akhauriyash/Code-Regression huggingface dataset:
#include "stdio.h"
#include <queue>
#include <string.h>
using namespace std;
int sx, sy, tx, ty;
void solve(){
  for(int i=0; i<ty-sy; i++){
    printf("U");
  }
  for(int i=0; i<tx-sx+1; i++){
    printf("R");
  }
  for(int i=0; i<ty-sy+1; i++){
    printf("D");
  }
  for(int i=0; i<tx-sx+1; i++){
    printf("L");
  }
  printf("U");

  for(int i=0; i<tx-sx; i++){
    printf("R");
  }
  for(int i=0; i<ty-sy+1; i++){
    printf("U");
  }
  for(int i=0; i<tx-sx+1; i++){
    printf("L");
  }
  for(int i=0; i<ty-sy+1; i++){
    printf("D");
  }
  printf("R\n");

}

int main(){

  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

  solve();

  return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int* arr=new int[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    int f=0,count=0;
    for(int i=0;i<n;i++)
    {
        double d= (1.0/(4.0 * m) )*(sum);
        double d1=(double)arr[i];
        if(d1>=d){
            count++;
        }
    }
    if(count>=m){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    delete[] arr;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s=="abc") cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int s,a,b,c,d;
    scanf("%d",&s);
    if(s>=0&&s<=86400){
    a=s/3600;
    b=s%3600;
    c=b/60;
    d=b%60;
    printf("%d:%d:%d\n",a,c,d);
    }
    return 0;
}



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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

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

  int a, b;

  int n;

  cin >> n;

  for(int i = 1; i <= 9; i++)
    for(int j = 1; j <= 9; j++) 
      if(i * j == n)
        return cout << "Yes" << endl, 0;

  return cout << "No" << endl, 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
ll inv(ll n){
    return modpow(n,mod-2);
}
long long modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll ans=1;
    rep(i,k){
        ans*=n;
        ans%=mod;
        n--;
    }
    ll t=1;
    rep(i,k){
        ans*=inv(t);
        ans%=mod;
        t++;
    }
    return ans;
}
int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans=modpow(2,n)-1;
    ans-=modcom(n,a);
    ans-=modcom(n,b);
    ans%=mod;
    out((ans+mod)%mod);
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int d,n,t=0,i;
	cin>>d>>n;
	for(i=1;t<n;i++)
	{
		bool b=1;
		int tmp=i;
		for(int j=0;j<d;j++)
		{
			if(tmp%100!=0)
			{
				b=0;
				break;
			}
			tmp/=100;
		}
		if(tmp%100==0) b=0;
		if(b) t++;
	}
	cout<<i-1;
  rt0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 220000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
vi dp(1000,-1);
int f(int a){
	if(dp[a]+1)return dp[a];
	return dp[a]=powmod(fact[a],MOD-2,MOD);
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int t=0;
	t+=min(a,d);
	d-=min(a,d);
	d-=min(b,d);
	t-=min(c,d);
	cout<<t<<endl;

}


Measured memory_bytes: 3664
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    RS int
    |>fun c -> if (c.[0]=c.[1]) then "Yes" else "No"
    |>stdout.WriteLine
    0


