akhauriyash/Code-Regression huggingface dataset:
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s,ss;
vector<int> v;

int main(void){
	cin>>n>>s>>ss;
	FOR printf("%c%c",s[i-1],ss[i-1]);
	return 0;
}



Measured memory_bytes: 256
import math
import numpy

N, D = map(int, input().split())

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

isTrue = 0

for i in range(N):
	x = list[i][0]
	y = list[i][1]
	
	cal = math.sqrt((x*x)+(y*y))
    
	if cal <= D:
		isTrue = isTrue+1

print(isTrue)

Measured memory_bytes: 63340
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
vector<int>v;
bool isPresent(int n){
    for(int i=0;i<v.size();i++){
        if(v[i]==n) return true;
    }
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    while(t--){
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        sort(arr,arr+n);
        for(int i=0;i<n;i++){
            sum+=arr[i];
        }
        sum-=arr[n-1]/2;
        cout<<sum;
    }
}
    

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,k;
  std::cin>>n>>k;

  long double ans=0.0l;

  rep(i,1,n+1){
    ll temp=i;
    ll cnt=0;
    while(temp<k){
      cnt++;
      temp<<=1;
    }
    ans+=pow(0.5l,cnt)/(long double)n;
  }

  std::cout<<std::setprecision(20)<<std::fixed<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 512
from collections import OrderedDict
N, M = map(int, input().split())

correct = set()
wrong = OrderedDict()

for _ in range(M):
  p, s = input().split()
  pn = int(p)
  if pn not in wrong:
    wrong[pn] = 0
  if s == 'AC':
    if pn not in correct:
      correct.add(pn)
  elif s == 'WA':
    if pn not in correct:
      wrong[pn] += 1

print(len(correct), sum([wrong[pn] for pn in correct]))


Measured memory_bytes: 38748
n, m = [int(v) for v in input().split()]
a, b = [], []
d = {}
for i in range(m):
    ai, bi = [int(v) for v in input().split()]
    a.append(ai)
    b.append(bi)
    d[ai] = d.get(ai, [])
    d[ai].append(bi)
    d[bi] = d.get(bi, [])
    d[bi].append(ai)

r = {}
def trace():
    tasks = [(1, 0)]
    i = 0
    while i < len(tasks):
        no, lv = tasks[i]
        for c in d[no]:
            if c != 1:
                if c not in r or (r[c][1] > lv and r[c][1] != 0):
                    r[c] = (no, lv)
                    tasks.append((c, lv + 1))
        i += 1
trace()

for i in range(2, n):
    if i not in r:
        print('No')
        break
else:
    print('Yes')
    for i in range(2, n +1):
        print(r[i][0])

Measured memory_bytes: 64268
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int N;
vector<int> b;
vector<int> buf;
vector<bool> flags;

void Output(int start, int end){
    for(int index = start; index >= end; --index){
        --buf[index];
        if(!flags[index]){
            continue;
        }
        if(buf[index] == 0){
            cout << b[index] << endl;
            flags[index] = false;
            Output(start, index);
        }
    }
}

int main(void){
    cin >> N;
    b = vector<int>(N, 0);
    buf = vector<int>(N, 0);
    bool clear = true;
    for(int cnt = 0; cnt < N; ++cnt){
        cin >> b[cnt];
        buf[cnt] = b[cnt];
        if((cnt + 1) < b[cnt]){
            clear = false;
            break;
        }
    }
    if(!clear){
        cout << "-1" << endl;
        return 0;
    }

    flags = vector<bool>(N, true);
    Output(N - 1, 0);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int n, x;
	cin >> n >> x;
	vector<int> a(n);

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

	int ans = 0;
	rep(i, n) {
		ans += a[i];
	}
	for (int i = 1; i < n; i++) {
		int res = i * x;
		vector<int> next_a = a;
		for (int j = 0; j < n; j++) {
			int k = (j + 1) % n;
			next_a[k] = min(a[k], a[j]);
			res += next_a[k];
		}
		a = next_a;
		ans = min(ans, res);
	}

	cout << ans << endl;


	return 0;
}

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

