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

int main() {
    long x, y, A, B, C;
    cin >> x >> y >> A >> B >> C;
    vector<long> a(A);
    vector<long> b(B);
    vector<long> c(C);
    for (int i = 0; i < A; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < B; i++) {
        cin >> b.at(i);
    }
    for (int i = 0; i < C; i++) {
        cin >> c.at(i);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    

  for(long i=0;i<A-x;i++){
    a.pop_back();
  }
  for(long i=0;i<B-y;i++){
    b.pop_back();
  }
  
  for(long i=0;i<x;i++){
    c.push_back(a.at(i));
  }
  for(long i=0;i<y;i++){
    c.push_back(b.at(i));
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  
    long total = 0;
    
    for (int i = 0; i < x+y; i++) {
        total += c.at(i);
    }
    
    

    cout << total << endl;
}


Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		
	}
	int max=arr[0];
	int count=1;
	for(int i=1;i<n;i++)
	{
		if(max>arr[i])
		{
			count++;
			max=arr[i];
		}
	}

	
	cout<<count<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll powmod(ll n,ll p,ll mod){
    ll res=1;
    while(p){
        if(p%2==1) res = (res*n)%mod;
        n = (n*n)%mod;
        p /= 2;
    }
    return res;
}

ll modinv(ll n,ll mod){
    return powmod(n,mod-2,mod);
}

ll factrial_mod(ll n,ll k,ll mod){
    ll x = 1,y = 1;
    rep(i,k){
        x = (x * (n - i)) % mod;
        y = (y * (i + 1)) % mod;
    }
    return x*modinv(y,mod)%mod;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    ll ans = powmod(2,n,MOD) - 1;
    ans = ((ans - factrial_mod(n,a,MOD)) % MOD + MOD) % MOD;
    ans = ((ans - factrial_mod(n,b,MOD)) % MOD + MOD) % MOD;
    cout << ans << endl;
}

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

int N;
vector<int> l;

int main() {
  cin >> N;
  for (int i = 0; i < 2 * N; ++i) {
    int t;
    cin >> t;
    l.push_back(t);
  }
  sort(l.begin(), l.end());
  int s = 0;
  for (int i = 0; i < 2 * N; i += 2) {
    s += l[i];
  }
  cout << s << endl;
  return 0;
}


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

// #define ll long long
// using namespace std;
// int main(){
// 	ll n,a,i,j,k,b,l,sum,cnt=0,cnt1=0,value;
// 	cin>>n>>a>>b;
// 	sum=a+b;
// 	value=n-sum;
// 	string s,s1;
// 	for( i=0;i<a;i++){
// 	 	s[i]='b';
//      }
// 	for( k=0;k<b;k++){
// 		s1[k]='r';
// 	}
// 	for( j=a;j<b;j++){
// 		s[i]=s1[j];
// 		i++;
// 	}
// 	for(l=0;l<sum;l++){

// 		if(s[l]=='b' ||s[l]=='B' ){
// 			cnt++;
// 		}else if(s[l]=='r'||s[l]=='R'){
// 			cnt1++;
// 		}
// 	}
// 	cout<<cnt+value<<endl;
// 	cnt=0;
// 	return 0;
// }


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll ab=a+b;
  ll k=n/ab*a;
  ll m=min(a,n%ab);
  cout <<k+m<<endl;
  return 0;
}

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

template <class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template <class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 100000 + 5;

int a[MAXN], x[MAXN], y[MAXN];

int main() {
  int n;
  scanf("%d", &n);
  For(i, 1, n) {
    scanf("%d", &a[i]);
  }
  For(i, 1, n >> 1) {
    x[i] = a[i << 1];
  }
  std::sort(x + 1, x + (n >> 1) + 1);
  std::sort(a + 1, a + n + 1);
  For(i, 1, n >> 1) {
    y[i] = a[i << 1];
  }
  int answer = n >> 1;
  for (int p = 1, q = 1; p <= n >> 1 && q <= n >> 1; ) {
    if (x[p] == y[q]) {
      ++ p, ++ q;
      -- answer;
    } else if (x[p] < y[q]) {
      ++ p;
    } else {
      ++ q;
    }
  }
  printf("%d\n", answer);
  return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<i64> A(N + 1);
    REP(i, N) cin >> A[i];
    A[N] = 0;
    vector<i64> inc(N, false);
    REP(i, N) {
        if (A[i] <= A[i + 1]) inc[i] = true;
    }

    i64 money = 1000;
    i64 s = -1;
    REP(i, N) {
        if (s == -1 && inc[i]) s = i;

        if (s != -1 && !inc[i]) {
            i64 nbuy = money / A[s];
            money -= A[s] * nbuy;
            money += A[i] * nbuy;
            s = -1;
        }
    }
    cout << money << endl;

    return 0;
}


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