Measured memory_bytes: 11220
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	switch (op) {
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		case '?':
			return 0;
	}
	main();	
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9;
const ll mod=1e9+7;
ll a,b,c,d;
map<ll,ll>ma;
ll solve(ll now){
    if(ma.find(now)!=ma.end()){
        return ma[now];
    }
    ll res;
    ll k;
    if(now>inf*2){
        k=2;
        if(now%k==0){
            res=solve(now/k)+a;
        }else{
            res=solve(now/k)+a+now%k*d;
            res=min(solve(now/k+1)+a+(k-now%k)*d,res);
        }
    }else{
        res=now*d;
    }
    if(now/2>0){
        k=2;
        if(now%k==0){
            res=min(solve(now/k)+a,res);
        }else{
            res=min(solve(now/k)+a+now%k*d,res);
            res=min(solve(now/k+1)+a+(k-now%k)*d,res);
        }
    }
    if(now/3>0){
        k=3;
        if(now%k==0){
            res=min(solve(now/k)+b,res);
        }else{
            res=min(solve(now/k)+b+now%k*d,res);
            res=min(solve(now/k+1)+b+(k-now%k)*d,res);
        }
    }else if(now>1){
        k=3;
        res=min(solve(now/k+1)+b+(k-now%k)*d,res);
    }
    if(now/5>0){
        k=5;
        if(now%k==0){
            res=min(solve(now/k)+c,res);
        }else{
            res=min(solve(now/k)+c+now%k*d,res);
            res=min(solve(now/k+1)+c+(k-now%k)*d,res);
        }
    }else if(now>1){
        k=5;
        res=min(solve(now/k+1)+c+(k-now%k)*d,res);
    }
    ma[now]=res;
    return res;
}
signed main(){
    ll t;cin>>t;
    while(t){
        t--;
        ll n;cin>>n>>a>>b>>c>>d;
        ma.clear();
        ma[0]=0;
        ll ans=solve(n);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long r,a,b;
    cin>>r>>a>>b;
    if(r>1 && b>=a || r==1 && a==b)
        cout<<(r-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl; 
 } 

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
alst = list(map(int, input().split()))
q = int(input())
dd = defaultdict(int)
for num in alst:
    dd[num] += 1
ans = sum(alst)
for _ in range(q):
    b, c = map(int, input().split())
    ans -= b * dd[b]
    ans += c * dd[b]
    dd[c] += dd[b]
    dd[b] = 0
    print(ans)

Measured memory_bytes: 24176
a = list(input())
for i in range(len(a)):
    a[i] = int(a[i])

ans = 0
for i in range(len(a)):
    if a[i] == 0:
        continue
    
    c = 0
    for j in range(i):
        c *= 10
        c += a[j]
    
    d = 0
    for j in range(i, len(a)):
        d *= 10
        d += a[j]
    
    if (c + d) % 2 != 0:
        continue

    x = (c + d) // 2
    y = d - x

    if x >= 0 and y >= 0:
        ans += 1

print(ans)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define INT long long
#define oo (6*(1e18))
using namespace std;
INT n, m, t[200020];
unordered_map<INT, INT> d;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(INT i = 0, j ; i < n ; i++ )
        cin>>j, d[j]++;
    cin>>m;
    for(INT i = 0, j ; i < m ; i++ )
    {
        cin>>j;
        if( !d[j] ) return cout<<"NO"<<endl, 0;
        d[j]--;
    }
    cout<<"YES\n";
    return 0;
}


Measured memory_bytes: 8520
from  collections import defaultdict

n=int(input())

def prime_factorize(n):
    d=defaultdict(int) 
    while n % 2 == 0:
        d[2]+=1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f]+=1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n]+=1
    return d

u=prime_factorize(n) 
cnt=0
for key,value in u.items():
    r=10**12
    l=0 
    while r-l>1:
        mid=(r+l)//2
        if mid*(mid+1)//2<=value:
            l=mid 
        else:
            r=mid
    cnt+=l
print(cnt)

Measured memory_bytes: 66020
n = int(input())
L = list(map(int,input().split()))
from collections import Counter
LL = Counter(L)
cnt = 0
sum1 = 0
for v in LL.values():
    a = v*(v-1)//2
    sum1 +=a

li = []
for i in range(n):
    li.append((L[i],LL[L[i]]))

for i in range(n):
    c = li[i][1]
    c = c*(c-1)//2
    b = li[i][1]-1
    b = b*(b-1)//2
    print(sum1-(c-b))

Measured memory_bytes: 33824
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Buffer(make([]byte, 500000), 500000)
	sc.Split(bufio.ScanWords)

	a := nextInt()
	s := next()

	if a >= 3200 {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}

	fmt.Println()
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
        char c;
        while(1){
             scanf("%c", &c);
             if('A'<=c&&c<='Z'){
                  c=c+32;
             }else if('a'<=c&&c<='z'){
                  c=c-32;
             }
             printf("%c",c);
             if(c=='\n'){
                  break;
             }
        }
        
	return 0;
}


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

int main()
{
    int q;
    cin >> q;
    deque<int> d;
    for (int i = 0; i < q; i++)
    {
        int flag;
        cin >> flag;
        int dir, num;
        int p;
        switch(flag)
        {
        case 0:
            cin >> dir >> num;
            if (dir == 0)
            {
                d.push_front(num);
            }
            else
            {
                d.push_back(num);
            }
            break;
        case 1:
            cin >> p;
            if (p < d.size())
            {
                cout << d[p] << "\n";
            }
            break;
        case 2:
            cin >> dir;
            if (dir == 0)
            {
                d.pop_front();
            }
            else
            {
                d.pop_back();
            }
            break;

        default:
            break;

        }
    }

    return 0;
}