int main(){
	int x;
	int max = 1;
	int tmp;
	cin >> x;
	for(int i=2; i< sqrt(x); i++){
		tmp = i * i;
		while(tmp <= x){
			if(tmp > max) max = tmp;
			tmp *= i;
		}
	}
	cout << max;
}



Measured memory_bytes: 256
# Problem D - Multiple of 2019

# input
S = list(input())
N = len(S)

# initialization
ans = 0

# count
nums_2019 = [0]*2019
nums_2019[0] = 1
s = 0
for i in range(N-1, -1, -1):
    s += int(S[i]) * pow(10, N - i - 1, 2019)
    nums_2019[s%2019] += 1

for i in range(2019):
    if nums_2019[i]>=2:
        ans += nums_2019[i] * (nums_2019[i]-1) // 2

# output
print(ans)


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end());
	int fMx = b[n - 1];
    int SMx = b[n - 2];

	for (int i = 0; i < n; i++) {
		if (a[i] == fMx)
			cout << SMx << "\n";
		else 
			cout << fMx << "\n";
	}
	return 0;
}

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

void update_dpk12(int k, vector<int> & dp1, vector<int> & dp2, const vector<int> & As){
    int m1, m2;
    if (As[0] > As[k]){
        m1 = As[0];
        m2 = As[k];
        dp1[k] = 0;
        dp2[k] = k;
    }else{
        m1 = As[k];
        m2 = As[0];
        dp1[k] = k;
        dp2[k] = 0;
    }
    for (int mask = 1; mask < k; mask <<= 1) {
        if ((mask & k) == 0) continue;
        int s = k ^mask;
        if (As[dp1[s]] > m1) {
            dp2[k] = dp1[k];
            dp1[k] = dp1[s];
            m2 = m1;
            m1 = As[dp1[s]];
        }else if (As[dp1[s]] == m1){
            if (dp1[s] != dp1[k]){
                dp2[k] = dp1[s];
                m2 = m1;
            }
        }else if (As[dp1[s]] > m2){
            dp2[k] = dp1[s];
            m2 = As[dp1[s]];
        }
        if (s > 0 and As[dp2[s]] > m2 ){
            dp2[k] = dp2[s];
            m2 = As[dp2[s]];
        }
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    const int L = (1 << N);
    vector<int> As(L);
    for (auto & a : As) cin >> a;

    vector<int> dp1(L);
    vector<int> dp2(L);
    // dp1[k]  k の bit列 のサブセット i について、Aiが最大となるときの i
    // dp2[k]　k の bit列 のサブセット i について、Aiが２番目に大きい値となるときの i

    dp1[0] = 0;
    dp2[0] = -1;
    dp1[1] = (As[0] > As[1]) ? 0 : 1;
    dp2[1] = 1 - dp1[1];

    int ans = As[0] + As[1];
    cout << ans << '\n';

    for (int k = 2; k < L; ++k){
        update_dpk12(k, dp1, dp2, As);
        ans = max(ans, As[dp1[k]] + As[dp2[k]]);
        cout << ans << '\n';
    }

    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;


int main() {

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> aw;
    rep(i, n) {
        int xn;
        cin >> xn;
        aw.push_back(xn);
    }
    vector<int> bw;
    rep(i, m) {
        int yn;
        cin >> yn;
        bw.push_back(yn);
    }

    sort(aw.begin(), aw.end());
    sort(bw.begin(), bw.end());

    if (aw.back() < bw[0] &&  aw.back() < y && bw[0] > x ) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

}


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

int main(){
    int n,ans;
    cin>>n;
    ans=0;
 
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                ans=1;
                break;
            }
        }
        if(ans==1)break;
    }

    if(ans==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  //std::ostringstream oss;
  //oss << "ABC" << N;
  //std::string ans = oss.str();

  ll A, B;
  std::cin >> A >> B;

  bool judge = false;
  if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) judge = true;
  if (judge) print("Possible");
  else print("Impossible");

  return 0;
}


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

# 1行目
N,L = map(int,input().split())
mylist = []
mylist = list(map(int,input().split()))
#for i in range(N):
#  val = input()
#  if val:
#    mylist.append(val)
#  else:
#    break