using namespace std;

struct Knapsack {
    int weight, value;
    Knapsack () : weight(-1) , value(-1) {}
    Knapsack (int w, int v) : weight(w), value(v) {}
};

long long getMaxValue (vector <Knapsack> &knapsack, int capacity) {
    if (knapsack.empty()) {
        return 0;
    }
    int n = knapsack.size();
    vector <long long> dp(capacity + 1);
    
    for (int i = 0; i < n; ++i) {
        int currWeight = knapsack[i].weight;
        int currValue = knapsack[i].value;
        for (int c = capacity; c >= currWeight; --c) {
            dp[c] = max(dp[c], dp[c - currWeight] + (long long)currValue);
        }
    }
    long long result = 0;
    for (long long v : dp) {
        result = max(result, v);
    }
    return result;
}

int  main () {
    int n = 0, capacity = 0;
    scanf("%d%d", &n, &capacity);
    vector <Knapsack> knapsack;
    for (int i = 0; i < n; ++i) {
        int w, v;
        scanf("%d%d", &w, &v);
        knapsack.emplace_back(Knapsack{w, v});
    }
    printf("%llu\n", getMaxValue(knapsack, capacity));
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS 1e-8
#define EQ(a,b) (abs((a)-(b)) < EPS)
using namespace std;

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

double calc_dis (int x, int y )
{
	return sqrt ((double)x*x + (double)y*y );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.EC", "r", stdin );
	int n;
	scanf ("%d", &n );
	int cnt = 0;
	while (cnt < n ){
		int x = 0, y = 0;
		set<P> pos; pos.clear();
		while (true ){
			int dx, dy;
			scanf ("%d %d", &dx, &dy );
			x += dx, y += dy;
			if (dx == 0 && dy == 0 ) break;
			pos.insert (P (x, y ) );
		} // end while
		P res;
		double maxd = 0.0;
//		rep (i, pos.size() ){
		set<P>::iterator it = pos.begin();
		for (; it != pos.end(); it++ ){
			int cx = (*it).first;
			int cy = (*it).second;
			double curr = calc_dis (cx, cy );
			if (maxd < curr ){
//				res = pos[i];
				res = (*it);
				maxd = curr;
			}else
			if (EQ (maxd, curr ) && cx > res.first ){
//				res = pos[i];
				res = (*it);
			} // end if
		} // end rep
		printf ("%d %d\n", res.first, res.second );
		cnt++;
	} // end while

	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int x;
	cin >> x;
	cout << x / 500 * 1000 + x % 500 / 5 * 5;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
Lmat = [int(n) for n in input().split()]
Lmat.sort()

sum = 0
for i in range(N):
    for j in range(i+1,N):
        sum+= bisect_left(Lmat, Lmat[i]+Lmat[j]) - j - 1
print(sum)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};



int main(){
  intl X;
  cin >> X;
  for (intl i = -150; i < 150 ; i++){
    for (intl j = -150 ; j < 150 ; j++){
      if ( i*i*i*i*i - j*j*j*j*j == X ){
        cout << i <<" "<< j;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
#include<math.h> 
#include<stdlib.h>
#include<map>
#include<set>
#include<time.h>
#include<bitset>
#include<list>
const int inf=2e9;
const int md=1e9+7;
using namespace std;
long long a[26];
long long ans;
string s;
int main(){
	cin>>s;
	long long n=s.size(); 
	ans=n*(n-1)/2+1;
	for (int i=0;i<(int)n;i++)
	a[s[i]-'a']++;
	for (int i=0;i<26;i++)
	ans-=a[i]*(a[i]-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
int x ;
cin >> x ;
cout << x*x*x <<endl ;

  return 0 ;
}



Measured memory_bytes: 3072
x=str(input())
S1=x.count("K")
S2=x.count("U")
S3=x.count("P")
S4=x.count("C")
b=min(S1,S2,S3,S4)
if S1==0 or S2==0 or S3==0 or S4==0:
    b=0
print(b)


Measured memory_bytes: 5556
// ABC143_D
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset 初期化
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    vector<ll> vec(N);
    REP(i, N) cin >> vec[i];
    
    // calculation
    sort(vec.begin(), vec.end());
    
    ll sum = 0, idx;
    for (ll i = 0; i < N-2; ++i) {
        for (ll j = i+1; j < N-1; ++j) {
            ll two = vec[i] + vec[j];
            auto iter = lower_bound(vec.begin()+j+1, vec.end(), two);
            if (iter == vec.end()) sum += N - j -1;
            else {
                ll idx = distance(vec.begin(), iter);
                sum += (idx-1) - j;
            }
        }
    }
    
    cout << sum << "\n";
    
    return 0;
}

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

int main(){
	int n,k,i,j,l;
	int a[100000];
	int Smax,S;
	while(l<5){
		cin>>n;
		cin>>k;
		if(n==0){break;}
		
		for(i=0;i<n;i++){
			cin>>a[i];
		}
		for(i=0;i<n-k;i++){
			S=0;
			for(j=i;j<i+k;j++){
				S+=a[j];
			}
			if(Smax<S){Smax=S;}
		}
		
		cout<<Smax<<endl;
		
		l++;
	}
		return 0;
		
}


Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();

  if(n<m){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  for(int i=n-1;i>=0;i--){
    if(i+m-1>=n) continue;
    string ss=s.substr(i,m);
    bool ok=true;
    rep(j,m){
      if(ss[j]!='?' && ss[j]!=t[j]) ok=false;
    }
    if(ok){
      rep(j,m){
        s[i+j]=t[j];
      }
      rep(j,n){
        if(s[j]=='?') cout << "a";
        else cout << s[j];
      }
      cout << endl;
      return 0;
    }
  }

  cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll x, K;

// x > K なら x = x-K
// x == K なら答えは 0
// x < K なら x が K 以上になることはもうなく，x = K-x
// K-(K-x) = x となり無限ループ 

signed main(){
    cin >> x >> K;
    if(x > K) x = x%K;
    cout << min(x, K-x) << endl;
}

Measured memory_bytes: 256
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1}
};

#[fastout]
fn main() {
   input! {
      s: Chars,
      t: Chars,
   }
   let n = s.len();
   for i in 0..n{
      if s[i] != t[i] {
         println!("No");
         return;
      }
   }
   println!("Yes");
}


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

#define int long long int
#define ps push_back
#define mod 1000000007
#define fi first
#define so second
#define pii pair<int,int>
#define TT int tt;cin>>tt;for(int cc=1;cc<=tt;cc++)

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}

signed main()
{
    int i,n,k;
    cin>>n>>k;
    int ncr[n+1];
    ncr[0]=1;
    int sum=0;
    for(i=k;i<=n+1;i++)
    {
        //cout<<i<<"-"<<endl;
        int a = ((n-i+1)*i)%mod;
        a = (a+1)%mod;
        //cout<<a<<"\n";
        sum = (sum + a)%mod;
    }
    cout<<sum;
}


Measured memory_bytes: 3636
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
A = III()
B = III()

from bisect import bisect_left

#インデックス付きソート
#(index,value)の順に格納
def index_sort(A):
    a = []
    for i,x in enumerate(A):
        a.append([i,x])
    return sorted(a,key=lambda x: x[1])

A2 = sorted(A)
B2 = sorted(B)

for i in range(N):
    if A2[i]>B2[i]:
        print('No')
        exit()

for i in range(N-1):
    if B2[i]>=A2[i+1]:
        print('Yes')
        exit()

A3 = index_sort(A)
B3 = index_sort(B)

for i in range(2,N)[::-1]:
    bindex = B3[i][0]
    aindex = A3[i][0]
    if aindex==bindex:
        print('Yes')
        exit()
    p1 = bisect_left(A2,A[bindex])
    A[aindex],A[bindex] = A[bindex],A[aindex]
    A3[i][0],A3[p1][0] = A3[p1][0],A3[i][0]

for i in range(N):
    if A[i]>B[i]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 96544
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll P[N+1],A[N+1],B[N+1];
  RREP(i,N){
    ll a;
    cin>>a;
    P[a]=i;
  }
  RREP(i,N) A[i]=30000*i;
  RREP(i,N) B[i]=30000*(N-i)+P[i];
  
  RREP(i,N){
    if(i<N) cout<<A[i]<<" ";
    else cout<<A[i]<<endl;
  }
  RREP(i,N){
    if(i<N) cout<<B[i]<<" ";
    else cout<<B[i]<<endl;
  }
  return 0;
}

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

int main(){
	const ll INF = 1e9 + 5;
	ll N; cin >> N;
        vector<vector<ll>> choices(N, vector<ll>(3));
        for(ll rep = 0; rep < N; ++rep){
            cin >> choices[rep][0];
            cin >> choices[rep][1];
            cin >> choices[rep][2];
        }
        vector<vector<ll>> maxGain(N, vector<ll>(3, -INF));
        maxGain[0][0] = choices[0][0];
        maxGain[0][1] = choices[0][1];
        maxGain[0][2] = choices[0][2];
        for(ll day = 1; day < N; ++day){
            for(ll choice = 0; choice < 3; ++choice){
                for(ll pChoice = 0; pChoice < 3; ++pChoice){
                    if(choice == pChoice) continue;
                    maxGain[day][choice] = max(maxGain[day][choice],
                    		      maxGain[day - 1][pChoice] + choices[day][choice]);
                }
            }
        }
        cout << max({maxGain[N - 1][0], maxGain[N - 1][1], maxGain[N - 1][2]}) << endl;
    	return 0;
}

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

int main(){
  int a[3];
  int count5 = 0;
  int count7 = 0;
  
  cin >> a[0] >> a[1] >> a[2];
  for(int i=0; i<3; i++){
    if(a[i]==5){
      count5++;
    }else if(a[i]==7){
      count7++;
    }
  }
  if(count5==2 && count7==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;      
  }
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n, k; cin >> n >> k;
   int a[n];
   for(int i = 0; i < n; i++)
      cin >> a[i];
   int sum = 0;
   for(int i = 0; i < n; i++)
   {
      int tmp = min(a[i], abs(k-a[i]));
      sum+= tmp;
   }
   cout << sum*2 << nl;

   return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, T;
    std::cin >> N >> T;

    std::vector<int> A(N);
    REP(i, N) {
        std::cin >> A[i];
    }

    int max_a    = 0;
    int max_diff = 0;
    int ans      = 0;
    for(int i = N - 1; i >= 0; i--) {
        if(max_a < A[i]) {
            max_a = A[i];
        }
        else {
            auto diff = max_a - A[i];
            if(diff == max_diff) {
                ans++;
            }
            else if(max_diff < diff) {
                ans      = 1;
                max_diff = diff;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 640
/*
https://drken1215.hatenablog.com/entry/2020/03/02/022900
https://linuxnosusume.blogspot.com/2017/12/union-find.html
勉強させていただいた記事
*/

#include <bits/stdc++.h>

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

struct UnionFind{
vi par;
UnionFind(int N) : par(N,-1){}

int root (int x){
   if(par[x]<0)return x;
   return par[x]=root(par[x]);
}

void unite(int x,int y){
   x=root(x);
   y=root(y);
if(x==y)return;
if(par[x]>par[y])swap(x,y);
par[x]+=par[y];
par[y]=x;
}

bool same(int x,int y){
return root(x)==root(y);
}

int size(int x){
   return -par[root(x)];
}
};

int main(){
   int N,M,K;
   cin>>N>>M>>K;
   vector<set<int>>dame(N);

   UnionFind tree(N);
   rep(i,M){
      int a,b;
      cin>>a>>b;
      a--,b--;
      dame[a].insert(b);
      dame[b].insert(a);
      tree.unite(a,b);
   }
   rep(i,K){
      int a,b;
      cin>>a>>b;
      a--,b--;
      if(!tree.same(a,b))continue;
      dame[a].insert(b);
      dame[b].insert(a);
   }

   //言葉で説明されると直感的に理解しやすい問題だった
   //ただ、UF木の理解が追いついていない

   rep(i,N){
      int mem=tree.size(i)-1;
      mem-=dame[i].size();
      cout<<mem<<" ";
   }
   cout<<endl;
   return 0;
}

//a=97,z=122

Measured memory_bytes: 24704
function Main(input) {
  var s = input.split(" ");
  var h = parseInt(s[0],10);
  var w = parseInt(s[1], 10);
  var r = h * w;
 
  if(h === 1 || w === 1){
    console.log("1");
    return;
  }
  
  // 偶数
  if(r % 2 === 0) {
    console.log(r/2);
  } else {
    // 奇数
    var a = r/2;
    console.log(Math.ceil(a));
  }
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 3005;
const lli inf = 1e18;

int n, m, k;
int a[maxn][maxn];

lli dp[maxn][maxn][5];

void read_input()
{
    cin >> n >> m >> k;
    fill_n(&a[0][0], sizeof(a) / sizeof(a[0][0]), 0);
    for(; k > 0; --k)
    {
        int x, y, v;
        cin >> x >> y >> v;
        a[x][y] = v;
    }
}

void solve()
{
    fill_n(&dp[0][0][0], sizeof(dp) / sizeof(dp[0][0][0]), -inf);
    dp[1][1][0] = 0;
    if(a[1][1] > 0) dp[1][1][1] = a[1][1];
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            for(int k = 0; k < 4; ++k)
            {
                if((i == n && j == m) || dp[i][j][k] == -inf) continue;
                if(j < m)
                {
                    dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                    if(k < 3 && a[i][j + 1] > 0)
                        dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + a[i][j + 1]);
                }
                if(i < n)
                {
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                    if(a[i + 1][j] > 0)
                        dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + a[i + 1][j]);
                }
            }
    lli ans = -inf;
    for(int k = 0; k < 4; ++k)
        ans = max(ans, dp[n][m][k]);
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 391600
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
string A, B, C;

void solve(){
	if(*A.rbegin() == B[0] and *B.rbegin() == C[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> A >> B >> C;
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, cnt = 0, ans = 0;
  char s[200010];
  scanf("%s", s);
  for(i = 0; s[i]; ++i) {
    if(s[i] == 'A') cnt++;
    else if(s[i] == 'B' && s[i + 1] == 'C') ans += cnt, ++i;
    else cnt = 0;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a[50],b[50],n;
  cin>>n;
    double c=0,d=0;
    r(i,n){
      cin>>a[i]>>b[i];
      c+=a[i],d+=b[i];
    }
    c/=n,d/=n;
    if(n%2)goto L;
    r(i,n/2)if(!abs((a[i]+a[(i+n/2)%n])/2.0-c)<0.0001||!abs((b[i]+b[(i+n/2)%n])/2.0-d)<0.0001)goto L;
    printf("%.11f %.11f\n",c,d);
    if(0)L:cout<<"NA"<<endl;
}

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

int main(){
    int a,b;
    cin >> a >>b;
    if(a == b){
        cout << a*2 <<endl;
    }
    else{
        int botton = max(a,b);
        int result = botton*2 - 1;
        cout << result <<endl;     
    }
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    string t = "ATCG";
    int ans = 0;
    int now = 0;
    
    for (int i = 0; i < s.size(); i++) {
        bool isATCG = false;
        
        for (int j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) {
                isATCG = true;
            }
        }
        if (!isATCG) {
            now = 0;
            
        } else {
            now++;
            ans = max(now, ans);
        }
    }
    
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("AC");
    } else {
        println!("WA");
    }
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let slen = s.len();
    let mut ans = false;
    let mut c_count = 0;
    for i in 0..slen {
        if i == 0 {
            if s[i] != 'A' {
                break;
            }
        } else if i >= 2 && i <= slen - 2 && s[i] == 'C' {
                c_count += 1;
        } else if s[i] < 'a' || 'z' < s[i] {
            yn(false);
            return;
        }
    }
    if c_count == 1 {
        ans = true;
    }
    yn(ans);
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  vector<int> e(n), o(n);
  int maxn = 1000001;
  int ev[maxn] = {0}, od[maxn] = {0};
  for(int i = 1; i <= n; i++) {
    if(i%2==0) {
      cin >> e[i/2];
      ev[e[i/2]]++;
    }
    if(i%2==1){
      cin >> o[i/2];
      od[o[i/2]]++;
    }
  }
  int maxEv = 0;
  int secEv = 0;
  int maxEvN = 0;
  int maxOd = 0;
  int secOd = 0;
  int maxOdN = 0;
  for(int i = 1; i < maxn; i++) {
    if(ev[i] >= maxEv) {
      secEv = maxEv;
      maxEv = ev[i];
      maxEvN = i;
    } else if(ev[i] >= secEv) {
      secEv = ev[i];
    }
    if(od[i] >= maxOd) {
      secOd = maxOd;
      maxOd = od[i];
      maxOdN = i;
    } else if(od[i] >= secOd) {
      secOd = od[i];
    }
  }
  if(maxEvN == maxOdN) {
    cout << min((n-maxOd-secEv), (n-secOd-maxEv)) << endl;
  } else {
    cout << n - maxEv - maxOd << endl;
  }

  return 0;
}


Measured memory_bytes: 8960
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

type food struct {
	a, b int
}
type foods []food

func (p foods) Len() int {
	return len(p)
}

func (p foods) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p foods) Less(i, j int) bool {
	return p[i].a+p[i].b > p[j].a+p[j].b
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	A := make(foods, N)
	for i := 0; i < N; i++ {
		a, b := getInt(), getInt()
		A[i] = food{a, b}
	}
	sort.Sort(A)
	ans := 0

	for i := 0; i < N; i++ {
		if i%2 == 0 {
			ans += A[i].a
		} else {
			ans -= A[i].b
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 4736
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 1e-11
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif
#ifdef _DEBUG
#include "Union_Find.h"
#include "Graph.h"
#endif

int N, Ma, Mb;
int A[40], B[40], C[40];
int DP[401][401];

int main() {
	cin >> N >> Ma >> Mb;
	REP(i, 0, N) {
		cin >> A[i] >> B[i] >> C[i];
	}

	Fill(DP, INF);
	DP[0][0] = 0;
	REP(k, 0, N) {
		REPM(i, 401, 1) {
			REPM(j, 401, 1) {
				if (i - A[k] < 0 || j - B[k] < 0) continue;
				DP[i][j] = min(DP[i][j], DP[i - A[k]][j - B[k]] + C[k]);
			}
		}
	}
	int ans = INF;
	for (int i = Ma, j = Mb; i <= 400 && j <= 400; i += Ma, j += Mb) {
		ans = min(ans, DP[i][j]);
	}
	cout << (ans == INF ? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <stack>

using namespace std;

#define LEN 6

int main(){
  int res;
  string N;

  cin >> N;
  if(N[2]== N[3] && N[4]==N[5]){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
  
  return 0;

}


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

const int N=2010;
int n,k,f[N][N];

int Pow(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%ha)
		if(b&1) ans=1ll*ans*a%ha;
	return ans;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=2;i<=n;i++) f[1][i]=1;
	for(int i=1;i<k-1;i++)
	{
		f[i+1][n-i+1]=f[i][n-i+1];
		for(int j=n-i;j>=2;j--)
			f[i+1][j]=(f[i+1][j+1]+f[i][j])%ha;
	}
	int ans=0;
	for(int i=2;i<=n-k+2;i++)
		ans=(ans+f[k-1][i])%ha;
	if(k==1) ans=1;
	if(n-k<=0) printf("%d",ans);
	else printf("%d",1ll*ans*Pow(2,n-1-k)%ha);
	return 0;
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main()
{
    ll N;
    cin >> N;
    bool ans = false;
    while(N)
    {
        ll num = N % 10;
        if(num == 7)
        {
            ans =true;
            break;
        }
        N /= 10;
    }
    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int calc(int n, int c, int d)
{
    int lcm = c * d / __gcd(c, d);
    return n - n / c - n / d + n / lcm;
}
main() {
    int a = readInt();
    int b = readInt();
    int c = readInt();
    int d = readInt();
    cout << calc(b, c, d) - calc(a - 1, c, d);
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
Blis = [int(x) for x in input().split()]
k = 0
for i in range(N):
  Alis = [int(x) for x in input().split()]
  total = 0
  for j in range(M):
    total = total + (Alis[j])*(Blis[j])
  total = total + C
  if total > 0:
    k = k + 1
print(k) 

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

int main(){
    int h,r;
    cin >> h >> r;
    if(h+r>0) cout << 1 << endl;
    if(h+r==0) cout << 0 << endl;
    if(h+r<0) cout << -1 << endl;
    return 0;
}

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

using namespace std;

#define ll long long

ll M = 1000000007;

ll bin_pow(ll a, ll pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        ll tmp = bin_pow(a, pow / 2) % M;
        return tmp * tmp % M;
    }
    return a * bin_pow(a, pow - 1) % M;
}

ll inv(ll a) {
    return bin_pow(a, M - 2) % M;
}

ll fact(ll a) {
    ll ans = 1;
    for (int i = 1; i <= a; i++) {
        ans *= i;
        ans %= M;
    }
    return ans;
}

vector<vector<int>> d;
vector<pair<int, int>> a;

int ans(int n, int t) {
    if (t <= 0 || n == 0) return 0;
    if (d[n][t] == -1) {
        d[n][t] = max(ans(n - 1, t), ans(n - 1, t - a[n - 1].first) + a[n - 1].second);
    }

    return d[n][t];
}

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

    int a, b;
    cin >> a >> b;

    cout << (a - 2 * b > 0 ? a - 2 * b : 0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,m,r,far[200][200];
int main(void){
    cin>>n>>m>>r;
    vector<int>v;
    for(int i=0;i<r;i++){
        int a;
        cin>>a;
        v.push_back(a-1);
    }
    sort(v.begin(),v.end());
    for (int i=0; i<n; i++)for (int j=0; j<n; j++)if(i!=j)far[i][j] = 1000000000;
    for (int i=0; i<m; i++) {
        int a,b,c;
        cin>>a>>b>>c;
        far[a-1][b-1]=far[b-1][a-1]=c;
    }
    for (int i=0; i<n; i++)for (int j=0; j<n; j++)for (int k=0; k<n; k++)far[j][k] = min(far[j][k],far[j][i]+far[i][k]);
    int ans=2000000001;
    do{
        int sum=0;
        for(int i=1;i<r;i++){
            sum+=far[v[i-1]][v[i]];
        }
        ans=min(sum,ans);
    }while (next_permutation(v.begin(), v.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int64_t> vs(3 * n);
    for (auto& v : vs)
    {
        cin >> v;
    }
    sort(vs.begin(), vs.end());

    int64_t ans = 0;
    for (int i = n; i < 3 * n; i += 2)
    {
        ans += vs[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    if((n + m) % 2)cout << "IMPOSSIBLE" << endl;
    else cout << (n + m) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
minabs=10**9+1
minus=0
allsum=0
for i in a:
  if i<0:
    minus+=1
  minabs=min(minabs,abs(i))
  allsum+=abs(i)

if minus%2==1:
  allsum-=minabs*2
print(allsum)

Measured memory_bytes: 14252
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> q[i];
  }
  vector<int> order(n);
  for (int i = 0; i < n; ++i) {
    order[i] = i + 1;
  }
  int a = 0, b = 0;
  int cnt = 1;
  do {
    if (order == p) a = cnt;
    if (order == q) b = cnt;
    cnt++;
  } while (next_permutation(order.begin(), order.end()));
  cout << abs(a - b) << endl;
  return 0;
}

Measured memory_bytes: 256
s=input()
b=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=='L':
            b+=1
            break
    if i%2==1:
        if s[i]=='R':
            b+=1
            break
if b==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,k,m,n,t;
	cin>>n>>k;
	ll ar[n];
	for(i=0;i<n;i++)
	cin>>ar[i];
	sort(ar,ar+n);
	ll s=0;
	for(i=0;i<k;i++)
	s+=ar[i];
	cout<<s;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	ll A=readll(),B=readll(),C=readll(),k=readll();
	printf("%lld\n",(A-B)*((k&1)?-1:1));
	return 0;
}


Measured memory_bytes: 764
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto rr = readln.split.to!(double[]);
    auto r1 = rr[0];
    auto r2 = rr[1];
    writefln("%.010f", r1 * r2 / (r1 + r2));
}

Measured memory_bytes: 256