Measured memory_bytes: 4564
w, h, x, y = map(int, input().split())

if w / 2 == x and h / 2 == y:
    ans = w / 2 * h
    print("{:.9f}".format(ans), 1)
    
else:
    ans = w / 2 * h
    print("{:.9f}".format(ans), 0)

Measured memory_bytes: 2940
def triangular(x,y,z)
  return x+y>z && y+z>x && z+x>y
end

n=gets.to_i
ln=gets.split(' ').map(&:to_i)
res=0
(0...n).each do |i|
  (i+1...n).each do |j|
    next if ln[i]==ln[j]

    (j+1...n).each do |k|
      next if ln[i]==ln[k] || ln[j]==ln[k]

      if triangular(ln[i],ln[j],ln[k])
        res += 1
      end
    end
  end
end
p res

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

int main() {
	int n, m, a[100][100] = {}, b[100] = {}, c[100] = {};
	cin >> n >> m;

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
	}

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

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;

using ll = long long;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  sort(all(L));
  ll sum = 0;
  for(int i = 0; i < N - 1; i++){
    sum += L[i];
  }
  cout << (L[N - 1] < sum ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int r = 0;
    int now = 0;
    ll ans = 0;
    for (int l = 0; l < n; ++l) {
        while (r < n && ((now ^ a[r]) == now + a[r])) {
            now ^= a[r];
            r++;
        }
        ans += r - l;
        now ^= a[l];
        if (l == r) r++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	if(a==b)
		cout<<"Draw"<<endl;
	else if(b==1)
		cout<<"Bob"<<endl;
	else if(a==1)
		cout<<"Alice"<<endl;
	else
		a>b?cout<<"Alice":cout<<"Bob";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
    int a,b;
    cin>>a>>b;
     int c=0;
    for(int i=a;i<=b;i++)
    {
        int h=i;
        int rev=0;
        while(h)
        {
            rev=rev*10 + h%10;
            h=h/10;

        }
        if(rev==i)
            c++;

    }
    cout<<c;


 return 0;
}








Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, M=1e9+1; string ans="YES"; cin >> N; int A[N]; vector<bool> C(M);
for(i=0; i<N; i++){ cin >> A[i]; if(C[A[i]]){ ans="NO"; break; } C[A[i]]=true; }
cout << ans << "\n";
}