i = 0
result = 0
res_bool = False
while result < 10 * N:
  result = N + i
  #print("i:{}".format(i))
  for a in str(result):
    #print("a:{}".format(a))
    if not a in [str(n) for n in mylist]:
      res_bool = True
    elif a in [str(n) for n in mylist]:
      #print("aがあった")
      res_bool =False
      break
  #print("res_bool:{}".format(res_bool))
  if res_bool:
    break
  i += 1
  
print(result)
      
     

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = 0x3f3f3f3f;
 
int a[11][11];
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    ll l, r;
    cin >> l >> r;
    int ans=2019;
    for(ll i=l; i<r; i++)
    {
        for(ll j=i+1; j<=r; j++)
        {
          	int x=i*j%2019;
            ans = min(ans, x);
            if(!ans)
            {
                cout << 0;
                return 0;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
using System;

namespace abc081_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int ret = 0;
            for (int i = 0; i < 3; i++)
            {
                if (s[i] == '1') ret++;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<vector>
#include<queue>
#include<string.h>
#include<functional>
#include<algorithm>
#include<iostream>
#include<limits.h>
#include<stdlib.h>
#include<assert.h>
using namespace std;

struct Edge
{
	int to, cost;
	Edge(int to_, int cost_):to(to_),cost(cost_){}
};
struct Node
{
	int index,cost,rest;
	Node(int index_, int cost_, int rest_): index(index_), cost(cost_), rest(rest_){}
	bool operator <(const Node &rhv)const
		{
			return cost < rhv.cost;
		}
	bool operator >(const Node &rhv)const
		{
			return rhv < *this;
		}
};

int N,M,C;
vector<Edge>edge[101];

int Solve(int k)
{
	bool visited[101][101]={};
	priority_queue<Node,vector<Node>,greater<Node> >q;
	q.push(Node(1,0,k));
	while(!q.empty()){
		Node node = q.top();
		q.pop();
		if(visited[node.index][node.rest])continue;
		visited[node.index][node.rest] = true;
		if(node.index == N)
			return node.cost;
		for(int i=0; i<edge[node.index].size(); ++i){
			Edge e = edge[node.index][i];
			q.push(Node(e.to, node.cost+e.cost, node.rest));
			if(e.cost && node.rest)
				q.push(Node(e.to, node.cost, node.rest-1));
		}
	}
	return 0x3fffffff;
}


int main()
{
	while(scanf("%d%d%d",&N,&M,&C),N){
		for(int i=0; i<=N; ++i){
			edge[i].clear();
		}

		for(int i=0; i<M; ++i){
			int f,t,c;
			scanf("%d%d%d",&f,&t,&c);
			edge[f].push_back(Edge(t,c));
		}
		int left=0, mid, right=N;
		while(left<right){
			mid = (left+right)/2;
			if(Solve(mid)<=C)right=mid;
			else left = mid+1;
		}
		printf("%d\n",left);
	}
	return 0;
}

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

vector<int> P;

int root(int v){ //根を返す
    if(P[v] == v) return v;
    else return root(P[v]);
}

bool is_same_set(int a, int b){ // 同じならtrue
    return root(a) == root(b);
}

void unite(int a, int b){ // aの根をbの根にくっつける
    P[root(a)] = root(b);
}

int main(){
    int n, q; cin >> n >> q;
    P.resize(n);
    for(int i = 0; i < n; i++){
        P[i] = i;
    }
    for(int i = 0; i < q; i++){
        int c, x, y; cin >> c >> x >> y;
        if(c == 0) unite(x, y);
        else if(c == 1){
            cout << is_same_set(x, y) << endl;
        }
    }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
LL f(LL a,LL b){
    return a/b;
}

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


int main(){
    LL a,b,c,d;cin >> a >> b >> c >> d;
    LL n = b-a+1;
    cout << n - (f(b,c)+f(b,d)-f(b,c*d/gcd(c,d))) + (f(a-1,c)+f(a-1,d)-f(a-1,c*d/gcd(c,d))) << endl;
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7
n, m = map(int, input().split())
X = list(map(int ,input().split()))
Y = list(map(int ,input().split()))
X.sort()
Y.sort()
mx, my = X[n-1], Y[m-1]
SX, SY = [0], [0]
for i in range(n):
    SX.append(mx-X[i])
for i in range(n):
    SX[i+1] += SX[i]
for i in range(m):
    SY.append(my-Y[i])
for i in range(m):
    SY[i+1] += SY[i]
xx = 0
for i in range(n):
    diff = mx-X[i]
    num = n-(i+1)
    tot = diff*num
    tot -= SX[n]-SX[i+1]
    xx += tot
yy = 0
for i in range(m):
    diff = my-Y[i]
    num = m-(i+1)
    tot = diff*num
    tot -= SY[m]-SY[i+1]
    yy += tot
print(xx*yy%MOD)


Measured memory_bytes: 106908
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		boolean ok=false;
		for(int i=a; i<=b; i++) {
			if(i%k==0) {
				ok=true;
			}
		}
		if(ok) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}
		sc.close();
	}


}

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

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

using namespace std;
using ll = long long;

int partition(vector<int> &a, int p, int r) {
    int bdry = 0;
    rep(i, a.size()) {
        if(a[i] <= a[r]) {
            swap(a[i], a[bdry]);
            bdry++;
        }
    }
    return bdry - 1;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int idx = partition(a, 0, n - 1);

    rep(i, n) {
        if(i == idx) printf("[");
        printf("%d", a[i]);
        if(i == idx) printf("]");
        printf(i == n - 1 ? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}//約数求める


ll kaijou(int n) {
	ll temp = 1;
	for (int i = 2; i <= n; i++) {
		temp *= i;
		temp %= MOD;
	}
	return temp;
}



int main() {
	string s;
	cin >> s;
	ll *num = new ll[s.size()+1];
	num[0] = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			num[i + 1] = num[i] + 1;
		}
		else {
			num[i + 1] = num[i];
		}
	}
	ll total = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'W')total += num[i];
	}
	cout << total;

	return 0;
}


Measured memory_bytes: 2180
n, y = map(int, input().split())
for senyen in range(n + 1):
    for gosenyen in range(n + 1 - senyen):
        manyen = n - senyen - gosenyen
        if senyen * 1000 + gosenyen * 5000 + manyen * 10000 == y:
            print(manyen, gosenyen, senyen)
            exit(0)
print("-1 -1 -1")

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

int isOddDigit(int num) {
  int digit = 0;
  while (num > 0) {
    num /= 10;
    digit++;
  }

  return digit % 2 == 1;
}

int main() {
  int N;
  int cnt = 0;
  cin >> N;

  for (int i = 1; i <= N; i++) {
    if (isOddDigit(i)) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
  int D;
  scanf("%d",&D);
  if (D == 25){
    printf("Christmas");
  }
  if (D == 24){
    printf("Christmas Eve");
  }
  if (D == 23){
    printf("Christmas Eve Eve");
  }
  if (D == 22){
    printf("Christmas Eve Eve Eve");
  }
  return 0;
}

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

using namespace std;

struct edge {
  int to, weight;
};

void dijkstra(vector<vector<edge>> graph, int start) {
  int n = graph.size();

  int dist[n];
  for (int i = 0; i < n; i++) {
    dist[i] = INT_MAX;
  }
  dist[start] = 0;

  priority_queue<pair<int, int>> que;
  que.push(make_pair(dist[start], start));
  while (!que.empty()) {
    int v = que.top().second;
    int c = que.top().first;
    que.pop();
    for (int i = 0; i < graph[v].size(); i++) {
      edge e = graph[v][i];
      if (dist[e.to] > c + e.weight) {
        dist[e.to] = c + e.weight;
        que.push(make_pair(dist[e.to], e.to));
      }
    }
  }

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

int main() {
  int n;
  cin >> n;
  vector<vector<edge>> graph;
  graph.resize(n);
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int v, c;
      cin >> v >> c;
      graph[u].emplace_back(edge{v, c});
    }
  }

  dijkstra(graph, 0);
}



Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
using namespace std;
long long a, b, c, d, e, na, nb, nc;
long long F[500000];
long long price(long long L) {
	if (L < nc)return c;
	if (L < nb + nc)return b;
	return a;
}
long long ruisekiwa(long long L, long long R) {
	if (L >= R)return 0;
	if (L == 0)return F[R - 1];
	return F[R - 1] - F[L - 1];
}
int main() {
	while (true) {
		cin >> a >> b >> c >> d >> e; if (a == 0)break;
		cin >> na >> nb >> nc;
		long long n = na + nb + nc, minx = na*a + nb*b + nc*c;
		for (long long i = 0; i < 500000; i++)F[i] = 0;
		for (long long i = 0; i < n; i++)F[i] = price(i);
		for (long long i = 1; i < n; i++)F[i] += F[i - 1];

		for (long long i = 0; i <= n; i++) {
			long long set1 = ruisekiwa(0, i);
			long long set2 = ruisekiwa(i, min(n, i + d));
			long long set3 = ruisekiwa(min(n, i + d), n);
			if (i >= d) {
				if (set1 >= i*e)set1 = i*e;
			}
			if (i < d) {
				if (set1 >= d*e)set1 = d*e;
			}
			if (set2 >= d*e)set2 = d*e;
			minx = min(minx, set1 + set2 + set3);
		}
		cout << minx << endl;
	}
	return 0;
}

Measured memory_bytes: 6992
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn dikstra(graph: &[Vec<(usize, usize)>]) -> Vec<usize> {
    let mut dists = vec![1usize << 30; graph.len()];

    dists[0] = 0;

    let mut h = BinaryHeap::new();
    h.push((0, 0));
    while let Some((_, n)) = h.pop() {
        for &(to, d) in &graph[n] {
            let dist = dists[n] + d;
            if dist < dists[to] {
                dists[to] = dist;
                h.push((-(dists[to] as i64), to))
            }
        }
    }
    dists
}

fn main() {
    let n = scan!(usize);

    let mut graph = vec![vec![]; n];
    for _ in 0..n {
        let vs = scan!(usize;;);
        for i in 0..vs[1] {
            graph[vs[0]].push((vs[(i + 1) * 2], vs[(i + 1) * 2 + 1]))
        }
    }
    let dists = dikstra(&graph);
    for (i, d) in dists.into_iter().enumerate() {
        println!("{} {}", i, d)
    }
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 
#define pb push_back
#define sz(a) (int)a.size()

const int INF=1e9+7;

void solve(){
	int n;
	cin >> n;
	int h[n];
	for(int i=0;i<n;++i) cin >> h[i];
	vi dp(n,INF);
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;++i){
		for(int j:{i-1,i-2})
		dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	}
	cout << dp[n-1] <<  nl;
}

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

	solve();
	
	return 0;
}







