akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    /* input */
    int N, M;  cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    rep(i, M) {
        int _k;  cin >> _k;
        k[i] = _k;
        rep(j, _k) {
            int _s;  cin >> _s;
            s[i].push_back(_s);
        }
    }
    vector<int> p(M);
    rep(i, M) cin >> p[i];

    int ans = 0;  // 全点灯のパターン数
    // スイッチONの部分集合の全探索
    for (int bit = 0; bit < (1<<N); ++bit) {
        /* bit で表される集合の処理 */
        // 電球が少なくとも一個つかない場合を判定
        bool flag = true;
        // 各電球について
        rep(i, M) {
            int cnt = 0;  // ONのスイッチ数
            // 各スイッチについて
            rep(j, k[i]) {
                // スイッチがONになっていれば
                if (bit & (1<<(s[i][j]-1))) {
                    cnt++;
                }
            }
            if (cnt % 2 != p[i]) flag = false;
        }
        if (flag) ans++;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [ list(map(int, input().split())) for _ in range(m) ]
A = { i[1] for i in ab if i[0]==1 }
B = { i[0] for i in ab if i[1]==n }
if A&B != set():
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N), b(N);
    rep(i, 0, N) cin >> a[i];
    rep(i, 0, N) cin >> b[i];
    ll ca = 0, cb = 0;
    rep(i, 0, N){
        if(a[i] > b[i]) ca += a[i] - b[i];
        if(a[i] < b[i]) cb += (b[i] - a[i]) / 2;
    }
    if(ca <= cb) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
/*
 * main.cpp
 *
 *  Created on: 2020/03/06
 *      Author: seal0
 */
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main(int argc, char* argv[])
{
	int K;
	scanf("%d", &K);
	string str = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
	string separate =", ";
	int numbers[32];

	int find ;
	int pos=0;
	int length_of_str = (int) str.length();

	for (int i=0; i<32; i++){
		find = (int) str.find(separate, pos);
		string substr =str.substr(pos, find-pos);
		pos = find+2;
//		printf("n=%s\n", substr.c_str());
		numbers[i] = stoi(substr);
	}
	printf("%d", numbers[K-1]);
	return 0;
}





Measured memory_bytes: 256
N,M = map(int,input().split())

St = [list(map(int,input().split()))for _ in range(N)]
Pt = [list(map(int,input().split()))for _ in range(M)]

for a,b in St:
    dis = [abs(a-c)+abs(b-d)for c,d in Pt]
    print(dis.index(min(dis))+1)


Measured memory_bytes: 9032
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
// DSU
/*
const int maxn=100009;
int arr[maxn];
int sz[maxn];
void init(){rep(i,maxn){arr[i]=i;sz[i]=1;}}
int root(int a){while(a!=arr[a]){arr[a]=arr[arr[a]];a=arr[a];}return a;}
int check(int a,int b){if(root(a)==root(b))return 1;return 0;}
int un(int a,int b)
{
  int roota=root(a);int rootb=root(b);
  if(sz[roota]>=sz[rootb]){sz[roota]+=sz[rootb];arr[rootb]=roota;}
  else {sz[rootb]+=sz[roota];arr[roota]=rootb;}
}
*/
int32_t main()
{
   fastio
   int n;
   cin>>n;
   int arr1[n],arr2[n];
   rep(i,n)
   {
     cin>>arr1[i];
     arr2[i]=arr1[i];
   }
   sort(arr2,arr2+n);
   int ans=0;
   for(int i=0;i<n;i++)
   {
     if(arr1[i]!=arr2[i])ans++;
   }
   if(ans==2 || ans==0)cout<<"YES\n";
   else cout<<"NO\n";

   return 0;
}