Measured memory_bytes: 123136
#include<stdio.h>
#include<stdlib.h>
int main(){
	int a,b,c,d,e,f;
	float x,y;
	while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)!=EOF){
		/*if((b>=0&&e>=0)||(b<0&&e<0)){
			x=(c*abs(e)-f*abs(b))/(a*abs(e)-d*abs(b));
		}
		else{
			x=(c*abs(e)+f*abs(b))/(a*abs(e)+d*abs(b));
		}
		y=(c-a*x)/b;*/
		x = (float)(c*e-b*f)/(a*e-d*b);
		y = (float)(c*d-a*f)/(b*d-a*e);
		if(-0.0005<x && x<=0)x=0;
		if(-0.0005<y && y<=0)y=0;
		printf("%1.3f %1.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 636
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;;){

			Scanner sc2 = new Scanner(sc.nextLine());

			int h = sc2.nextInt();

			int w = sc2.nextInt();

			

			if((w|h)==0)break;

			

			int[][] map = new int[h][w];

			int[] dx = {0,0,1,-1,0};

			int[] dy = {-1,1,0,0,0};

			for(int i =0 ; i < h; i++){

				String buffer = sc.nextLine();

				for(int j = 0; j < w; j++){

					char b = buffer.charAt(j);

					int mapn = 4;

					switch(b){

					case '^':

						mapn = 0;

						break; 

					case 'v':

						mapn = 1;

						break; 

					case '>':

						mapn = 2;

						break; 

					case '<':

						mapn = 3;

						break; 

					}

					map[i][j] = mapn;

				}

			}

			boolean hasVisited[][] =new boolean[h][w];

			String ret = "";

			for(int x=0,y=0;;x+=dx[map[y][x]],y+=dy[map[y][x]]){

				if(hasVisited[y][x]) {

					ret = "LOOP";

					break;

				}

				hasVisited[y][x] = true;

				if(map[y][x] == 4){

					ret = x+" "+y;

					break;

				}

			}

			System.out.println(ret);			

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
using namespace std;
const int N = 1e5 + 5;
int main(){
    int n ;
    cin >> n;
    vector<int> a(n);
    long long xr = 0;
for(int i = 0 ; i<n;  i++){
        cin>> a[i];
        xr^=a[i];
}
    for(int i = 0 ; i<n; i++)cout<<(xr^a[i])<<" " ;
}







Measured memory_bytes: 4056
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main()
{
	int ans,a,n,i,m,j,out=0;
	map<int,int> N;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a;
		N[a]++;
	}
	cin>>m;
	for(i=0;i<m;i++)
	{
		cin>>a;
		if(!N[a])
		{
			puts("NO");
			return 0;
		}
		N[a]--;
	}
	puts("YES");

	return 0;
}






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

using i64 = long long int;

int main(){
    int n;
    cin >> n;
    set<string> st;
    string s;
    cin >> s;
    st.insert(s);
    bool ok = true;
    for(int i=1;i<n;++i){
        string w;
        cin >> w;
        if(st.count(w))ok = false;
        if(w[0] != s.back())ok = false;
        st.insert(w);
        s = w;
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]

paths = [[0] * (N + 1) for _ in range(N + 1)]

edges = []
for i in range(M):
    a, b = [int(_) for _ in input().split()]
    paths[a][b] = 1
    paths[b][a] = 1
    edges.append((a, b))


class UF:
    def __init__(self, v):
        self.parent = None
        self.val = v

    @property
    def root(self):
        if not self.parent:
            return self
        return self.parent.root

    def __str__(self):
        if self.parent:
            return str(self.val) + ' ' + str(self.parent.val)
        return str(self.val) + ' None'


def merge(u1, u2):
    r1 = u1.root
    r2 = u2.root
    if r1 == r2:
        return
    r1.parent = r2


def chk(a, b):
    nodes = [UF(i) for i in range(N + 1)]
    for i in range(1, N):
        for j in range(i + 1, N + 1):
            if paths[i][j]:
                merge(nodes[i], nodes[j])
    return int(nodes[a].root != nodes[b].root)


ans = 0
for e in edges:
    paths[e[0]][e[1]] = 0
    paths[e[1]][e[0]] = 0
    ans += chk(e[0], e[1])
    paths[e[0]][e[1]] = 1
    paths[e[1]][e[0]] = 1
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 44441e-8;




ll ar[100010][3];
ll dp[100010][3];


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

    ll n;
    cin>>n;
    for(ll i=0; i<n; i++)
    {
        for(ll j=0; j<3; j++)
        {
            cin>>ar[i][j];
        }
    }

    for(ll i=0; i<3; i++)
    {
        dp[0][i]=ar[0][i];
    }

    for(ll i=1; i<n; i++)
    {
        dp[i][0]=ar[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=ar[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=ar[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }


//    for(ll i=0; i<n; i++)
//    {
//        for(ll j=0; j<3; j++)
//        {
//            cout<<dp[i][j]<<ss;
//        }
//        cout<<nn;
//    }




    ll ans=max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});

    cout<<ans<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 8280
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define fr(i,s,e) for(ll i=s;i<e;i++)
using namespace std;

int main() {
    ll n;
    cin>>n;
    unordered_map<string,ll>mp;
    mp["AC"]=0;
    mp["WA"]=0;
    mp["TLE"]=0;
    mp["RE"]=0;
    fr(i,0,n)
    {
        string a;
        cin>>a;
        mp[a]++;
    }
        cout<<"AC x "<<mp["AC"]<<"\n";
        cout<<"WA x "<<mp["WA"]<<"\n";
        cout<<"TLE x "<<mp["TLE"]<<"\n";
        cout<<"RE x "<<mp["RE"]<<"\n";
    
    
  	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.Arrays;

public class Main{
	public static void main(String[]args){
    	Scanner sc=new Scanner(System.in);
      	int N=sc.nextInt();
      	int array[]=new int[N];

      	for(int t=0;t<N;t++){
        	array[t]=sc.nextInt();
        }

      	Arrays.sort(array);
				int big=N/2;
				int small=N/2-1;

				

				System.out.println(array[big]-array[small]);
}
}


Measured memory_bytes: 51816
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define all(x) x.begin(),x.end() 
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 3e3 + 7;
    const int INF = 1e15;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int dpd[MAX][MAX];
    int a[MAX];

    void solve()
    {
        cin>>n;
        fo(i,0,n)
        cin>>a[i];

        rfo(L,n-1,0)
        {
            fo(R,L,n)
            {
                if(L==R)
                    dpd[L][R]=a[L];
                else
                    dpd[L][R]=max(a[L]-dpd[L+1][R],a[R]-dpd[L][R-1]);
            }
        }
        cout<<dpd[0][n-1]<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 70016
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
ab = nan(n)
d = [(ab[i][1], ab[i][0], ab[i][1] - ab[i][0]) for i in range(n)]
d.sort()

ok = True
c = 0
for i in range(n):
    b, a, p = d[i]
    if p < c:
        ok = False
        break
    c += a

print("Yes" if ok else "No")

Measured memory_bytes: 73476
h,w=[int(i) for i in input().split()]
s=[input() for i in range(h)]
count=0

M = [["#" for i in range(w)] for j in range(h)]

for i in range(h):
  for j in range(w):
    count=0
    if s[i][j]==".":
      
      if j-1>=0:
           if s[i][j-1]=="#":
               count=count+1
      if j<w-1:
           if s[i][j+1]=="#":
               count=count+1            
      if i-1>=0:
           if s[i-1][j]=="#":
               count=count+1    
      if i<h-1:
           if s[i+1][j]=="#":
               count=count+1                
              
      if j-1>=0 and i-1>=0:
           if s[i-1][j-1]=="#":
               count=count+1
      if j<w-1 and i-1>=0:
           if s[i-1][j+1]=="#":
               count=count+1            
      if i<h-1 and j-1>=0:
           if s[i+1][j-1]=="#":
               count=count+1    
      if i<h-1 and j<w-1:
           if s[i+1][j+1]=="#":
               count=count+1                     
              
      M[i][j]=count

M_LIST=[]
for i in range(h):
    M_LIST.append("".join(map(str,M[i])))
    print(M_LIST[i])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  string s,ans="AKIHABARA";
  int j=0;
  cin>>s;
  if(s.size()>9) cout<<"NO"<<endl;
  else{
  for(int i=0;i<ans.size();){
    if(s[i]!=ans[j]){
      if(ans[j]!='A'){
        cout<<"NO"<<endl;
        break;
      }else i--;
    }
    i++;
    j++;
    if(j==ans.size()) cout<<"YES"<<endl;
  }
  }
}

Measured memory_bytes: 256
class BinarySearch:

    def __init__(self, S, n):
        self.target = S
        self.length = n
    
    def search(self, key):
        left = 0
        right = self.length
        while left<right:
            mid = int((left+right)/2)
            if self.target[mid]==key:
                return True
            elif self.target[mid]<key:
                left = mid + 1
            elif self.target[mid]>key:
                right = mid
        return False


def main():
    n = int(input())
    S = [int(i) for i in input().split()]
    q = int(input())
    T = (int(i) for i in input().split())
    bs = BinarySearch(S, n)
    count = 0
    for t in T:
        if bs.search(t):
            count += 1
    print(count)

if __name__=='__main__':
    main()


Measured memory_bytes: 16900
S = input()
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

ans = "None"
for i in range(len(alphabet)):
    if(alphabet[i] not in S):
        ans = alphabet[i]
        break
    
print(ans)

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

class Node{
public:
    int parent, rank;
    Node(int id): parent(id), rank(0){}
};

int find(vector<Node>& nodes, const int& x){
    if(nodes[x].parent != x){
        nodes[x].parent = find(nodes, nodes[x].parent);
    }
    return nodes[x].parent;
}
void unite(vector<Node>& nodes, const int& x, const int& y){
    int px = find(nodes, x), py = find(nodes, y);
    if(nodes[px].rank < nodes[py].rank){
        nodes[px].parent = py;
    }
    else if(nodes[py].rank < nodes[px].rank){
        nodes[py].parent = px;
    }
    else{
        nodes[px].rank++;
        nodes[py].parent = px;
    }
}
int main(){
    int n, q, c, x, y; 
    cin >> n >> q;
    vector<Node> nodes;
    for(int i = 0; i < n; i++){
        nodes.push_back(Node(i));
    }
    for(int i = 0; i < q; i++){
        cin >> c >> x >> y;
        if(c == 0) unite(nodes, x, y);
        else{
            cout << (int)(find(nodes, x) == find(nodes, y)) << endl;
        }
    }
}



Measured memory_bytes: 3248
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$x = $in->nextInt();
$a = $in->nextInt();
$b = $in->nextInt();

if (abs($x-$a) < abs($x-$b)) {
	$out->println('A');
} else {
	$out->println('B');
}

?>


Measured memory_bytes: 4604
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100
#define IN (1<<21)
#define O 0
#define I 1

int prim(void);

int n,A[N][N];

int main(){
  int i,j,s;
  scanf("%d",&n);
  for(i=O;i<n;i++){
    for(j=O;j<n;j++){
      scanf("%d",&s);
      A[i][j]=(s==-I) ? IN:s;
    }
  }
  printf("%d\n",prim());
  return 0;
}

int prim(){
  int i,u,v,m,a=O,d[N],pi[N],color[N];

  for(i=O;i<n;i++){
    d[i]=IN;
    pi[i]=-I;
    color[i]=WHITE;
  }
  d[O]=O;

  while(I){
    m=IN;
    u=-I;
    for(i=O;i<n;i++){
      if(m>d[i] && color[i]!=BLACK){
        u=i;
        m=d[i];
      }
    }
    if(u==-I){
      break;
    }
    color[u]=BLACK;
    for(v=O;v<n;v++){
      if(color[v]!=BLACK && A[u][v]!=IN){
        if(d[v]>A[u][v]){
          d[v]=A[u][v];
          pi[v]=u;
          color[v]=GRAY;
        }
      }
    }
  }
  for(i=O;i<n;i++){
    if(pi[i]!=-I){
      a+=A[i][pi[i]];
    }
  }
  return a;
}




Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int t[n+1],x[n+1],y[n+1];
    t[0] = x[0] = y[0] = 0;
    for(int i = 0; i < n; i++) {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }
    bool flag = true;
    for(int i = 0; i < n; i++) {
        int dt = t[i+1] -t[i];
        int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
        if(dt < dist) {
            flag = false;
        }
        if(dt % 2 != dist % 2) {
            flag = false;
        }
    }
    if(flag) {
        cout << "Yes";
    }else {
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		for(int i=2; i<=n;i+=2) {
			for(int j=1;j<=n; j+=2) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

const ll p = 1e9+7;

string s;
int ct[26], n;
ll ans = 1;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	for (int i = 0; i < n; ++i)
		ct[s[i]-'a']++;
	for (int i = 0; i < 26; ++i)
		ans = ans*(ct[i]+1)%p;
	cout << ans-1 << endl;
}

Measured memory_bytes: 512
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n,k = map(int, input().split())
    if n%k == 0:
        print(0)
    else:
        print(1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9488
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  ll N,M;
  cin >> N >> M;
  vector<ll> A(N),sum(N+1,0);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  for(int i=1; i<=N; i++){
    sum[i] = sum[i-1] + A[i-1];
  }
  ll ok=0,ng=300000;
  ll ans=0;
  while(ng-ok>1){
    ll mid=(ok+ng)/2;
    ll tmp=0,cnt=0;
    for(int i=0; i<N; i++){
      ll num = lower_bound(A.begin(),A.end(),mid-A[i]) - A.begin();
      cnt += N-num;
      tmp += sum[N]-sum[num] + A[i]*(N-num);
    }
    if(cnt>=M){
      ok = mid;
      ans = tmp - (cnt-M)*mid;
    }else{
      ng = mid;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
   int N;
   cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   int count=0;
   for(int i=0;i<N;i++){
      if(a[a[i]-1]-1==i) count++;
   }
   cout<<count/2<<endl;
   return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include<algorithm>
#include<sstream>
#include<stack>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 998244353;
const ll INF = (1LL << 60);
string s, t, u; ll n, m = 6, k, q = 0, ans, sum =0,b,c = INF; 
int main() {
    cin >> n;
    rep(i, n) {
        cin >> b;
        sum += abs(b);
        if (b < 0)q++;
        c = min(c, abs(b));
    }
    if (q % 2 == 0) cout << sum << endl;
    else cout << sum - 2 * c << endl;
}

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (2 * x[i] <= 2 * (k - x[i]))sum += 2 * x[i];
		else sum += 2 * (k - x[i]);
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define REP(i,a,b) for(int i=a; i<=b; i++)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x,y;
    cin >> x >> y;
    bool flag=false;
    for(int i=0; i<=x; i++){
        if(((2*i)+(4*(x-i)))==y){
            flag=true;
            break;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s, t;
  cin >> s >> t;

  REP(i,t.length()){
    REP(j,s.length()){
      if(t[i] > s[j]){
        printf("Yes\n");
        return 0;
      }
    }
  }

  REP(i,t.length()){
    REP(j,s.length()){
      if(t[i] != s[j]){
        printf("No\n");
        return 0;
      }
    }
  }

  if(t.length() > s.length()){
    cout << "Yes\n";
    return 0;
  }

  printf("No\n");
  return 0;
}



Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll m=in(),d=in();
    ll cnt=0;
    for(ll i=1;i<=m;++i){
        for(ll j=2;j<10;++j){
            if(i!=j&&i%j==0){
                ll dd=(i/j)*10+j;
                if(1<=dd&&dd<=d)++cnt;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s[1003] = {}, a3[9] = {}, a2[6] = {}, a[7] = {}, b[4] = {"aacd", "bbcd", "efgg", "efhh"};
    for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) a3[i] += '.';
    for (int i = 0; i < 9; i += 3) for (int j = 0; j < 9; j += 3) a3[i][j] = a3[i + 1][j] = a3[i + 2][j + 1] = a3[i + 2][j + 2] = 'a';
    for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) a2[i] += '.';
    a2[0][0] = a2[0][1] = a2[3][3] = a2[3][4] = 'a';
    a2[0][2] = a2[1][2] = a2[3][5] = a2[4][5] = 'b';
    a2[2][2] = a2[2][1] = a2[5][5] = a2[5][4] = 'c';
    a2[2][0] = a2[1][0] = a2[5][3] = a2[4][3] = 'd';
    a2[0][3] = a2[1][3] = a2[2][4] = a2[2][5] = 'e';
    a2[3][0] = a2[4][0] = a2[5][1] = a2[5][2] = 'f';
    for (int i = 0; i < 7; i++) for (int j = 0; j < 7; j++) a[i] += '.';
    a[0][0] = a[1][0] = a[2][1] = a[2][2] = a[3][0] = a[4][0] = a[5][1] = a[5][2] = a[0][3] = a[1][3] = a[2][4] = a[2][5] = a[3][3] = a[4][3] = a[5][4] = a[5][5] = 'a';
    a[0][6] = a[1][6] = a[6][0] = a[6][1] = 'b';
    a[2][6] = a[3][6] = a[6][2] = a[6][3] = 'c';
    a[4][6] = a[5][6] = a[6][4] = a[6][5] = 'd';
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) s[i] += '.';
    if (n == 2) {cout << -1; return 0;}
    else if (n == 3) {cout << "a..\na..\n.aa\n"; return 0;}
    else if (n == 5) {cout << "aabbc\nhi..c\nhi..d\ng.jjd\ngffee\n"; return 0;}
    else if (n % 4 == 0) {
        for (int i = 0; i < n; i += 4) {
            for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k++) s[i + j][i + k] = b[j][k];
        }
    } else if (n % 4 == 1) {
        for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) s[i][j] = a3[i][j];
        for (int i = 9; i < n; i += 4) {
            for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k++) s[i + j][i + k] = b[j][k];
        }
    } else if (n % 4 == 2) {
        for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) s[i][j] = a2[i][j];
        for (int i = 6; i < n; i += 4) {
            for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k++) s[i + j][i + k] = b[j][k];
        }
    } else {
        for (int i = 0; i < 7; i++) for (int j = 0; j < 7; j++) s[i][j] = a[i][j];
        for (int i = 7; i < n; i += 4) {
            for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k++) s[i + j][i + k] = b[j][k];
        }
    }
    for (int i = 0; i < n; i++) cout << s[i] << '\n';
}


Measured memory_bytes: 2304
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main() {
	int a[4], n, r;
	cin >> n;
	a[0] = n / 1000, a[1] = n / 100 % 10;
	a[2] = n / 10 % 10, a[3] = n % 10;
	rep(i, 0, 1 << 3) {
		r = a[0];
		rep(i2, 0, 3) {
			if (i >> i2 & 1)r += a[i2 + 1];
			else r -= a[i2 + 1];
		}
		if (r == 7) {
			printf("%d", a[0]);
			rep(i2, 0, 3) {
				printf((i >> i2 & 1) ? "+%d" : "-%d", a[i2 + 1]);
			}
			puts("=7");
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256