Measured memory_bytes: 3968
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<assert.h>

#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)>(b))?(b):(a)

typedef long long ll;
typedef unsigned long long ull;

int main(void)
{
    int m, n;
    scanf("%d%d", &n, &m);
    int* a = calloc(n, sizeof(int));
    int sum = 0;
    for (size_t i = 0; i < n; i++)
    {
        scanf("%d", a + i);
        sum += a[i];
    }
    double v = (double)sum / (4.0 * m);
    int c = 0;
    for (size_t i = 0; i < n; i++)
    {
        if (a[i]>=v)
        {
            c++;
        }
    }

    printf("%s", m <= c ? "Yes" : "No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    ll a[51]; ll b[51]; ll c[51]; ll d[51];
    int N,M;cin>>N>>M;
    int id;
    for(int i=0; i<N;i++) cin>>a[i]>>b[i];
    for(int i=1; i<=M;i++) cin>>c[i]>>d[i];

    for(int i=0; i<N;i++){
      ll dist = INF;
      for(int j=1; j<=M;j++){
        ll dd = max(a[i] - c[j], c[j]- a[i]) + max(b[i] - d[j], d[j]- b[i]);
        if(dist>dd){
          dist = dd; id=j;
        }
      }
      cout<<id<<endl;
      id = -1;
    }

    return 0;
}


Measured memory_bytes: 256
use std::io::*;

// 持ってる票数が固定 →　貪欲
// 全員投票しなくて良い →　平均値最大化っぽい
// しかし、全員持ってる票数が違う＋全員投票しなくてはいけないので、難しい。

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let p: usize = itr.next().unwrap().parse().unwrap();

    let mut s = 0;
    let mut a = Vec::new();
    for _ in 0..n {
        let w: usize = itr.next().unwrap().parse().unwrap();
        let b: usize = itr.next().unwrap().parse().unwrap();
        s += b * p;
        a.push(w * (100 - p) + b * p);
    }
    a.sort_by(|a, b| b.cmp(&a));
    for i in 0..n {
        if s <= a[i] {
            println!("{}", i + 1);
            return;
        }
        s -= a[i];
    }
}


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

