akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

vector<ll> A;
ll sum[100005];
int main() {
	ll N, M;
	cin >> N >> M;

	A.resize(N);
	priority_queue<ll> pq;
	rep(i, N) {
		cin >> A[i];	
	}
	sort(A.begin(), A.end());
	vector<pint> S;
	rep(i, M) {
		ll B, C;

		cin >> B >> C;

		S.push_back({ C, B });

	}
	
	sort(S.begin(), S.end());
	ll ind = 0;
	ll ans = 0;


	for (int i = M - 1; i >= 0; i--) {

		if (S[i].first <= A[ind] || ind >= N){
			break;
		}
		ll kaisuu = 0;
		while (S[i].first > A[ind] && ind < N && kaisuu < S[i].second) {
			A[ind] = S[i].first;
			ind++;
			kaisuu += 1;

		}

	}

	rep(i, N) {
		ans += A[i];
	}
	
	cout << ans << endl;
	return 0;
}

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

int main(){

	int  N;
	int  W;
	int vi[1000];
	int wi[1000];
	int DP[1001][1001];

	cin>>N>>W;

	for(int i=0;i<N;i++){
		cin>>vi[i]>>wi[i];
	}

	for(int j=0;j<=W;j++){
		DP[N][j]=0;
	}
	
	for(int i=N-1;i>=0;i--){
		for(int j=0;j<=W;j++){
			if(j<wi[i]){
				DP[i][j]=DP[i+1][j];
			}else{
				if(DP[i+1][j]>DP[i+1][j-wi[i]]+vi[i]){
					DP[i][j]=DP[i+1][j];
				}else{
					DP[i][j]=DP[i+1][j-wi[i]]+vi[i];
				}
			}
		}
	}

	cout<<DP[0][W]<<endl;
	
	return 0;
}


	

Measured memory_bytes: 3480
//written by libra9z
#define LOCAL_TIME
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> pii;
typedef pair <ll,int> plli;
typedef pair <int,pii> pipii;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector <vector<int> > mat;
#define rep(i,n) for (int i=0;i<(n);i++)
#define Rep(i,a,b) for (int i=(a);i<=(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rRep(i,a,b) for (int i=(a);i>=b;i--)
#define repit(it,a) for ((__typeof(a.begin())) it=a.begin();it!=a.end();it++)
#define repx(x,a) for (auto x:a)
#define pb push_back
#define mp make_pair()
#define eb emplace_back
#define X first
#define Y second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Debug(x) cerr<<#x<<" = "<<x<<endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl
#define Debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")\n"
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n"
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define get1(x,a) x>>a
#define get2(x,a,b) x>>a>>b
#define get3(x,a,b,c) x>>a>>b>>c
#define getn(x,n,v) rep(i,n) x>>v[i]
#define put1(x,a) x<<a
#define put2(x,a,b) x<<a<<" "<<b
#define put3(x,a,b,c) x<<a<<" "<<b<<" "<<c
#define putn(x,n,v) rep(i,n) x<<v[i]<<" ";
#define eaq(n,x) __typeof(x) n=x;
#define RET(p,x) return p<<x<<endl,0;
const ll h1=999999937;
const ll h2=1000000009;
const int inf=2e9;
const ll mod=1000000007;
const int dx[]={1,0,-1,0,1,0,-1,0};
const int dy[]={0,1,0,-1,1,0,-1,0};
const double pi=3.141592653589793;
const bool multitests=false,alotoftests=false;
ifstream fin("input.txt");ofstream fout("output.txt");
stringstream sinout;
long long n,f[100];
bool solve(int __test)
{
	f[0]=2LL;
	f[1]=1LL;
	cin>>n;
	for (int i=2;i<=n;++i)
	{
		f[i]=f[i-1]+f[i-2];
	}
	cout<<f[n];
	return false;
}
signed main()
{
	int __tests,__test=1;
	(multitests==true)?((alotoftests==false)?scanf("%d",&__tests):__tests=inf):__tests=1;
	for (;(alotoftests==true && multitests==true)?(!solve(__test)):(__test<=__tests);++__test)
	{
		if (!(multitests==true && alotoftests==true))
		{
			solve(__test);
		}
	}
	#ifdef LOCAL_TIME
	eprintf("\n\nSystem Time : %d ms",clock());
	#endif
	fin.close();fout.close();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1005,M=5005;
int sum[N],n,fa[N],a[N],b[N],dp[N][M];
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;i++)scanf("%d",&fa[i]);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)dp[i][0]=1;
	for (int i=n;i;i--){
		b[i]=-1;
		for (int j=a[i];j>=0;j--)
			if (dp[i][j]){
				b[i]=sum[i]-j;
				break;
			}
		if (b[i]==-1){
			puts("IMPOSSIBLE");
			return 0;
		}
		if (i==1)continue;
		int y=fa[i];
		for (int j=a[y];j>=0;j--){
			if (a[i]&&b[i])dp[y][j]=0;
			if (j>=a[i])dp[y][j]|=dp[y][j-a[i]];
			if (j>=b[i])dp[y][j]|=dp[y][j-b[i]];
		}
		sum[y]+=a[i]+b[i];
	}
	puts("POSSIBLE");
}