Measured memory_bytes: 256
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	int d,t,s;
	cin >> d >> t >> s;
	if((double)d / s <= (double)t)
	{
		cout << "Yes";
	}else{
		cout << "No";
	}
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 45;
int n;
int A[N][N];
ll f[N][N][N] , g[N][N][N];
int main()
{
	n = read() << 1; ll ans = 0;
	for(int i = 1;i <= n;i ++) for(int j = 1;j <= n;j ++) scanf("%1d",&A[i][j]);
	for(int i = 1;i <= n;i ++)
	{
		f[i][i][i] = 1;
		for(int j = i + 1;j < n;j ++) g[i][i][j] = A[j][i];
	}
	for(int len = 3;len <= n;len += 2) for(int i = 1 , j;i <= n - len;i ++)
	{
		j = i + len - 1;
		for(int p = i;p < j;p += 2) for(int q = j;q > p;q -= 2)
		{
			ll sum = 0;
			for(int k = q;k <= j;k ++) sum += f[q][j][k] * g[i][p][k];
			for(int k = p + 1;k < q;k ++) f[i][j][k] += sum * f[p + 1][q - 1][k];
		}
		for(int w = i;w <= j;w ++) for(int k = j + 1;k < n;k ++) g[i][j][k] += f[i][j][w] * A[w][k];
	}
	for(int i = 1;i < n;i ++) ans += f[1][n - 1][i] * A[n][i];
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
int bgrid[2002][2002];
int wgrid[2002][2002];

int main() {
    int n, m, i, j, k;
    cin >> n >> k;
    vector<pair<pair<ll, ll>, ll>> v(n);
    for(i = 0; i < n; i++) {
        char c;
        cin >> v[i].first.first >> v[i].first.second >> c;
        if(c == 'W')
            v[i].second = 1;
        else
            v[i].second = 0;
        v[i].first.first %= 2 * k;
        v[i].first.second %= 2 * k;
        // 縦横に2*k動かしても色は変わらない
    }
    for(i = 0; i < 2 * k + 2; i++) {
        for(j = 0; j < 2 * k + 2; j++) {
            bgrid[i][j] = 0;
            wgrid[i][j] = 0;
        }
    }
    int bsum = 0;
    for(i = 0; i < n; i++) {
        if(((v[i].first.first / k) + (v[i].first.second / k)) % 2 == 0) {
            if(v[i].second == 1) {
                wgrid[v[i].first.first % k][v[i].first.second % k]++;
            } else {
                wgrid[v[i].first.first % k][v[i].first.second % k]--;
                ++bsum;
            }
        } else {
            if(v[i].second == 1) {
                wgrid[v[i].first.first % k][v[i].first.second % k]--;
                bsum++;
            } else {
                wgrid[v[i].first.first % k][v[i].first.second % k]++;
            }
        }
    }
    for(i = 0; i < k; i++) {
        for(j = 1; j < k; j++) {
            bgrid[i][j] += bgrid[i][j - 1];
            wgrid[i][j] += wgrid[i][j - 1];
        }
    }
    for(i = 0; i < k; i++) {
        for(j = 1; j < k; j++) {
            wgrid[j][i] += wgrid[j - 1][i];
            bgrid[j][i] += bgrid[j - 1][i];
        }
    }
    int ret = 0;
    for(i = 0; i < k; i++) {
        for(j = 0; j < k; j++) {
            int ok = wgrid[k - 1][k - 1] - wgrid[k - 1][j] - wgrid[i][k - 1] + 2 * wgrid[i][j] + bsum;
            ret = max({ret, ok,n-ok});
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 33920
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	string s;
	cin >> s;
	f(i, s.size()) {
		if ((i % 2 && s[i] != 'i') || (i % 2 == 0 && s[i] != 'h') || s.size() % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>
#include <stack>
#include <cstring>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

const int maxn = 100001;
int cnt[maxn];

void solve() {
  memset(cnt, 0, sizeof(cnt));
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    cnt[a]++;
    cnt[b]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (cnt[i] % 2 != 0) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
  return;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 640
N,M = map(int,input().split())

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

A.sort(key=lambda x: x[0])

cnt = 0
fee = 0
flg=0
for j in A:
    for k in range(j[1]):
        cnt += 1
        fee += j[0]
        if cnt == M:
            print(fee)
            flg=1
            break
    
    if flg==1:
        break

Measured memory_bytes: 29020
xin = input().split()
X, N = list(map(int, xin))


xin = input().split()
p = list(map(int, xin))

if (N == 0):
	print(X)
	exit()


dist_min=N
min_value=X

#p2 = range(X+N,X-N,-1)


for i in range(X+N,X-N-1,-1):
	flag=False
	for j in range(N):
		if(i==p[j]):
			flag=True
	if( flag == True):
		continue
	
	
	dist = abs(X-i)
	
	if ( dist==dist_min ):
		if(i<min_value):
			min_value = i
	elif ( dist < dist_min):
		dist_min = dist
		min_value = i

print(min_value)


Measured memory_bytes: 9156
using System;
class main{
    static void Main(string[] args){
        string[] line = Console.ReadLine().Split(' ');
        int[] numbers = new int[6];
        for(int i = 0;i<6;i++){
            numbers[i] = int.Parse(line[i]);
        }
        dice dice = new dice();
        dice.setNumbers(numbers);

        char[] orders = Console.ReadLine().ToCharArray();
        for (int i = 0, count = orders.Length; i < count; i++) {
            if (orders[i] == 'S')
            {
                numbers[0] = dice.T;
                numbers[1] = dice.S;
                numbers[2] = dice.B;
                numbers[3] = dice.N;
                dice.T = numbers[3];
                dice.S = numbers[0];
                dice.B = numbers[1];
                dice.N = numbers[2];                
            }
            else if (orders[i] == 'E') 
            {
                numbers[0] = dice.T;
                numbers[1] = dice.E;
                numbers[2] = dice.B;
                numbers[3] = dice.W;
                dice.T = numbers[3];
                dice.E = numbers[0];
                dice.B = numbers[1];
                dice.W = numbers[2];    
            }
            else if (orders[i] == 'W')
            {
                numbers[0] = dice.T;
                numbers[1] = dice.W;
                numbers[2] = dice.B;
                numbers[3] = dice.E;
                dice.T = numbers[3];
                dice.W = numbers[0];
                dice.B = numbers[1];
                dice.E = numbers[2];    
            }
            else
            {
                numbers[0] = dice.T;
                numbers[1] = dice.N;
                numbers[2] = dice.B;
                numbers[3] = dice.S;
                dice.T = numbers[3];
                dice.N = numbers[0];
                dice.B = numbers[1];
                dice.S = numbers[2];     
            }
        }
        Console.WriteLine(dice.T);
    }
}
class dice
{
    private int _T, _B, _N, _E, _W, _S;
    public int T { get { return _T; } set { _T = value; } }
    public int B { get { return _B; } set { _B = value; } }
    public int N { get { return _N; } set { _N = value; } }
    public int E { get { return _E; } set { _E = value; } }
    public int W { get { return _W; } set { _W = value; } }
    public int S { get { return _S; } set { _S = value; } }

    public dice(){
        _T= _B= _N= _E= _W= _S = 0;
    }

    public void setNumbers(int[] numbers)
    {
        _T = numbers[0];
        _S = numbers[1];
        _E = numbers[2];
        _W = numbers[3];
        _N = numbers[4];
        _B = numbers[5];
    }

    public void getNumbers()
    {
        int[] numbers = new int[6];
        numbers[0] = _T;
        numbers[1] = _S;
        numbers[2] = _E;
        numbers[3] = _W;
        numbers[4] = _N;
        numbers[5] = _B;
    }
}

Measured memory_bytes: 5608
#include<stdio.h>

int gcd(int,int);

int main(){
  int x,y;

  scanf("%d%d",&x,&y);
  printf("%d\n",gcd(x,y));

  return 0;
}

int gcd(int x,int y){
  int n;
  
  if(y>x){
    n= x;
    x = y;
    y = n;
  }
  
  while(y>0)           {
    int r = x%y;
    x = y;
    y  =r;
  }
  return x;
}




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

#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

const long long MOD = 1000000007;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T pow_mod(T , T , T);

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  faster();
  ll n,a,b;
  cin >> n >> a >> b;
  ll sum = modpow(2,n,MOD);
  sum--;
  ll _sum = 1;
  for(ll i=n;i>=n-a+1;i--){
    _sum = _sum*i%MOD;
  }
  for(ll i=a;i>=1;i--){
    _sum = _sum*(modpow(i,MOD-2,MOD))%MOD;
  }
  ll __sum = 1;
  for(ll i=n;i>=n-b+1;i--){
    __sum = __sum*i%MOD;
  }
  for(ll i=b;i>=1;i--){
    __sum = __sum*(modpow(i,MOD-2,MOD))%MOD;
  }
  sum = sum - _sum - __sum;
  while(sum<0) sum += MOD;
  cout << sum << endl;
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し二乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し二乗法(剰余)
template <class T>
T pow_mod(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = pow_mod(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

Measured memory_bytes: 256
n = gets.to_i
b = gets.chomp.split.map(&:to_i)
a = []

loop do
  break if n == 0

  found = false
  (n - 1).step(0, -1) do |i|
    if i + 1 == b[i]
      a.unshift(i + 1)
      b.delete_at(i)
      found = true
      break
    end
  end
  
  if !found
    puts "-1"
    exit
  end
  n -= 1
end
puts a

Measured memory_bytes: 14344
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>


int main(){
	std::string S;
	std::cin >> S;
	if(S=="AKIHABARA"){
		std::cout << "YES" <<std::endl;
	}else if(S=="KIHBAR"){
		std::cout << "YES" <<std::endl;
	}else if(S=="KIHABR"){
		std::cout << "YES" <<std::endl;
	}else if(S=="KIHBRA"){
		std::cout << "YES" <<std::endl;
	}else if(S=="AKIHBR"){
		std::cout << "YES" <<std::endl;
	}else if(S=="KIHBR"){
		std::cout << "YES" <<std::endl;
	}else if(S=="AKIHABR"){
		std::cout << "YES" <<std::endl;
	}else if(S=="AKIHBAR"){
		std::cout << "YES" <<std::endl;
	}else if(S=="AKIHBRA"){
		std::cout << "YES" <<std::endl;
	}else if(S=="AKIHABAR"){
		std::cout << "YES" <<std::endl;
	}else if(S=="AKIHABRA"){
		std::cout << "YES" <<std::endl;
	}else if(S=="AKIHBARA"){
		std::cout << "YES" <<std::endl;
	}else if(S=="KIHABARA"){
		std::cout << "YES" <<std::endl;
	}else if(S=="KIHABAR"){
		std::cout << "YES" <<std::endl;
	}else if(S=="AKIHBRA"){
		std::cout << "YES" <<std::endl;
	}else if(S=="KIHABRA"){
		std::cout << "YES" <<std::endl;
	}else{
		std::cout << "NO" <<std::endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t<<endl;
    }
    else
        cout<<(n/x+1)*t<<endl;

}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	int n;string s;
	int m=0,x=0;;
	cin>>n>>s;
	rep(i,n){
		if(s[i]=='I'){
			x++;
			m=max(m,x);
		}else
		{
			x--;
			m=max(m,x);
		}
	}
	cout<<m<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

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

        int n = sc.nextInt();

        System.out.println(n*n*n);
        

        
        
        

        






    }
}

Measured memory_bytes: 22608
INF = float('inf')
from collections import defaultdict
N = int(input())
dx = defaultdict(list)
dy = defaultdict(list)
for i in range(N):
    x,y,d = input().split()
    x = int(x)
    y = int(y)
    dx[d].append(x)
    dy[d].append(y)

mxl = INF
if 'L' in dx:
    mxl = min(dx['L'])
mxr = INF
if 'R' in dx:
    mxr = min(dx['R'])
mxud = INF
if 'U' in dx:
    mxud = min(dx['U'])
if 'D' in dx:
    mxud = min(min(dx['D']),mxud)
Mxl = -INF
if 'L' in dx:
    Mxl = max(dx['L'])
Mxr = -INF
if 'R' in dx:
    Mxr = max(dx['R'])
Mxud = -INF
if 'U' in dx:
    Mxud = max(dx['U'])
if 'D' in dx:
    Mxud = max(max(dx['D']),Mxud)
myu = INF
if 'U' in dy:
    myu = min(dy['U'])
myd = INF
if 'D' in dy:
    myd = min(dy['D'])
mylr = INF
if 'L' in dy:
    mylr = min(dy['L'])
if 'R' in dy:
    mylr = min(min(dy['R']),mylr)
Myu = -INF
if 'U' in dy:
    Myu = max(dy['U'])
Myd = -INF
if 'D' in dy:
    Myd = max(dy['D'])
Mylr = -INF
if 'L' in dy:
    Mylr = max(dy['L'])
if 'R' in dy:
    Mylr = max(max(dy['R']),Mylr)

def xmin(t):
    return min(mxl-t,mxr+t,mxud)

def xmax(t):
    return max(Mxl-t,Mxr+t,Mxud)

def ymin(t):
    return min(myu+t,myd-t,mylr)

def ymax(t):
    return max(Myu+t,Myd-t,Mylr)

cand = [0,(mxl-mxr)/2,mxl-mxud,mxud-mxr,(Mxl-Mxr)/2,Mxl-Mxud,Mxud-Mxr,(myd-myu)/2,mylr-myu,myd-mylr,(Myd-Myu)/2,Mylr-Myu,Myd-Mylr]

ans = INF
for t in cand:
    if t < 0:
        continue
    ans = min(ans,(xmax(t)-xmin(t))*(ymax(t)-ymin(t)))
print(ans)

Measured memory_bytes: 58968
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int s[3];

int main() {
  cin>>s[0]>>s[1]>>s[2];
  sort(s,s+3);
  cout<<s[0]+s[1]<<endl;
}


Measured memory_bytes: 256
N = int(input())
abc = [0]*N
for i in range(N):
    abc[i] = list(map(int,input().split()))
dp = [0]*N
for i in range(N):
    dp[i] = [0,0,0]
dp[0][0],dp[0][1],dp[0][2]= abc[0][0], abc[0][1], abc[0][2]

for i in range(1, N):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + abc[i][0]
    dp[i][1]= max(dp[i-1][0], dp[i-1][2])+ abc[i][1]
    dp[i][2]= max(dp[i-1][1], dp[i-1][0])+ abc[i][2]

print(max(dp[N-1]))


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

int main(){
    int n;
    cin>>n;
    bool flag=false;
    while(n>0){
        if(n%10==9)flag=true;
        n/=10;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(){
  int x, n;
  cin >> x >> n;
  vector<int> nums;
  for (int i=0; i< n; i++) {
    int a;
    cin >> a;
    nums.push_back(a);
  }
  sort(nums.begin(), nums.end());

  auto center = find(nums.begin(), nums.end(), x);
  if (center == nums.end()) {
    // if x not found
    cout << x << endl;
    return 0;
  }

  int forward = 101;
  int backward = 101;

  int before = x;
  for (auto itr = center - 1; itr >= nums.begin(); itr--) {
    if (*itr != --before) {
      forward = before;
      break;
    }
  }
  if (forward == 101) {
    forward = before - 1;
  }

  before = x;

  for (auto itr = center + 1; itr < nums.end(); itr++) {
    if (*itr != ++before) {
      backward = before;
      break;
    }
  }

  if (backward == 101) {
    backward = before +1 ;
  }

  int ans = abs(forward-x) <= abs(backward-x) ?forward  : backward;
  cout << ans << endl;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

signed main() {
  int A, B;
  cin >> A >> B;
  if ((A + 11) % 13 > (B + 11) % 13) {
    cout << "Alice" << endl;
  } else if ((A + 11) % 13 < (B + 11) % 13) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
}


Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
A = []
if N == 1:
    A = [str(i) for i in range(10)]
else:
    A = [str(i) for i in range(10**(N-1), 10**N)]

for i in range(M):
    s, c = [int(j) for j in input().split()]
    A = [a for a in A if a[s-1] == str(c)]
if len(A) > 0:
    print(A[0])
else:
    print(-1)

Measured memory_bytes: 62560
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  s = to_string(n);
  rep(i,3){
    if(s[i]=='1'){
      s[i] = '9';
    }else{
      s[i] = '1';
    }
  }
  cout << s << endl;
  return 0;
}

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

int main(){
  ll n;  cin >> n ;
  int a[n],b[n],c[n];
  ll all=0;
  rep(i,n){
     cin >> a[i];
  }
  rep(i,n){
     cin >> b[i];
  }
  rep(i,n-1){
     cin >> c[i];
  }
  rep(i,n){
     all+=b[a[i]-1];
     if(i+1<n && a[i+1] == a[i]+1){
        all += c[a[i]-1];
     }
  }
  cout << all << endl;
}



Measured memory_bytes: 256
def expected_value(x):
    a = int(x)
    s = (a+1) * (a/2)
    # e = 0
    # for i in range(1, a+1):
    #     e += i / a
    return s / a

n, k = [int(x) for x in input().split()]
evs = list(map(expected_value, input().split())) 

# initialize
left = 0
max_ev = 0
ev = 0
for i in range(k):
    ev += evs[i]

max_ev = ev
for i in range(k, n):
    ev = ev - evs[left] + evs[i]
    left += 1
    if ev > max_ev:
        max_ev = ev
print('{:.7f}'.format(max_ev))

Measured memory_bytes: 23588
S = input()
n = len(S)
res = 0
cur = 0
count = [0] * 2020
for i, c in enumerate(map(int, S)):
    cur = (cur * 10 + c) % 2019
    if cur == 0:
        res += 1
    temp = (cur * pow(10, (n - i), 2019)) % 2019
    res += count[temp]
    count[temp] += 1
print(res)


Measured memory_bytes: 9120
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(x + r > W || x - r < 0){
            System.out.println("No");
        } else if (y + r > H || y - r < 0){
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
        
        
    }
}


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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int A[220000], B[220000];
pint BA[220000];
signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) { cin >> A[i] >> B[i], BA[i] = pint(B[i], A[i]); }
    sort(BA, BA + N), reverse(BA, BA + N);
    int t = 1e11;
    for (int i = 0; i < N; i++) {
        chmin(t, BA[i].first);
        t -= BA[i].second;
        if (t < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 6912
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 getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	x := getInts(N)

	ans := 1
	cnt := 0
	for i := 1; i <= N; i++ {
		// out(x[i-1], 2*cnt-1)
		if x[i-1] >= 2*(cnt+1)-1 {
			cnt++
		} else {
			ans *= (cnt + 1)
			ans %= mod
		}
	}
	for i := 1; i <= cnt; i++ {
		ans *= i
		ans %= mod
	}
	out(ans)
}


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

int main()
{
    ll n;
    cin >>n;
    ll a[n];
    rep(i,n) cin >>a[i];
    ll ans[n];
    rep(i,n) ans[a[i]-1]=i+1;
    rep(i,n) cout<<ans[i]<<endl;
}


Measured memory_bytes: 2432
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
int n;
int num[200010];
ll ans;
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for (int i = 1; i <= n; i++) num[i] = read() - i;
	sort(num + 1, num + n + 1);
	int now = num[(n + 1) / 2];
	for (int i = 1; i <= n; i++)
		ans = ans + abs(num[i] - now);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int ans = 0;
	string s;
	cin >> s;
	int temp = 0;

	loop(i,0,s.length())
	{
		if(s[i] == 'R')
		{
			temp++;
			ans = max(ans , temp);
		}
		else temp = 0;
	}

	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int a[101];
int main(){
	int N,K;
	int c;
	cin >> N >> K;
	for(int i=0;i<K;i++){
		int x;
		cin >> x;
		for(int j=0;j<x;j++){
			int y;
			cin >> y;
			a[y]=1;
		}
	}
	for(int i=1;i<=N;i++){
		if(a[i]==0)c++;
	}
	cout << c << endl;
	return 0;
}

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

const int N = 20000 + 10;

int n;
int perm[N];
int aa[N], bb[N], cc[N];

int main() {
	scanf( "%d", &n );
	for( int i = 1; i <= n; i++ ) {
		scanf( "%d", perm + i );
	}
	for( int i = 1; i <= n; i++ ) {
		cc[perm[i]] = i;
	}
	aa[1] = bb[1] = 1;
	for( int i = 1; i < n; i++ ) {
		if( cc[i+1] - cc[i] > 0 ) {
			bb[i+1] = bb[i] - 1;
			aa[i+1] = cc[i+1] - cc[i] + aa[i] + 1;
		} else {
			aa[i+1] = aa[i] + 1;
			bb[i+1] = cc[i+1] - cc[i] + bb[i] - 1;
		}
	}
	int amin = aa[1], bmin = bb[1];
	for( int i = 1; i <= n; i++ ) {
		amin = min( amin, aa[i] );
		bmin = min( bmin, bb[i] );
	}
	for( int i = 1; i <= n; i++ ) {
		aa[i] = aa[i] - amin + 1;
		bb[i] = bb[i] - bmin + 1;
	}
	for( int i = 1; i <= n; i++ )
		printf( "%d ", aa[i] );
	printf( "\n" );
	for( int i = 1; i <= n; i++ )
		printf( "%d ", bb[i] );
	printf( "\n" );

}




Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int s[200010]={},x[200010]={};
  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    s[i]=s[i-1]+a;
    x[i]=x[i-1]^a;
  }
  int ans=0,l=1;
  for(int r=1;r<=n;r++){
    for(;(s[r]-s[l-1])!=(x[r]^x[l-1]);l++);
    ans+=r-l+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3964
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  std::cout<<std::fixed<<std::setprecision(10);
  ll N; cin>>N;
  vector<ll> v;
  rep(i,N){
    ll a; cin>>a;
    v.push_back(a);
  }
  
  sort(v.begin(),v.end());
  
  
  ld ans=(v[0]+v[1])/2.0;
  
  if(N>2){
    for(int i=2; i<N; i++){
      ans=(ans+v[i])/2.0;
    }
  }
  
  cout<<ans<<endl;
}
    
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 998244353;
int n;
char s[maxn];
int cnt[maxn << 1];
int get_val(int k) {
	int res = 0;
	for(int i = 0; i < k; i++) {
		res = (2LL * res % mod + (s[i] - '0')) % mod;
	}
	return res;
}
void add(int& a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
void sub(int& a, int b) {
	a -= b;
	if(a < 0) a += mod;
}
int main() {
	scanf("%d", &n);
	scanf("%s", s);
	for(int k = 2; k <= 2 * n; k += 2) {
		if(2 * n % k != 0 || (2 * n / k) % 2 == 0) continue;
		int num = 0;
		add(num, get_val(k / 2));
		bool flag = 1;
		for(int j = k / 2; j < n; j++) {
			char t;
			int r = j % k;
			if(r < k / 2) t = s[r];
			else t = '0' + '1' - s[r - k / 2];
			if(t > s[j]) {flag = 0; break;}
			else if(t < s[j]) break;
		}
		if(flag) add(num, 1);
		//printf("k = %d: flag = %d, num = %d\n", k, flag, num);
		add(cnt[k], num);
		int s = 2 * n / k;
		//printf("s = %d\n", s);
		for(int l = 3; l <= s; l += 2) 
			if(s % l == 0) sub(cnt[k * l], cnt[k]);
	}
	//for(int k = 1; k <= 2 * n; k += 1)
	//	printf("cnt[%d] = %d\n", k, cnt[k]);
	int ans = 0;	
	for(int k = 2; k <= 2 * n; k += 2) 
		add(ans, 1LL * k * cnt[k] % mod);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
MOD=10**9+7
ans=1
1.upto(N) do|i|
  ans*=i
  ans%=MOD
end
puts ans

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

int main() {
	string s, t;
	cin >> s >> t;
	
	vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1));
	for (int j = 1; j <= s.size(); ++j) {
		for (int i = 1; i <= t.size(); ++i) {
			if (s[j-1] == t[i-1])
				dp[j][i] = dp[j-1][i-1] + 1;
			else
				dp[j][i] = max(dp[j-1][i], dp[j][i-1]);
		}
	}

	string longest;
	for (int j = s.size(), i = t.size(); j > 0 and i > 0; ) {
		if (s[j-1] == t[i-1]) {
			longest += s[j-1];
			j--; i--;
		}
		else {
			dp[j-1][i] > dp[j][i-1] ? j-- : i--;
		}
	}
	
	reverse(longest.begin(), longest.end());
	cout << longest << endl;
}


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

stack = list()

def deal_expression(x):
    if x.isdigit():
        stack.append(int(x))
    else:
        a = stack.pop()
        b = stack.pop()
        if x == '+':
            stack.append(b + a)
        elif x == '-':
            stack.append(b - a)
        elif x == '*':
            stack.append(b * a)
        elif x == '/':
            stack.append(b / a)

for x in input().split():
    deal_expression(x)
print(stack[0])

Measured memory_bytes: 7752
#include <stdio.h>

int main(void) {
	int blood_num;
	int blood_rest[100];
	int family_num;
	int now_blood;
	int i,j;
	while(1) {
		scanf("%d%d",&family_num,&blood_num);
		if(family_num==0 && blood_num==0)break;
		for(i=0;i<blood_num;i++)scanf("%d",&blood_rest[i]);
		for(i=0;i<family_num;i++) {
			for(j=0;j<blood_num;j++) {
				scanf("%d",&now_blood);
				blood_rest[j]-=now_blood;
			}
		}
		for(i=0;i<blood_num;i++) {
			if(blood_rest[i]<0) {
				puts("No");
				break;
			}
		}
		if(i>=blood_num)puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <tuple>
using namespace std;
typedef long long ll;

int main(void){
    ll n, a[100010], b[100010], c[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    
    int x[100010], y[100010], a_idx = 0, b_idx = 0, c_idx = 0;
    while (a_idx != n && b_idx != n) {
        if (a[a_idx] < b[b_idx]) {
            x[a_idx] = n - b_idx;  a_idx++;
        }
        else b_idx++;
    }
    if (a_idx != n) {
        for (int i = a_idx; i < n; i++) x[i] = 0;
    }
    
    b_idx = 0;
    while (b_idx != n && c_idx != n) {
        if (b[b_idx] < c[c_idx]) {
            y[b_idx] = n - c_idx;  b_idx++;
        }
        else c_idx++;
    }
    if (b_idx != n) {
        for (int i = b_idx; i < n; i++) y[i] = 0;
    }
    
    ll s[100010];
    for (int i = 0; i <= n; i++) {
        if (i == 0) s[i] = 0;
        else s[i] = s[i - 1] + y[i - 1];
    }
    
    ll ans = 0;
    for (int i = 0; i < n; i++) ans += s[n] - s[n - x[i]];
    
    cout << ans << endl;
    
    /*
    for (int i = 0; i < n; i++) cout << x[i] << " ";
    cout << endl;
    for (int i = 0; i < n; i++) cout << y[i] << " ";
    cout << endl;
    for (int i = 0; i <= n; i++) cout << s[i] << " ";
    cout << endl;*/
}


Measured memory_bytes: 4224
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 25/07/2020

from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

n, k = iia()
arr = iia()
tot = 1
for i in range(k, n):
    if arr[i] > arr[i - k]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 94468
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define do(i,j,k) for(register int i=j;i>=k;i--) 
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
int t;
struct node
{
	ll val,pos;
}a[2005];
ll dp[2005][2005];
bool cmp(node x,node y){return x.val<y.val;}
int main()
{
    int n=read();
	fo(i,1,n)
	{
		a[i].val=read();
		a[i].pos=i;
	} 
	sort(a+1,a+n+1,cmp);
	fo(i,1,n)
	{
		ll p=a[i].val,s=a[i].pos;
		fo(l,1,n+1-i)
		{
			int r=l+i-1;
			dp[l][r]=max(dp[l+1][r]+p*abs(s-l),dp[l][r-1]+p*abs(s-r));
		}
	}
	printf("%lld\n",dp[1][n]);
}
/*int cnt,h[200010],vis[200010],dis[200010];
struct edge
{
	int v,w,next;
}e[200010*2];
il void add(int u,int v,int w)
{
	e[++cnt].v=v;
	e[cnt].w=w;
	e[cnt].next=h[u];
	h[u]=cnt;
}*/
/*int cnt,prime[1005],p[1005];
void primes(int n)
{
	memset(p,1,sizeof(p));
	p[1]=0;
	fo(i,2,n)
	{
		if(p[i]) prime[++cnt]=i;
		fo(j,1,cnt)
		{
			if(i*prime[j]>n) break;
			p[i*prime[j]]=0;
			if(i%prime[j]==0) break;
		}
	}
}*/

Measured memory_bytes: 26320
#include<stdio.h>
#include<stdlib.h>

int main(void){

  int N;
  scanf("%d\n", &N);

  int *A;
  A = (int*)malloc(N*sizeof(int));
  for(int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }

  int min=1000000000, max=0;

  for(int i=0; i<N; i++){
    if(A[i]<min) min = A[i];
    if(A[i]>max) max = A[i];
  }

  printf("%d\n", max-min);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int age = Integer.parseInt(sc.next());
        if (age == 7 || age == 5 || age == 3) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 22740
#include <iostream>
using namespace std;
 
int main() {
	int a, b, c, ans;
	cin >> a >> b >> c;
	ans = 0;
 
	for (int i = 0; i <= b; ++i) {
		if ((a*i) % b == c) {
			ans = 1;
			break;
		}
	}
	if (ans == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
		return 0;
}

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

int main(){
  int N,H,W;
  cin>> N>>H>>W;
  vector<int> A(N),B(N);
  REP(i,N){
    cin >> A.at(i)>>B.at(i);
  }
  int count=0;
  REP(i,N){
    if(A.at(i)>=H && B.at(i)>=W){
      //cout << A.at(i)<<B.at(i)<<endl;
      count++;}
  }
  cout<<count<<endl;
  
  
  


}


Measured memory_bytes: 256
N, P = map(int, input().split())
A = [(int(a)) % 2 for a in input().split()]

DP = [[0, 0] for _ in range(N)] #DP[i][0]はi番目で0となる場合の数, DP[i][1]は1となる場合の数
DP[0][A[0]] += 1
DP[0][0] += 1
for i in range(1, N):
    if A[i] == 0:
        DP[i][0] = DP[i-1][0] * 2
        DP[i][1] = DP[i-1][1] * 2
    else:
        DP[i][0] = DP[i-1][1] + DP[i-1][0]
        DP[i][1] = DP[i-1][0] + DP[i-1][1]
print(DP[N-1][P])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<pl,ll> tl;
vector<tl> w;
int main() {
	ll x,y,z;
	cin >> x >> y >> z;
	ll n = x+y+z;
	for(int i=0;i<n;i++) {
		ll a,b,c;
		cin >> a >> b >> c;
		w.push_back({{a,b},c});
	}
	sort(w.begin(),w.end(),[&](const tl& a, const tl& b) {
			return a.first.second-a.first.first > b.first.second - b.first.first;
			}
			);
	vector<ll> ro(z+1,0);
	ll rs = 0;
	priority_queue<ll> pq;
	for(int i=0;i<y;i++) {
		rs += w[i].first.second;
		pq.push(w[i].second-w[i].first.second);
	}
	for(int i=0;i<z;i++) {
		ro[i] += rs;
		rs += w[y+i].first.second;
		pq.push(w[y+i].second-w[y+i].first.second);
		rs += pq.top();pq.pop();
	}
	ro[z] += rs;
	rs = 0;
	pq = priority_queue<ll>();
	reverse(w.begin(),w.end());
	for(int i=0;i<x;i++) {
		rs += w[i].first.first;
		pq.push(w[i].second-w[i].first.first);
	}
	for(int i=0;i<z;i++) {
		ro[z-i] += rs;
		rs += w[x+i].first.first;
		pq.push(w[x+i].second-w[x+i].first.first);
		rs += pq.top();pq.pop();
	}
	ro[0] += rs;
	ll res = 0;
	for(int i=0;i<ro.size();i++) {
		res = max(res,ro[i]);
	}
	cout << res << '\n';
}


Measured memory_bytes: 7440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,l,result=0,tmp=0,tmp2=0;
  int a[LIMIT2]={0};
  int k[LIMIT1]={0};
  int s[30][30]={0};
  int p[30]={0};
  
  scanf("%lld %lld",&n,&m);
  rep(i,m){
    scanf("%d",&k[i]);
    rep(j,k[i]){
      scanf("%d",&s[i][j]);
    }
  }
  rep(i,m) scanf("%d",&p[i]);
  
  for(i=0;i<(1<<(n));i++){//switch add pattern
    tmp2=0;
    for(j=0;j<m;j++){//lamp
      tmp=0;
      for(l=0;l<k[j];l++){
        if(i & (1<<(s[j][l]-1))) tmp++;
      }
      if(tmp%2==p[j]) tmp2++;
    }
    if(tmp2==m) result++;
  }
  printf("%lld",result);
  return 0;
}



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

    // void solve(){
    //     int n0,n1,n2;   cin >> n0 >> n1 >> n2;
    //     if(n1 == 0){
    //         for(int i = 0;i <= n0;i++)  cout << (n0 == 0 ? "" : "0");
    //         for(int i = 0;i <= n2;i++)  cout << (n2 == 0 ? "" : "1");
    //         cout << "\n";
    //         return;
    //     }
    //     for(int i = 0;i <= n2;i++)  cout << "1";
    //     for(int i = 0;i <= n0;i++)  cout << "0";
    //     for(int i = 0;i <= n1 - 2;i++)  cout << (i&1 ? "0" : "1");
    //     cout << "\n";
    // }

    int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        string a,b; cin >> a >> b;
        string s;
        if(a.size() >= b.size())    cout << "No";
        else{
            for(int i = 0;i < a.size();i++){
                s += b[i];
            }
            if(s == a)  cout << "Yes";
            else    cout << "No";
        }
    	return 0;
}

Measured memory_bytes: 3044