int main(){
    int bl, conf;
    cin >> bl >> conf;
    vector<int> stone;
    stone.push_back(conf);

    for(int i=1; i<bl; i++){
        stone.push_back(conf - i);
    }
    for(int i=1; i<bl; i++){
        stone.push_back(conf + i);
    }
    sort(stone.begin(), stone.end());
    for(int i=0; i<stone.size(); i++){
        cout << stone.at(i) << " ";
    }
    return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO;
	
	string s, t;
	cin >> s >> t;
	
	int ans = 0;

	
	for (int i = 0; i < (int) s.size(); ++i) {
		if (s[i] != t[i]) 
			++ans;
		}
	cout << ans;
	
}


Measured memory_bytes: 3804
I,O,_,J,L,_,_ = gets.split.map(&:to_i)
p O + I + J + L + case
                  when [I,J,L].map{ |x| x % 2 }.uniq.size == 1; 0
                  when [I,J,L].min > 0; -1
                  when [I,J,L].count{ |x| x % 2 == 0 } == 2; -1
                  else -2
                  end

Measured memory_bytes: 3836
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << PREC(10);
  int n, d, cnt = 0;
  cin >> n >> d;
  vector<vector<int>> x(n,vector<int>(d));
  REP(i,n) REP(j,d) cin >> x[i][j];
  REP(i,n) {
    REP(j,n) {
      if(i == j) continue;
      double res = 0;
      REP(k,d) res += pow((double)x[i][k] - (double)x[j][k], 2);
      res = sqrt(res);
      if(floor(res) == res) cnt++;
    }
  }
  cout << cnt / 2 << endl;
  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