Measured memory_bytes: 18048
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
  int m,d,mlist[12]={31,29,31,30,31,30,31,31,30,31,30,31},dsum;
  string res;
  while(cin>>m>>d){
    dsum=0;
    if(!m)return 0;
    for(int i=0;i<m;i++){
      dsum+=(i+1!=m)?mlist[i]:d;
    }
    //1 Thur 2 Fri 3 Satu 4 Sun 5 Mon 6 Tues 0 Wed
    switch(dsum%7)
      {
      case 0:
	res="Wednesday";
	break;
      case 1:
	res="Thursday";
	break;
      case 2:
	res="Friday";
	break;
      case 3:
	res="Saturday";
	break;
      case 4:
	res="Sunday";
	break;
      case 5:
	res="Monday";
	break;
      case 6:
	res="Tuesday";
	break;
      }
    cout<<res<<endl;
  }
}

Measured memory_bytes: 0
mod = 10**9+7

H, W, A, B = [int(_) for _ in input().split()]

fact = [1] * (2 * 10**5+1)
for i in range(1, 2*10**5+1):
    fact[i] = i * fact[i-1] % mod

def comb(n, k):
    a = fact[n] % mod
    b = (fact[k] * fact[n-k]) % mod
    b_ = pow(b, mod-2, mod)
    return  (a * b_) % mod

ans = 0
for w in range(B, W):
    ans += comb(H-A-1 + w, w) * comb(A-1 + W-w-1, W-w-1) % mod

print(ans % mod)


Measured memory_bytes: 10996
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (A, B, C) = (input[0], input[1], input[2])

print((A == B && B == C) ? "Yes" : "No")

Measured memory_bytes: 7908
#!/usr/bin/python3

import array
from fractions import Fraction
import math
import os
import sys


class Vec(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y
        super().__init__()

    def __add__(self, other):
        return Vec(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vec(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __rmul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __truediv__(self, scalar):
        return Vec(self.x / scalar, self.y / scalar)

    def __iadd__(self, other):
        self.x += other.x
        self.y += other.y
        return self

    def __isub__(self, other):
        self.x -= other.x
        self.y -= other.y
        return self

    def __imul__(self, scalar):
        self.x *= scalar
        self.y *= scalar
        return self

    def __idiv__(self, scalar):
        self.x /= scalar
        self.y /= scalar
        return self

    def __neg__(self):
        return Vec(-self.x, -self.y)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def abs2(self):
        return self.x * self.x + self.y * self.y

    def __abs__(self):
        return math.sqrt(float(self.abs2()))

    def __str__(self):
        return '({}, {})'.format(self.x, self.y)


def main():
    x1, y1, x2, y2 = read_ints()
    Q = read_int()
    for _ in range(Q):
        x, y = read_ints()
        print(*solve(Vec(x1, y1), Vec(x2, y2), Vec(x, y)))


def solve(u, v, a):
    v -= u
    a -= u
    b = Fraction(2 * v.dot(a), v.abs2()) * v - a
    b += u
    return float(b.x), float(b.y)


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7184
import java.util.*;
public class Main {
	Scanner sc;
	int power2(int n) {
		int x = 1;
		for (int i=0;i<n;i++) x *= 2;
		return x;
	}
	
	int root2(int n) {
		int count = 1;
		while (n/2!=0) {
			n /= 2;
			count++;
		}
		return count;
	}
	
	void run() {
		sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int n = sc.nextInt();
			
			int[] b = new int [root2(n)];
			
			for (int i=0;i<b.length;i++) {
				if (n%2 == 1) b[i] = 1;
				n /= 2;
			}
			LinkedList<Integer> list = new LinkedList<Integer>();
			for (int i=0;i<b.length;i++) 
				if (b[i] == 1) list.add(power2(i));
			for (int i=0;i<list.size()-1;i++) System.out.print(list.get(i)+" ");
			System.out.println(list.get(list.size()-1));
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int match[] = {0,2,5,5,4,5,6,3,7,6};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vint mp(10,0);
    REP(i,m){
        int ai;
        cin >> ai;
        mp[match[ai]] = max(mp[match[ai]],ai);
    }
    vint a;
    REP(i,10){
        if(mp[i]>0)a.pb(mp[i]);
    }
    sort(rALL(a));
   
   
    vector<int> dp(n+1,-INF);
    dp[0]=0;
    for(int i=1;i<=n;++i){
        for(int j : a){
            if(i-match[j]>=0&&dp[i-match[j]]>=0){
                dp[i]=max(dp[i],dp[i-match[j]]+1);
            }
        }
    }
    vint ans(n);
    int now = n;
    int id=0;
    for(int i = dp[n]-1;i>=0;i--){
        for(int j : a){
            if(now-match[j]>=0&&dp[now-match[j]]==i){
                ans[id]=j;
                id++;
                now=now-match[j];
                break;
            }
        }
    }
    //sort(rALL(ans));
    REP(i,n){
        if(ans[i]==0){
            cout << endl;
            break;
        }
        cout << ans[i];

    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(void) {
  int zero_begin = 0, one_begin = 0;
  string S;

  cin >> S;

  for (int i = 0; i < S.length(); i++) {
    // If S[i] is not 1, increment odd
    if ((i%2 == 0 && S[i] == '1') || (i%2 == 1 && S[i] == '0')) {
      one_begin++;
    } else if ((i%2==0 && S[i] == '0') || (i%2 == 1 && S[i] == '1')) {
      zero_begin++;
    }
  }

  if (one_begin <= zero_begin) {
    cout << one_begin << '\n';
  } else {
    cout << zero_begin << '\n';
  }

  return 0;
}

Measured memory_bytes: 512
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])

if  1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1<= b <= 12:
    print('YYMM')
elif 1<= a <= 12:
    print('MMYY')
else:
    print('NA')

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  vi a(3);rep(i,3)cin>>a[i];
  sort(All(a));
  cout<<a[2]-a[1]+a[1]-a[0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n, b;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i++){
        cin >> d[i];
    }

    sort(d.begin(),d.end());
    b = d.size() / 2;

    if(d[b - 1] == d[b]){
        cout << 0;
    }
    else{
        cout << d[b] - d[b - 1];
    }
    
    return 0;
}

Measured memory_bytes: 640
x1, y1, x2, y2 = map(int,input().split())
vec = [x2-x1,y2-y1]
x3 = x2 - vec[1]
y3 = y2 + vec[0]
x4 = x3 - vec[0]
y4 = y3 - vec[1]
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

	string o;
	string e;
	cin >> o >> e;
	int co=0, ce = 0;
	bool isO = true;
	string ans;
	while((co != len(o) || ce != len(e)))
	{
		if (isO)
		{
			ans+=o[co];
			co++;
		}
		else
		{
			ans+=e[ce];
			ce++;
		}
		isO ^= true;
	}

		dbg(co);
		dbg(ce);
		if (co < len(o))
		{
			dbg(co);
			ans+=o[co];
		}
		else if (ce < len(e))
		{
			dbg(ce);
			ans+=e[ce];
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

int main(){
    ll K; cin >> K;
    int ans = 1;
    ll now = 7;
    set<ll> exist;
    exist.insert(now);
    while(now%K != 0){
        now = (now*10 + 7) % K;
        ans++;
        if (exist.count(now) > 0){
            cout << -1 << endl;
            return 0;
        }
        else{
            exist.insert(now);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 50504
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

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

n,m = ips()
a = iprow()

s = sum(a)
a.sort(reverse= True)
for i in range(m):
    if a[i]  < s* (1/(4*m)): j(0)
j(1)

Measured memory_bytes: 5716
#include<stdio.h>

int main(void)
{
int n,r,p,c,i,j;
int card[51];
int tem[51];

while(scanf("%d%d",&n,&r),n+r){

for(i=1;i<=n;i++){
card[i]=i;
}

for(i=0;i<r;i++){
scanf("%d%d",&p,&c);
for(j=n-p+1;j>n-p+1-c;j--){
tem[j]=card[j];
}
for(j++;j+c<=n;j++){
card[j]=card[j+c];
}
for(;j<=n;j++){
card[j]=tem[j-p+1];
}
}
printf("%d\n",card[n]);
}
return 0;
}

Measured memory_bytes: 600
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine();

            if (int.Parse(x) > 0) {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine("1");
            }
        }
    }
}


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

int main(void) {
    long long A, B, C, K, x;
    scanf("%lld%lld%lld%lld", &A, &B, &C, &K);
    if (K<=A) x=K;
    else if (K<=A+B) x=A;
    else x=A-(K-A-B);
    printf("%lld", x);
    return 0;
}


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

int main(){
    vector<char>v;
    char a,b;
    for(int i=0;i<3;i++){
        cin>>a>>b;
        v.push_back(a);
        v.push_back(b);
    }
    sort(v.begin(),v.end());
    string s="";
    for(int i=0;i<v.size();i++){
        s+=v[i];
    }
    bool flag=false;
    if(s=="112234")flag=true;
    if(s=="112334")flag=true;
    if(s=="112344")flag=true;
    if(s=="122334")flag=true;
    if(s=="122344")flag=true;
    if(s=="123344")flag=true;
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(10);
    cout<<fixed;
    long double l=0;
    cin>>l;
    cout<<(l*l*l)/27<<endl;
}


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

int main(){
  int num;
  cin >> num;
  for(int i= 0; i<num ; i++){
    float x[4];
    float y[4];
    cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
    float AB=0;
    float CD=0;
    AB =(y[1]-y[0]) / (x[1]-x[0]);
    CD =(y[3]-y[2]) / (x[3]-x[2]);
    if(CD == -0)CD = 0;
    if(AB == -0)AB = 0;
    if(AB == CD)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

#define inp 200005
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }

using namespace std;

// Pick yourself up, 'cause...

vector<int> g[inp];
int n;
vector<vector<int>> dp(inp,vector<int>(2,0));
vector<bool> vis(inp,false);

void func(int cn , int p) // 0 white , 1 black
{
    if(vis[cn]) return;

    vis[cn]=true;

    ll white = 1;
    ll black = 1;
    for(int c:g[cn])
    {
        if(c==p) continue;
        func(c , cn);
        white *= (dp[c][0] + dp[c][1]);
        black *= dp[c][0];
        white%=mod;
        black%=mod;
    }
    dp[cn][0]=white;
    dp[cn][1]=black;
}

int main()
{
    jaldi

    cin>>n;

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

    func(1 , 0);
     
    cout << ( dp[1][0] + dp[1][1] ) % mod;
    
    return 0;
}

Measured memory_bytes: 28996
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pdp         pair<double, pii>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    int n, k;
    cin>>n>>k;
    vector<int>vec(n);
    for(int i =0 ; i < n ; i++ ) cin>>vec[i];


    int lo = 1, hi = INF, ret = -1;

    while(lo <=hi) {
        int mid = (lo+hi)/2;

        
        int cnt = 0;

        for(auto x : vec) {
            cnt += (x-1)/mid + 1 -1;
        }

        if(cnt > k) {
            lo = mid + 1;
        }
        else {
            ret = mid;
            hi = mid - 1;
        }

    }
    cout<<ret<<'\n';
    return 0;
}

Measured memory_bytes: 3972
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;
struct UnionFind{
    vector<int> par,sizes;
    UnionFind(int n):par(n+1),sizes(n+1,1){
        rep2(i,1,n)par[i]=i;
    }
    int find(int x){
        return (x==par[x]?x:par[x]=find(par[x]));
    }
    bool unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return false;
        if(sizes[x]<sizes[y]){
            swap(x,y);
        }
        par[y]=x;
        sizes[x]+=sizes[y];
        return true;
    }
    bool same(int x,int y) {return (find(x)==find(y));}
    int size(int x) {return sizes[find(x)];}
};
main(){
    int n=in();
    UnionFind uf(n+1);
    int m=in();
    int mm=m;
    rep(i,m){
        int a=in(),b=in();
        if(!uf.unite(a,b)){
            mm--;
        }
        in();
    }
    cout<<n-mm;
}



Measured memory_bytes: 1024
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int i,j,k,l,diff,cnt = 0,flag = 0;
	int n = sc.nextInt();                                                                                                                                                                                                                             
	char[] target = sc.next().toCharArray();
	char[][] old = new char[n][];
	
	void doIt2(){
n1:		for(k = 0; k < old[i].length; k ++ ){
			if(target[0] == old[i][k]){
				for(j = k + 1; j < old[i].length; j ++ ){				
					if(target[target.length-1] == old[i][j]){
						if((j - k) % (target.length-1) != 0)continue;
						diff = (j - k) / (target.length-1);
						flag = 2;
						for(l = 1; l <= target.length-1; l ++ ){
							if(target[l] == old[i][k + l * diff]){
								flag ++;
								if(flag == target.length){
									cnt ++;
									break n1;
								}
							}
							else break;
						}
					}
				}
			}
		}
	}
	
	void doIt(){
		for(i = 0; i < n; i ++ ){
			old[i] = sc.next().toCharArray();
			doIt2();
		}
		System.out.println(cnt);
	}
	
	public static void main(String args[]){
		new Main().doIt();
	}
}

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

int N, ans, tmp;
int x[100][100], y[100][100], d[100][100];

void dfs(int Y, int X)
{
	if (d[Y][X] == tmp)
	{
		ans++;
		tmp++;
		return;
	}

	if (d[Y][X]>=0 && d[Y][X]<tmp)
	{
		tmp++;
		return;
	}

	d[Y][X] = tmp;
	dfs(y[Y][X], x[Y][X]);
}

int main()
{
	while (cin >> N, N)
	{
		for (int i=0; i<N; i++)
		for (int k=0; k<N; k++)
			cin >> x[i][k] >> y[i][k];

		ans = 0; tmp=0;
		memset(d, 0xff, sizeof(d));
		for (int i=0; i<N; i++)
		for (int k=0; k<N; k++)
			if(d[i][k] == -1)
				dfs(i,k);

		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b; cin >> a >> b;
	int dp[b + 50][2], arr[a + 50];
	for(int i=1; i<=a; i++)
		cin >> arr[i];
	sort(arr + 1, arr + a + 1);
	memset(dp, 0, sizeof(dp));
	for(int i=1; i<=b; i++)
	{
		bool yes1 = false, yes2 = false;
		for(int j=1; j<=a; j++)
		{
			if(i - arr[j] < 0) break;
			if(dp[i - arr[j]][1] == false) yes1 = true;
			if(dp[i - arr[j]][0] == false) yes2 = true;
		}
		dp[i][0] = yes1; dp[i][1] = yes2;
//		cout << dp[i][0] << ' ' << dp[i][1] << '\n';
	}
	if(dp[b][0]) cout << "First";
	else		 cout << "Second";
	cout << '\n';
	return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define INF 0x3f3f3f3f
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    int vis[n+1];
    memset(vis, 0, sizeof(vis));
    while(k--) {
        int d;
        cin >> d;
        for(int i=0;i<d;i++) {
            int x;
            cin >> x;
            vis[x] = 1;
        }
    }
    int cnt = 0;
    for(int i=1;i<=n;i++) {
        if(vis[i] == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <stack>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <climits>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		int in[26] = {0};
		bool exist[26] = {false};
		bool array[26][26] = {{0}};
		
		rep(i, n){
			char str[64];
			scanf("%s", str);
			int first = str[0] - 'a';
			int end = str[strlen(str)-1] - 'a';
			
			in[first]++;
			in[end]--;
			exist[first] = exist[end] = true;
			array[first][end] = true;
		}
		
		bool ok = true;
		int start = -1;
		rep(i, 26){
			if(in[i] != 0){
				ok = false;
				break;
			}
			else if(exist[i] && start == -1)
				start = i;
		}
		
		if(ok && start != -1){
			stack<int> S;
			S.push(start);
			while(!S.empty()){
				int s = S.top();
				S.pop();
				if(!exist[s])
					continue;
				exist[s] = false;
				rep(i, 26){
					if(array[s][i] && exist[i])
						S.push(i);
				}
			}
			
			rep(i, 26){
				if(exist[i]){
					ok = false;
					break;
				}
			}
		}
		
		puts(ok ? "OK" : "NG");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

int main(){
    int N, tmp = 0;
    std::cin >> N;
    std::vector<int> L(N);
    for(auto i = 0; i < N; i++){
        std::cin >> L.at(i);
    }

    auto iter = std::max_element(L.begin(), L.end());
    auto dist = std::distance(L.begin(), iter);
    for(auto i = 0; i < L.size(); i++){
        if(i != dist){
            tmp += L.at(i);
        }
    }

    std::string ans = L.at(dist) < tmp ? "Yes" : "No";

    std::cout << ans << std::endl;

    return 0;

}


Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
cnt=h=0
for i in range(len(A)):
    tmp=A[i]
    if i==0:
        h=A[i]
    else:
        if tmp>=h:
            h=tmp
        else:
            cnt+=h-tmp
print(cnt)

Measured memory_bytes: 32152
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  double n,t,a,h[1000],T,d=1000,ans;
  cin >> n >> t >> a;
  for(int i=0; i<n; i++) {
    cin >> h[i];
    T=t-h[i]*0.006;
    if(abs(T-a)<d) {
      d=abs(T-a);
      ans=i+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   int n;
   cin>>n;
   if(n<2)cout<<1<<endl;
   else if(n<4)cout<<2<<endl;
   else if(n<8)cout<<4<<endl;
   else if(n<16)cout<<8<<endl;
   else if(n<32)cout<<16<<endl;
   else if(n<64)cout<<32<<endl;
   else  cout<<64<<endl;
}

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

int swap(int* a,int* b){
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	// your code goes here
	int N;
	cin >> N;
	int p[N];
	int i;
	int ans=0;
	for(i=0;i<N;i++){
		cin >> p[i];
	}
	
	for(i=0;i<N;i++){
		if(p[i] == i+1){
			if(i==0){swap(&p[i],&p[i+1]);}
			else if(i==N-1){swap(&p[i-1],&p[i]);}
			else {swap(&p[i],&p[i+1]);}
			ans++;
		}
	}
	
	cout << ans << '\n';
	return 0;
}

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

int main(){
  int a,b,c,d,e;
  int res=0;
cin >> a >> b >> c >> d >> e;
if(a == 0) res=1;
else if(b == 0) res=2;
else if(c == 0) res=3;
else if(d==0) res=4;
else res=5;
cout << res << endl;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
  int n,mi,a,ans=-(1<<30);
  cin>>n>>mi;
  for(int i=1;i<n;i++){
    cin>>a;
    if(ans<a-mi)ans=a-mi;
    if(a<mi)mi=a;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair <int, int>;

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  string s, t;
  cin >> s >> t;
  ll ans = 0;
  rep(i, s.size()) {
    if (s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;

ll H,W;
ll p[3];

int main(){
 
cin>>H>>W;

if(H%3==0||W%3==0){
    cout<<0<<endl; return 0;
}
if(H>W) swap(H,W);

ll Min=INF;
for(ll w=1; w<W; w++){
    p[0]=w*H,p[1]=(W-w)*(H/2),p[2]=(W-w)*(H-H/2);
    sort(p,p+3);
    Min=min(Min,p[2]-p[0]);
}
for(ll h=1; h<H; h++){
    p[0]=h*W,p[1]=(H-h)*(W/2),p[2]=(H-h)*(W-W/2);;
    sort(p,p+3);
    Min=min(Min,p[2]-p[0]);
}

ll k=W%3;
ll s=(W-k)/3,S=s+1;
s=s*H,S=S*H;
Min=min(Min,S-s);
k=H%3;
s=(H-k)/3; S=s+1;
s=s*W; S=S*W;
Min=min(Min,S-s);

cout<<Min<<endl;

}

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

using namespace std;

int main(void){
    int N,M;
    cin>>N>>M;
    long long mod=1000000007;
    vector<int> a(M);
    for(int i=0;i<M;i++){
        cin>>a[i];
    }
    vector<bool>step(N+1,true);
    for(int i=0;i<M;i++){
        step[a[i]]=false;
    }
    vector<long long>dp(N+1);
    dp[0]=1;
        for(int i=0;i<=N;i++){
            for(int next=i+1;next<=min(N,i+2);next++){
                if(step[next]){
                    dp[next]+=dp[i];
                    dp[next]=dp[next]%mod;
                }
            }
        }
    cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int w,h,n;
    cin>>w>>h>>n;
    vector<vector<bool> >rect(w,vector<bool>(h,false));
    for(int i=0;i<n;i++)
    {
        int x1,y1,a;
        cin>>x1>>y1>>a;
        if(a==1){
            for(int i=0;i<x1;i++)
            {
                for(int j=0;j<h;j++)
                {
                    rect[i][j]=true;
                }
            }
        }
        else
        if(a==2){
            for(int i=x1;i<w;i++)
            {
                for(int j=0;j<h;j++)
                {
                    rect[i][j]=true;
                }
            }
        }
        else
        if(a==3){
            for(int i=0;i<w;i++)
            {
                for(int j=0;j<y1;j++)
                {
                    rect[i][j]=true;
                }
            }
            
        }
        else{
            for(int i=0;i<w;i++)
            {
                for(int j=y1;j<h;j++){
                    rect[i][j]=true;
                }
            }
        }
    }
    int count=0;
    for(int i=0;i<w;i++)
    {
        for(int j=0;j<h;j++)
        {
            if(rect[i][j]==false)count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 3636
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: Non-decreasing
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;
const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

int as[MAX_N];
vpii ans;

/* subroutines */

/* main */

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

  int mina = INF, maxa = -INF, mini = -1, maxi = -1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &as[i]);
    if (mina > as[i]) mina = as[i], mini = i;
    if (maxa < as[i]) maxa = as[i], maxi = i;
  }
  //printf("mina=%d, maxa=%d\n", mina, maxa);

  if (mina < 0 && maxa > 0) {
    if (-mina <= maxa) {
      for (int i = 0; i < n; i++)
	if (i != maxi) as[i] += maxa, ans.push_back(pii(maxi, i));
      mina += maxa;
    }
    else {
      for (int i = 0; i < n; i++)
	if (i != mini) as[i] += mini, ans.push_back(pii(mini, i));
      maxa += mina;
    }
  }

  if (mina >= 0)
    for (int i = 1; i < n; i++)
      as[i] += as[i - 1], ans.push_back(pii(i - 1, i));
  else
    for (int i = n - 1; i > 0; i--)
      as[i - 1] += as[i], ans.push_back(pii(i, i - 1));

  printf("%d\n", (int)ans.size());
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
  //for (int i = 0; i < n; i++) printf("%d ", as[i]); putchar('\n');
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=3.14159265358979323846;

void solve(){
    double a, b, x;
    cin >> a >> b >> x;
    if(x/a > a*b/2.0){
        //cout << 1 << endl;
        double res = atan((2.0*b-(2*x/(a*a)))/a);
        printf("%.10f\n", 180.0/PI*res);
    }
    else if(x/a == a*b/2.0){
        //cout << 2 << endl;
        double res = atan(b/a);
        printf("%.10f\n", 180.0/PI*res);
    }
    else{
        double res = atan(a*b*b/(2.0*x));
        printf("%.10f\n", 180.0/PI*res);
    }
}

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

Measured memory_bytes: 512
using System;

namespace Print_Test_Cases
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            int i = 0;

            while(true)
            {
                int x = int.Parse (Console.ReadLine ());
                i++;

                if (x == 0) {break;}
                Console.WriteLine ("Case " + i + ": " + x);

            }
        }
    }
}

Measured memory_bytes: 9308
import std.algorithm;
import std.format;
import std.stdio;
import std.string;

void main() {
  int n;
  readf(" %s",&n);

  long ct,ca;
  readf(" %s %s", &ct, &ca);
  foreach (i; 1 .. n) {
      long a,t;
      readf(" %s %s", &t, &a);

      long na = (ca + a - 1) / a * a;
      long nt = (ct + t - 1) / t * t;

      long k = max(na/a,nt/t);

      ct = t * k;
      ca = a * k;

      debug {
          writeln(ct,",",ca);
      }
  }

  writeln(ct+ca);
}


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

using namespace std;

static int s_count( const char *s, const char *t )
{
	int c = 0;

	while ( *t != '\0' )
	{
		if ( *s != *t )
		{
			c++;
		}

		s++;
		t++;
	}

	return c;
}

void main_body( void )
{
	string S;
	string T;
	int cmin;

	cin >> S;
	cin >> T;

	cmin = T.length();

	for ( int i = 0; i < ( S.length() - T.length() + 1 ); i++ )
	{
		int c;

		c = s_count( S.c_str() + i, T.c_str() );

		if ( cmin > c )
		{
			cmin = c;
		}
	}

	cout << cmin << endl;

	return;
}

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

	if ( argc > 1 )
	{
		c = atoi( argv[ 1 ] );
	}
	else
	{
		c = 1;
	}

	for ( int i = 0; i < c; i++ )
	{
		main_body();
	}

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 10;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n;
int odd[N >> 1], even[N >> 1];
int evenTree[N << 2], oddTree[N << 2];
int pos[N];
vector<int> vec;

struct node{
    int l, r;
    int m;

    bool operator< (const node &rhs) const {
        return m > rhs.m;
    }
};
priority_queue<node> pq;

void build(int root, int *data, int start, int end, int *dataTree) {
    if (start == end) {
        dataTree[root] = data[start];
        return;
    }
    int mid = (start + end) >> 1;
    build(root << 1 | 1, data, start, mid, dataTree);
    build((root << 1) + 2, data, mid + 1, end, dataTree);
    dataTree[root] = min(dataTree[root << 1 | 1], dataTree[(root << 1) + 2]);
}

int query(int *dataTree, int root, int start, int end, int qstart, int qend) {
    if (start == qstart && end == qend)
        return dataTree[root];
    int mid = (start + end) >> 1;
    if (qend <= mid)
        return query(dataTree, root << 1 | 1, start, mid, qstart, qend);
    if (qstart > mid)
        return query(dataTree, (root << 1) + 2, mid + 1, end, qstart, qend);
    return min(query(dataTree, root << 1 | 1, start, mid, qstart, mid), query(dataTree, (root << 1) + 2, mid + 1, end, mid + 1, qend));
}

void qPush(int l, int r) {
    node nd;
    nd.l = l, nd.r = r;
    nd.m = l % 2 == 0 ? query(evenTree, 0, 0, (n >> 1) - 1, l >> 1, r >> 1) : query(oddTree, 0, 0, (n >> 1) - 1, l >> 1, (r >> 1) - 1);
    pq.push(nd);
}

int main() {
    int i, j;
    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        int t;
        scanf("%d", &t);
        pos[t] = i;
        if (i & 1)
            odd[i >> 1] = t;
        else
            even[i >> 1] = t;
    }
    build(0, even, 0, (n >> 1) - 1, evenTree);
    build(0, odd, 0, (n >> 1) - 1, oddTree);
    node nd;
    nd.l = 0, nd.r = n - 1, nd.m = evenTree[0];
    pq.push(nd);
    while (!pq.empty()) {
        node nd = pq.top();
        pq.pop();
        vec.push_back(nd.m);
        int pair = nd.l % 2 == 0 ? query(oddTree, 0, 0, (n >> 1) - 1, pos[nd.m] >> 1, nd.r >> 1) : query(evenTree, 0, 0, (n >> 1) - 1, (pos[nd.m] >> 1) + 1, nd.r >> 1);
        vec.push_back(pair);
        if (nd.l < pos[nd.m])
            qPush(nd.l, pos[nd.m] - 1);
        if (pos[pair] - pos[nd.m] > 1)
            qPush(pos[nd.m] + 1, pos[pair] - 1);
        if (nd.r > pos[pair])
            qPush(pos[pair] + 1, nd.r);
    }
    for (i = 0; i < n; ++i)
        printf("%d ", vec[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 9640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend();
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int main() {
  makei(N);
  say(N/3);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] a = new int[31];
		int data = 0;
		for(int i = 0 ; i < 28 ; i ++){
			data=scan.nextInt();
			a[data]=data;
		}
		for(int i = 1 ; i < 31; i ++){
			if(a[i]==0)
				System.out.println(i);
		}
	}
}

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

using namespace std;

int main(){

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

    
    unordered_map<int,int> mp;

    for(int i = 0; i < m; i++){
        int s, c;
        cin>>s>>c; s--;
        if((mp.count(s) == 1 && mp[s] != c) || 
        ((s == 0 && c == 0) && n > 1)){
            cout<<-1<<"\n";
            return 0;
        }
        mp[s] = c;
    }

    vector<int> dig(n, -1);

    for(int i = 0; i < n; i++){
        if(mp.count(i) == 1){
            dig[i] = mp[i];
        }
    }

    if(n == 1 && m == 0){
        cout<<0<<"\n";
        return 0;
    }
    for(int i=  0; i < n; i++){
        if(i == 0 && dig[i] == -1)
            dig[i] = 1;
        else if(dig[i] == -1)
        {
            dig[i] = 0;
        }
        
    }

    if(n == 2 && dig[0] == 0 && dig[1] == 0){
        cout<<-1;
        return 0;
    }
    if(n == 3 && dig[0] == 0 && dig[1] == 0 && dig[2] == 0){
        cout<<-1;
        return 0;
    }

    for(int i = 0; i < n;  i++){
        cout<<dig[i];
    }
   


}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define INF 10000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int color[N];
int M[N][N];
int d[N];
int p[N];
int n;

void prim(void);

int main()
{
    int i,j,sum = 0;
    
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++){
            scanf("%d",&M[i][j]);
        }
    }
    prim();
    
    for(i = 0;i < n;i++){
        if(p[i] != -1){
            sum += M[i][p[i]];
        }
    }
    printf("%d\n",sum);
    return 0;
}

void prim(void)
{
    int i,u = 0,v = 0;
    int mincost;
    for(u = 0;u < n;u++){
        color[u] = WHITE;
        d[u] = INF;
        p[u] = -1;
    }
    d[0] = 0;
    
    while(1){
        mincost = INF;
        u = -1;
        for(i = 0;i < n;i++){
            if(color[i] != BLACK && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }
        
        if(u == -1) break;
        
        color[u] = BLACK;
        
        for(v = 0;v < n;v++){
            if(color[v] != BLACK && M[u][v] != -1){
                if(M[u][v] < d[v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
}



Measured memory_bytes: 2052