char mp[111][111];
int x[111];
int y[111];

int main(){
	
	int h,w;cin >> h >> w;
	REP(i,h){
		REP(j,w){
			cin >> mp[i][j];
			if(mp[i][j] == '#'){
				y[i]++;
				x[j]++;
			}
		}
	}
	
	REP(i,h){
		int cou = 0;
		REP(j,w){
			if(y[i] == 0 || x[j] == 0)continue;
			cout << mp[i][j];
			cou++;
		}
		if(cou)cout << endl;
	}
	return 0;
}


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

int main() {
    int W, H, N; cin >> W >> H >> N;
    int xmin = 0, xmax = W;
    int ymin = 0, ymax = H;
    while (N--) {
        int xi, yi, a; cin >> xi >> yi >> a;
        if (a == 1) xmin = max(xmin, xi);
        if (a == 2) xmax = min(xmax, xi);
        if (a == 3) ymin = max(ymin, yi);
        if (a == 4) ymax = min(ymax, yi);
    }
    if (xmin < xmax && ymin < ymax) {
        cout << (xmax - xmin) * (ymax - ymin) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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

int main(){
    string S;
    cin >> S;

    int i;

    if (S.size() == 2){
        cout << S;
    }
    else{
        for (i=2; i>=0; i--) cout << S[i];
    }
    cout << '\n';
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	int T, A;
	cin >> T >> A;
	vector<int> H;
	rep(i, 0, N) {
		int h;
		cin >> h;
		H.push_back(h);
	}

	int rsl = 1;
	double min_v = abs(T - H[0] * 0.006 - A);
	rep(i, 1, N) {
		double tmp = T - H[i] * 0.006;
		if(min_v > abs(tmp - A)) {
			rsl = i + 1;
			min_v = abs(tmp - A);
		}
	}

	cout << rsl << endl;
		
}


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

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){

    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    if(b<=0){
        if(d<=0){
            cout << a*c << endl;
        }
        else if(d>0&&c<=0){
            cout << a*c << endl;
        }
        else if(c>0){
            cout << b*c << endl;
        }
    }
    else if(b>0&&a<=0){
        if(d<=0){
            cout << a*c << endl;
        }
        else if(d>0&&c<=0){
            cout << max(b*d,a*c) << endl;
        }
        else if(c>0){
            cout << b*d << endl;
        }
    }
    else if(a>0){
        if(d<=0){
            cout << a*d << endl;
        }
        else if(d>0&&c<=0){
            cout << b*d << endl;
        }
        else if(c>0){
            cout << b*d << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける

int a,b;

int main() {
	cin >> a >> b;
	int keta = 1;
	int target = b;
	while (target > 0) {
		target /= 10;
		keta *= 10;
	}
	int res = a * keta + b;
	bool flag = false;
	for (int i = 1;i <= res;++i) {
		if (res == i * i)flag = true;
	}
	if (flag)puts("Yes");
	else puts("No");
	return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int n = S.size();
    int m = T.size();
    int ans = 1e+9;

    for(int i = 0; i < n-m+1; ++i) {
        int cnt = 0;
        for(int j = 0; j < m; ++j) {
            if (S.at(i+j) != T.at(j)) {   
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  std::vector<int> V,C;
  int tmp,ans;
  
  std::cin >> N ;
  for(int i=0; i<N; i++){
    std::cin >> tmp;
    V.push_back(tmp);
  }
  for(int i=0; i<N; i++){
    std::cin >> tmp;
    C.push_back(tmp);
  }
  
  
  
  ans = 0;
  for(int i=0; i<N; i++){
    if(V[i]>C[i]){
      ans += V[i] - C[i];
    }
  }
  
  
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}




int main(){

    int X,A;
    cin >>X >> A;

    cout << (X<A?0:10) << endl;
    

}

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

struct edge{
    int to, cost;
};

int N;
vector<vector<edge>> tree;
vector<int> dist;
vector<int> color;

void dfs1(int n){
    int nChi = tree[n].size();
    for(int i=0; i<nChi; i++){
        int v = tree[n][i].to;
        int w = tree[n][i].cost;
        if(dist[v] > dist[n] + w){
            dist[v] = dist[n] + w;
            dfs1(v);
        }
    }
}

void dfs2(int n, int prev){
    int nChi = tree[n].size();
    // cout << "dfs2 : " << n << endl;
    for(int i=0; i<nChi; i++){
        int v = tree[n][i].to;
        int w = tree[n][i].cost;
        if(v==prev) continue;
        if(dist[v] = dist[n] + w){
            if(w%2==0) color[v] = color[n];
            else color[v] = 1 - color[n];
            dfs2(v, n);
        }
    }
}

int main(){
    cin >> N;
    tree = vector<vector<edge>>(N+1, vector<edge>());
    for(int i=0; i<N-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        edge e;  e.to = v;  e.cost = w;
        tree[u].push_back(e);
        e.to = u;
        tree[v].push_back(e);
    }

    int root = 1;
    dist = vector<int>(N+1,1e9);
    dist[root] = 0;
    dfs1(root);
    
    color = vector<int>(N+1, 0);
    color[root] = 0;
    dfs2(root, 0);
    for(int i=1; i<=N; i++){
        cout << color[i] << endl;
    }
}

Measured memory_bytes: 9344
//--------ROMAN ITERATION -------------
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    Fast_IO();
    int n , x  ; 
    cin >> n >> x  ; 
    if ( n < x )
        cout << "0"; 
    else 
        cout << "10";
    
    return 0 ;
}



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

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

using namespace std;
using lint=long long;

lint solve(){
	lint a,b; cin>>a>>b;
	if(a<b) swap(a,b);
	if(a==b) return (a-1)+(b-1);

	lint m=sqrt(a*b)+1;
	while(m*m>a*b) m--;

	lint l=m,r=m;
	while((l+1)*r<a*b) l++;

	lint res=0;
	res+=b-1; // (a+1, b-1), (a+2, b-2), ..., (a+b-1, 1)
	res+=r-b; // (*, b+1), (*, b+2), ..., (l, r)
	res+=l-1; // (l-1, r+1), (l-2, r+2), ..., (1, l+r-1)
	if(m*m==a*b) res--;

	return res;
}

int main(){
	int q; cin>>q;
	rep(_,q) cout<<solve()<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  
  vector<int>x(N);
  vector<int>y(N);
  for(int i=0;i<N;i++){
    if(i%2!=0){if(i-1>=0){x[i]++;y[i]--;}
               if(i+1<N){x[i]++;y[i]--;}
    }
    if(i%2==0){if(i-1>=0){x[i]--;y[i]++;}
               if(i+1<N){x[i]--;y[i]++;}
    }
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  int64_t sumx=0,sumy=0;
  for(int i=0;i<N;i++){
    //cout<<"x "<<x[i]<<" "<<"y "<<y[i]<<endl;
    sumx+=(x[i]*A[i]);
    sumy+=(y[i]*A[i]);
  }
  cout<<max(sumx,sumy)<<endl;
  
  return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int P=1e9+7;
int n,k,m;
int dp[101][64000],sum[101][64000];
struct node {
	int a,b;
};
vector<node>num;
int main() {
	scanf("%d%d",&n,&k);
	int x=1;
	num.push_back((node)<%0,0%>);
	while(x<=n) {
		int t=n/x,y=n/t;
		num.push_back((node)<%x,y%>);
		x=y+1;
	}
	m=num.size();
	for(int i=1; i<m; i++) {
		dp[1][i]=num[i].b-num[i].a+1;
		sum[1][i]=(sum[1][i-1]+dp[1][i])%P;
	}
	for(int i=2; i<=k; i++) {
		for(int j=1; j<m; j++) {
			dp[i][j]=1ll*sum[i-1][m-j]*(num[j].b-num[j].a+1)%P;
			sum[i][j]=(sum[i][j-1]+dp[i][j])%P;
		}
	}
	printf("%d",sum[k][m-1]);
}

Measured memory_bytes: 51064
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[3];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		if(a[0]*a[0]+a[1]*a[1]!=a[2]*a[2])cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
}

Measured memory_bytes: 1168
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>

using namespace std;

using Weight=int;
using Edge=pair<size_t, size_t>;

static const Weight INF=1<<27;


void build_path(
    const vector<vector<size_t>> &via, size_t s, size_t t, vector<size_t> &path
) {
    size_t u=via[s][t];
    if (!~u) {
        path.push_back(s);
    } else {
        build_path(via, s, u, path);
        build_path(via, u, t, path);
    }
}

vector<size_t> build_path(
    const vector<vector<size_t>> &via, size_t s, size_t t
) {
    vector<size_t> path;
    build_path(via, s, t, path);
    path.push_back(t);
    return path;
}

int main() {
    size_t N, M;
    scanf("%zu %zu", &N, &M);

    vector<vector<Weight>> d(N, vector<Weight>(N, INF));
    for (size_t i=0; i<M; ++i) {
        size_t a, b;
        Weight c;
        scanf("%zu %zu %d", &a, &b, &c);

        --a, --b;
        d[a][b] = d[b][a] = c;
    }

    /* Warshall-Floyd */
    // path-buildable
    vector<vector<size_t>> via(N, vector<size_t>(N, -1));
    for (size_t k=0; k<N; ++k)
        for (size_t i=0; i<N; ++i)
            for (size_t j=0; j<N; ++j)
                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                    via[i][j] = k;
                }

    set<Edge> es;
    for (size_t s=0; s<N; ++s)
        for (size_t t=s+1; t<N; ++t) {
            vector<size_t> path=build_path(via, s, t);

            for (size_t i=1; i<path.size(); ++i) {
                size_t fst=path[i-1], snd=path[i];
                if (fst > snd) swap(fst, snd);

                es.insert(make_pair(fst, snd));
            }
        }

    printf("%zu\n", M-es.size());
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int min=1000000;
		long max=-1000000;
		long sum=0;

		for(int i=0;i<N; i++){
			int a=sc.nextInt();
			if(a<=min) {
				min=a;
			}
			if(a>max) {
				max=a;
			}
			sum+=a;		
		}
		System.out.printf("%d %d %d\n",min,max,sum);
	}


}



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

int main(){
    int ans=0;
    string s;
    cin>>s;

    for(int i=0;i<s.length();i++){
        if(s[i]==s[i+1]){
            if(s[i]=='0')s[i+1]='1';
            else s[i+1]='0';

            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 512