akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int[] H = LineInt();
        Array.Reverse(H);
        string ans = "Yes";
        for (int i = 1; i < N; i++)
        {
            if (H[i - 1] < H[i]) H[i] -= 1;
        }
        for (int i = 1; i < N; i++)
        {
            if (H[i - 1] < H[i]) ans = "No";
        }

        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}
public class MinTree
{
    private List<int> table = new List<int>();
    private static int size = 1;
    private static int high = 1;
    public MinTree(int n, int k = 0)
    {
        while (size < n) size *= 2;
        high = (int)Math.Log(size, 2);
        for (int i = 0; i < 2 * size - 1; i++) table.Add(k);
    }
    public void Add(int x, int v)
    {
        x += size - 1;
        table[x] += v;
        table[x] = Math.Max(0, table[x]);
        while (x != 0)
        {
            x = (x % 2 == 0 ? x / 2 - 1 : x / 2);
            table[x] = table[x * 2 + 1] + table[x * 2 + 2];
        }
    }
    public int MLS(int k)
    {
        if (table.First() == 0) return -1;
        int index = 0;
        for (int y = 0; y < high; y++)
        {
            int left = index * 2 + 1;
            int right = index * 2 + 2;
            if (table[left] >= k) index = left;
            else { k -= table[left]; index = right; }
        }
        return index - size + 1;
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


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

const int MAX = 2100;

int main() {
    long long res = 0;
    int N; cin >> N;
    vector<long long> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];

    // C, S
    vector<long long> C(MAX, 0), S(MAX+1, 0);
    for (int i = 0; i < N; ++i) C[L[i]]++;
    for (int x = 0; x < MAX; ++x) S[x+1] = S[x] + C[x]; // 累積和
    
    // a と b を固定
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue; // 同じものは選ばない
            
            // c の満たすべき値の区間を [left, right) で表す
            int left = abs(L[i] - L[j]) + 1;
            int right = L[i] + L[j];

            // 累積和で個数を求める
            int count = S[right] - S[left];
            if (left <= L[i] && L[i] < right) --count;
            if (left <= L[j] && L[j] < right) --count;

            res += max(count, 0);
        }
    }
    cout << res/6 << endl;
}

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll > 
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;
 
const double EPS = 1e-12;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
 
ll dp[N] , h[N];
ll n;
ll fun(ll i){

  if(i == n - 1){
    return abs(h[i] - h[n]);
  }
  if(i >= n){
    return 0;
  }
  if(dp[i] != -1){
    return dp[i];
  }

  return dp[i] = min(fun(i+1) + abs(h[i] - h[i+1]), fun(i+2) + abs(h[i] - h[i+2]));
  //return dp[n];
}
 
 
int main()
{
    fast;
    //ll n;
    cin >> n;
    for(int i = 1 ; i <= n; i++ ){
      cin >> h[i];
    }
    memset(dp , -1 , sizeof(dp));
    cout << fun(1); 
    





















    
    return 0;
    
}

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

typedef long long ll;

struct UnionFind
{
    int i;
    vector<int> par;
    vector<int> size;
    UnionFind(int n): par(n),size(n,1){
        for(i = 0;i < n;++i){
            par.at(i) = i;
        }
    }
    
    int root(int x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = root(par.at(x));
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }else{
            if(size.at(x) < size.at(y)){
                swap(x,y);
            }
            par.at(ry) = rx;
            size.at(rx) += size.at(ry);
            return;
        }
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int get_size(int x){
        return size.at(root(x));
    }

};

int main()
{
    int i,j;
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<set<int>> dame(n);
    int a,b;
    for(i = 0;i < m;++i){
        cin >> a >> b;
        --a;    --b;
        uf.unite(a,b);
        dame.at(a).insert(b);
        dame.at(b).insert(a);
    }
    int c,d;
    for(i = 0;i < k;++i){
        cin >> c >> d;
        --c;    --d;
        if(!uf.same(c,d))   continue;
        dame.at(c).insert(d);
        dame.at(d).insert(c);
    }
    for(i = 0;i < n;++i){
        cout << uf.get_size(i) -1 - dame.at(i).size() << endl;
    }
    return 0;
}

Measured memory_bytes: 25472
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		String s=scn.next();
		int ans=0;
		for(int i=0;i<n-2;i++) {
			if(s.charAt(i)=='A' && s.charAt(i+1)=='B' && s.charAt(i+2)=='C') {
				ans++;
			}
		}System.out.println(ans);
    }
}

Measured memory_bytes: 27028
import heapq

n = int(input())
a = list(map(int, input().split()))

p = [0] * (n + 1)
q = [] + p

L = []
R = []
C = [] + a[n:n * 2]

for i in range(n):
    heapq.heappush(L, a[i])
    heapq.heappush(R, - a[n * 2 + i])

p[0] = sum(L)
q[n] = sum(R)
for i in range(n):
    if C[i] > L[0]:
        p[i + 1] = p[i] + C[i] - L[0]
        heapq.heappop(L)
        heapq.heappush(L, C[i])
    else:
        p[i + 1] = p[i]

    temp = C[n - 1 - i] * -1
    if temp > R[0]:
        q[n - 1 - i] = q[n - i] + temp - R[0]
        heapq.heappop(R)
        heapq.heappush(R, temp)
    else:
        q[n - 1 - i] = q[n - i]

ans = p[n] + q[n]
for i in range(n):
    ans = max(ans, p[i] + q[i])

print(ans)


Measured memory_bytes: 40212
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
int a;
string s;
cin>>a>>s;
if(a>=3200) cout<<s<<endl;
else cout<<"red"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans=1;
    int now=h[0];
    rep2(i,1,n){
        if(now<=h[i]) ans++;
        now = max(now,h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
#define MAX 52
#define MAX_TIME 30*61

vector<int> vv;

int encode(){
    int h,m;
    scanf("%d%d",&h,&m);
    int tim=60*h+m;
    vv.push_back(tim);
    return tim;
}
struct st{
    int star;
    int en;
    void input(){
        star=encode();
        en=encode();
    }
    inline bool contain(int t){
        return star<=t&&t<=en;
    }
};
struct ss{
    vector<st> v;
    void input(){
        for(int i=0;i<3;i++){
            v.push_back(st());
            v.back().input();
        }
    }
    inline bool valid(int a,int b,int c){
        for(auto &it:v){
            if(it.contain(a)||it.contain(b)||it.contain(c))continue;
            return false;
        }    
        return true;
    }
};
vector<ss> v;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        v.push_back(ss());
        v.back().input();
    }
    sort(vv.begin(),vv.end());
    vv.erase(unique(vv.begin(),vv.end()),vv.end());
    int ans=0;
    for(int i=0;i<vv.size();i++){
        for(int j=i;j<vv.size();j++){
            for(int k=j;k<vv.size();k++){
                int cnt=0;
                for(auto &it:v){
                    if(it.valid(vv[i],vv[j],vv[k])){
                        cnt++;
                    }
                }
                ans=max(ans,cnt);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int a, b, c, d;

void solve()
{
    if(fabs(a-c) <= d) printf("Yes\n");
    else {
        if(fabs(a-b) <= d && fabs(b-c) <= d) printf("Yes\n");
        else printf("No\n");
    }
}

int main()
{
    cin >> a >> b >> c >> d;
    solve();
    return 0;
}

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

#define LL long long

double arr[1009];

int main(){
	

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin>>n;

	double t,a;
	cin>>t>>a;

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

	vector<pair<double,int> > v;
	for(int i=1;i<=n;i++){
		v.push_back(make_pair(abs(a-(t-(0.006*arr[i]))),i));
	}
	sort(v.begin(),v.end());

	cout<<(v[0].second)<<endl;
}

Measured memory_bytes: 256
N = int(input())
array_xy=[[] for i in range(N)]
# print(array_xy)

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

# print(array_xy)

#正直者と不親切な人のすべての場合を列挙し、証言が成り立つ場合をみる
max_honest=0
for i in range(1<<N):
    #正直者と不親切な人の組み合わせを作成
    isHonest=[False]*N
    for j in range(N):
        if ((i >> j) & 1) == 1:
            isHonest[j]=True
    # print("pattern:", isHonest)


    #証言が成り立つか確認
    ok = True
    for j in range(len(array_xy)):
        #不親切な人の時証言は気にしない
        if isHonest[j]==False:
            continue
        #正直者のときは証言をチェック→おかしければこの場合は不成立
        for k in range(len(array_xy[j])):
            tmp_x = array_xy[j][k][0]
            tmp_y = array_xy[j][k][1]
            # print("tmp_x,tmp_y",tmp_x,tmp_y)
            if  (isHonest[tmp_x-1]==True and tmp_y ==0) or \
                (isHonest[tmp_x-1]==False and tmp_y ==1):
                ok = False
        if ok == False:
            break
    if ok == True:
        # print(isHonest)
        if isHonest.count(True) > max_honest:
            max_honest = isHonest.count(True)
print(max_honest)


Measured memory_bytes: 3064
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
edge = [[False for j in range(n)] for i in range(n)]
for i in range(m):
	edge[ab[i][0]-1][ab[i][1]-1] = edge[ab[i][1]-1][ab[i][0]-1] = True
visited = [False for j in range(n)]

def dfs(v):
	visited[v] = True
	for i in range(0, n):
		if edge[v][i]==True and visited[i]==False:
			dfs(i)

ans = 0
for i in range(m):
	edge[ab[i][0]-1][ab[i][1]-1] = edge[ab[i][1]-1][ab[i][0]-1] = False
	for j in range(n):
		visited[j] = False
	dfs(0)
	bridge = False
	for j in range(n):
		if visited[j]==False:
			bridge = True
			break
	if bridge:
		ans += 1
	edge[ab[i][0]-1][ab[i][1]-1] = edge[ab[i][1]-1][ab[i][0]-1] = True
print(ans)

Measured memory_bytes: 3064
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)



int main()
{
      int t;
      cin>>t;


      t<=999?cout<<"ABC":cout<<"ABD";


}

Measured memory_bytes: 3620
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll f[ohara], t[ohara], rui[ohara];

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

  f[0] = 1;
  t[0] = 1;
  rrep(i, 1, ohara) {
    f[i] = f[i - 1] * 4;
    t[i] = t[i - 1] * 2;
    f[i] %= MOD;
    t[i] %= MOD;
  }

  cin >> n;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);

  rep(i, n) {
    ll cost;
    cost = t[2 * i];
    cost *= f[n - i - 1];
    cost %= MOD;
    cost *= a[i];
    cost %= MOD;
    cost *= (i + 2);
    cost %= MOD;
    ans += cost;
    ans %= MOD;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 20736
fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(" ").map(String::toInt)
    when {
        a < b -> {
            if (b < c) {
                println("Yes")
            } else {
                println("No")
            }
        }
        else -> println("No")
    }
}



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

int panjang;
string s;
string t;

int main(){
	cin>>s>>t;
	panjang=s.length();
	s+=t[panjang];
	if(s==t){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n;
    if (n == 1) {
        END(1)
    }

    vl primes = {
            2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103,
            107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223,
            227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347,
            349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
            467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607,
            613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743,
            751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883,
            887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};

    ans = 1;
    REP(i, 0, primes.size()) {
        if (primes.at(i) > n) break;
        ll next = primes.at(i);
        while (next <= n) {
            cnt += n / next;
            next *= primes.at(i);
        }
        ans *= (cnt + 1);
        ans %= MOD;
        cnt = 0;
    }
    MSG(ans)
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  char c[3][3];
  rep(i,2)rep(j,3)cin>>c[i][j];
  bool ok=true;
  rep(i,3)if(c[0][i]!=c[1][2-i])ok=false;
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static int GCD(int a, int b)
    {
        while (b != 0)
        {
            var c = a % b;
            a = b;
            b = c;
        }
        return a;
    }

    public static int LCM(int a, int b)
    {
        return (a / GCD(a, b)) * b;
    }

    public static int ReadInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static void Main()
    {
        var n = ReadInt();
        var a = ReadInts();
        var ans = LCM(a[0],a[1]);
        for (int i = 2; i < n; i++)
        {
            ans = LCM(ans, a[i]);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 20256
#include <iostream>
#include <map>

using namespace std;

map<string,bool> m;

bool check(string s){
  if (m[s]) {
    return false;
  }

  if (s == "") {
    return true;
  }

  int len = (int)s.size();
  if (s[0] != 'm' || s[len-1] != 'w') {
    m[s] = true;
    return false;
  }

  if (len < 3) {
    m[s] = true;
    return false;
  } 

  len = (int)s.size();
  s.erase(--s.end());
  s.erase(s.begin());

  for (int i = 0 ; i < len ; i++) {
    if (s[i] == 'e') {
      string X = s.substr(0,i);
      string Y = s.substr(i+1,len);
 
      int ok = 2;
      if (check(X)) {
	ok--;
      } else {
	m[X] = true;
      }

      if (check(Y)) {
	ok--;
      } else {
	m[Y] = true;
      }

      if (!ok) {
	return true;
      }

    } 
  }

  m[s] = true;
  return false;
}

int main(){
  string s;

  cin >> s;
  if (check(s)) {
    cout << "Cat" << endl;
  } else {
    cout << "Rabbit" << endl;
  }

  return 0;
}

Measured memory_bytes: 10588
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    let A:Vec<usize> = sc.vec(N);
//    let mut ans:usize = 0;
    let mut now:usize = 0;
    for i in 0..N{
        if A[i] == now + 1{
            now += 1;
        }
    }
    if now == 0{
        println!("-1");
    }else{
        println!("{}", N - now);
    }

}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
int main(){
	int time[5];
  	int time_1d[5];
  	int output;output=0;
  	for(int i=0;i<5;i++){
  		cin>>time[i];
      	time_1d[i]=time[i]%10;
      	if(time[i]%10==0){
        	output=output+time[i];
        }else{
        	output=output+time[i]-time_1d[i]+10;
        }
  	}
  	int mini_time;mini_time=10;
  	for(int j=0;j<5;j++){
      if(mini_time>time_1d[j]&&time_1d[j]>0){
        mini_time=time_1d[j];
      }
    }
  	output=output-(10-mini_time);
    cout<<output<<endl;
}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

eps = 1e-7
def bs(f, mi, ma):
    mm = -1
    while ma > mi + eps:
        m1 = (mi*2+ma) / 3.0
        m2 = (mi+ma*2) / 3.0
        r1 = f(m1)
        r2 = f(m2)
        if r1 < r2:
            mi = m1
        else:
            ma = m2
    return f((ma+mi)/2.0)

def main():
    rr = []

    def f(n):
        a = [LI() for _ in range(n)]
        def _f(x,y):
            r = inf
            for px,py,l in a:
                r = min(r, l**2 - (x-px)**2 - (y-py)**2)
            return r
        def _fy(y):
            def _ff(x):
                return _f(x,y)
            return bs(_ff, -100, 100)
        r = bs(_fy,-100,100)

        return "{:0.7f}".format(r**0.5)

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 9112
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	int N, X;
	scanf("%d%d", &N, &X);
	int m[100];
	int min = 1000;
	int count = 0;
	int b[1000] = { 0 };
	int a = 0;
	int k = 0;

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

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1 - i; j++) {
			if (m[j] > m[j + 1]) {
				a = m[j];
				m[j] = m[j + 1];
				m[j + 1] = a;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		k = m[i];
		X -= m[i];
		if (X  >= 0 && b[k] == 0) {
			count++;
		}
	}
	printf("%d", count+X/m[0]);


	return 0;

}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let ab = get!(usize, usize; m);

    let mut nodes = vec![Vec::new(); n+1];
    for (a,b) in ab {
        nodes[a].push(b);
        nodes[b].push(a);
    }
    let mut left = 1;
    let mut right = 1;
    let mut set = BTreeSet::new();
    let mut deque = VecDeque::new();
    deque.push_front(1);
    set.insert(1);
    loop {
        if let Some(&node) = nodes[left].iter().find(|&e| !set.contains(&e)) {
            left = node;
            set.insert(node);
            deque.push_front(left);
            continue;
        }
        if let Some(&node) = nodes[right].iter().find(|&e| !set.contains(&e)) {
            right = node;
            set.insert(node);
            deque.push_back(right);
            continue;
        }
        break;
    }
    println!("{}", deque.len());
    for e in deque {
        print!("{} ", e);
    }
    println!("");
}


Measured memory_bytes: 19324
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int numa[25],numb[25],numc[25];
    int num;
    cin >> num;
    for(int i=1;i<=num;i++){
        cin >> numa[i];
    }
    for(int i=1;i<=num;i++){
        cin >> numb[i];
    }
    for(int i=1;i<num;i++){
        cin >> numc[i];
    }
    numc[num]=-1;
    int ans = 0;
    for(int i=1;i<num;i++){
        ans += numb[numa[i]];
        if(numa[i]+1==numa[i+1]){
            ans += numc[numa[i]];
        }
    }
    ans += numb[numa[num]];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll cnt;
void insertionSort(vector<ll> &a, ll n, ll g){
    for(ll i=g; i<n; i++){
        ll v=a[i];
        ll j=i-g;
        while(j>=0 && a[j]>v){
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }
}
void shellSort(vector<ll> &a, ll n){
    cnt=0;
    vector<ll> g={1};
    while(g[g.size()-1]*3+1<n){
        ll y=g[g.size()-1];
        g.push_back(y*3+1);
    }
    ll m=g.size();
    reverse(g.begin(),g.end());
    rep(i,m) insertionSort(a,n,g[i]);
    cout<<cnt<<endl;
}

int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> g={1};
    while(g[g.size()-1]*3+1<n){
        ll y=g[g.size()-1];
        g.push_back(y*3+1);
    }
    ll m=g.size();
    reverse(g.begin(),g.end());
    cout<<m<<endl;
    rep(i,m){
        cout<<g[i];
        if(i<m-1) cout<<' ';
    }
    cout<<endl;
    shellSort(a,n);
    rep(i,n) {cout<<a[i]<<endl;}
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ld r;
    cin >> r;
    cout << 2 * M_PI * r << endl;
    GAME_OVER;
}

Measured memory_bytes: 3808
#include <iostream>

using namespace std;

int main()
{
    int n,x,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(i%2==1&&x%2==1)cnt++;
    }
    cout <<cnt << endl;
    return 0;
}


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

map<unsigned long long,bool>mp;
unsigned long long a[100005];

int main(){

    int n,ans=0;

    cin>>n;

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

        if(mp[a[i]]==false){
            mp[a[i]]=true;
        }
        else{
            mp[a[i]]=false;
        }

    }

    for(int i=0;i<n;i++){
        if(mp[a[i]]==true) {
            ans++;
            mp[a[i]]=false;
        }
    }

    cout<<ans<<"\n";

}



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

const long long  mod=1e9+7;
int main()
{
  int n;
  cin>>n;
  vector<long long>dp(n+1);
  dp[1]=dp[2]=0;
  dp[0]=1;
  for(int i=3;i<=n;i++)
  {
      for(int j=i-3;j>=0;j--)
      {
          (dp[i]+=dp[j])%=mod;
      }
  }  
  cout<<dp[n];
}

Measured memory_bytes: 3572
#include<stdio.h>
int main(void){
	int W, H, x, y, r, a, b, c, d;
	scanf("%d", &W);
	scanf("%d", &H);
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &r);
	a = x - r;
	b = y + r;
	c = x + r;
	d = y - r;
	if ( 0 > a ){
		printf("No\n");
	}
	else if( b > H ){
		printf("No\n");
	}
	else if( c > W ){
		printf("No\n");
	}
	else if( 0 > d ){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1012
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 1100;

vector<int> g[maxn];
bool vis[maxn];
int match[maxn];

bool magyar(int u)
{
	for (int i = 0;i < g[u].size();++i)
	{
		int v = g[u][i];
		if (!vis[v])
		{
			vis[v] = true;
			if (!match[v] || magyar(match[v]))
			{
				match[u] = v;
				match[v] = u;
				return true;
			}
		}
	}
	return false;
}

int px[maxn], py[maxn];
int px2[maxn], py2[maxn];

int main(int argc, char * argv[])
{
	int n;
	scanf("%d", &n);
	for (int i = 1;i <= n;++i)
	{
		scanf("%d%d", &px[i], &py[i]);
	}
	for (int i = 1;i <= n;++i)
	{
		scanf("%d%d", &px2[i], &py2[i]);
	}
	for (int i = 1;i <= n;++i)
	{
		for (int j = 1;j <= n;++j)
		{
			if (px[i] < px2[j] && py[i] < py2[j])
			{
				g[i].push_back(n + j);
				g[n + j].push_back(i);
			}
		}
	}
	int ans = 0;
	for (int i = 1;i <= n;++i)
	{
		memset(vis, false, sizeof vis);
		if (magyar(i)) ans++;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 384
/* ex4_1
   key_tree */

#include <stdio.h>
#include <math.h>

int main(void){
    //　入力
    int all_tree, range; 
    scanf("%d %d", &all_tree, &range);
  
    // 監視員1人が監視できる木の本数
    int num_tree = 1 + 2*range;
  
    /* 木の全数を監視可能本数で割ったとき、割り切れたら商が、監視に必要な人数
  　   余りが出たら、商+1が監視に必要な人数 */
    int num_people = ceil((double)all_tree / num_tree);
  
    printf("%d\n", num_people);
  
    return 0;
}

Measured memory_bytes: 128
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 2*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif

vector<pii> adj[N] ;
int col[N], dist[N] ;

void dfs(int u, int p = -1){
    for(auto it : adj[u]){
        if(it.ff == p) continue ;
        dist[it.ff] = dist[u] + it.ss;
        if(dist[it.ff]%2) col[it.ff] = 1 ;
        dfs(it.ff,u) ;
    }
}
void solve()
{
    int n ;
    cin >> n; 
    rep(i,n-1){
        int x,y,w ;
        cin >> x >> y >> w ;
        adj[x].pb({y,w}) ;
        adj[y].pb({x,w}) ;
    }
    col[1] = dist[1] = 0 ;
    dfs(1) ;
    repA(i,1,n) cout << col[i] << endl ;

}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

using namespace std;
int main()
{
	int  n, y;
	cin >> n >> y;
	int ok = 1;
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= n; j++) {
			if (10000 * i + 5000 * j + 1000 * (n - i - j) == y && n - i - j >= 0) {
				cout << i << " " << j << " " << n - i - j << endl;
				ok = 0;
				break; 
			}
		}
					if (!ok)
				break;
	}
	if (ok)
		printf("-1 -1 -1\n");
	return 0;
} 

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int x,ans=1;
	cin>>x;
	for(int i=1;i<=x;i++){
		for(int j=2;j<=i;j++){
			int k=i,cnt=0;
			while(k%j==0)cnt++,k/=j;
			if(k==1 && cnt>1){
				ans=i;
			}
		}
	}
	cout<<ans;
}





Measured memory_bytes: 3568
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	if (a == b && b == c) cout << '1';
	else if (a == b || b == c || c == a) cout << '2';
	else cout << '3';

	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
l=list(input())
m=0
if n==1:
  print(0)
else:
  for i in range(1,n-1):
    if l[i]=="R":
      if l[i+1]=="R":
        m+=1
    if l[i]=="L":
      if l[i-1]=="L":
        m+=1
  if l[0]=="R" and l[0]==l[1]:
    m+=1
  if l[-1]=="L" and l[-2]==l[-1]:
    m+=1
  print(min(m+k*2,n-1))

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

vector<int> as, bs, cs;

int main() {
  int n;
  cin >> n;
  as.resize(n); bs.resize(n); cs.resize(n);
  rep(i, n) {
    cin >> as[i];
  }
  sort(as.begin(), as.end());
  rep(i, n) {
    cin >> bs[i];
  }
  sort(bs.begin(), bs.end());
  rep(i, n) {
    cin >> cs[i];
  }
  sort(cs.begin(), cs.end());
  long result = 0;
  rep(i, n) {
    int b = bs[i];
    auto aIte = lower_bound(as.begin(), as.end(), b);
    auto cIte = upper_bound(cs.begin(), cs.end(), b);
    result += (aIte-as.begin())*(cs.end()-cIte);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
using namespace std;

int a,b,k;

int main()
{
    while(scanf("%d%d%d",&a,&b,&k)!=EOF)
    {
        int t = k;
        if(b-k>a)
        {
            while(t--)
                printf("%d\n",a++);
            t = b - k + 1;
            if(t==a-1)
                ++t;
            while(t<=b)
                printf("%d\n",t++);
        }
        else
        {
            while(a<=b)
                printf("%d\n",a++);
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int r,c;
		Scanner scan = new Scanner(System.in);
		r=scan.nextInt();
		c=scan.nextInt();
		int[][] array=new int[r+1][c+1];
		for(int i=0;i<(r+1);i++)
			for(int j=0;j<(c+1);j++)
				array[i][j]=0;
		
		for(int i=0;i<r;i++){
			int temp=0;
			for(int j=0;j<c;j++){
				array[i][j]=scan.nextInt();
				temp+=array[i][j];
			}
			array[i][c]=temp;
		}
		for(int i=0;i<(c+1);i++){
			int temp=0;
			for(int j=0;j<r;j++){
				temp+=array[j][i];
			}
			array[r][i]=temp;
		}
		for(int i=0;i<(r+1);i++){
			for(int j=0;j<c;j++){
				System.out.print(array[i][j]+" ");
			}
			System.out.println(array[i][c]);
		}
	}
}


Measured memory_bytes: 41792
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void) {
	int n,x,y;cin>>n>>x>>y;
	cout<<min(x,y)<<" "<<max(0,x+y-n)<<endl;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main (){
    string s;
    cin >> s;
    while (s != "-") {
        int no, b;
        cin >> no ;
        for (int i = 0; i < no; i++) {
            cin >> b;
            s += s.substr(0, b);
            s = s.substr(b, s.length() - b);
        }
        cout << s << '\n';
        cin >> s;
    }
}


Measured memory_bytes: 3180
dX = [2,2,2,1,0,-1,-2,-2,-2,-1,0,1]
dY = [-1,0,1,2,2,2,1,0,-1,-2,-2,-2]
def solve(x,y,i):
	if i == 2*n: return True
	sx,sy = xy[i],xy[i+1]
	for dx,dy in zip(dX,dY):
		if doa(x+dx,y+dy,sx,sy): 
			r = solve(x+dx,y+dy,i+2)
			if r: return r

def doa(x,y,sx,sy):
	if not (0 <= x <= 9 and 0 <= y <= 9): return False
	return True if abs(x-sx) < 2 and abs(y-sy) < 2 else False

while 1:
	x,y = map(int,raw_input().split())
	if x == y == 0: break
	n = input()
	xy = map(int,raw_input().split())
	print "OK" if solve(x,y,0) else "NA"

Measured memory_bytes: 4264
N, Q = gets.split.map(&:to_i)
edges = (N - 1).times.map { gets.split.map(&:to_i) }
queries = Q.times.map { gets.split.map(&:to_i) }

graph = Array.new(N) { [] }
edges.each do |(u, v)|
  u -= 1
  v -= 1
  graph[u].push(v)
  graph[v].push(u)
end
table = Array.new(N) { 0 }
queries.each do |(u, x)|
  u -= 1
  table[u] += x
end

queue = [[0, nil]]
while !queue.empty?
  u, parent = queue.shift
  n = table[u]
  graph[u].each do |v|
    next if v == parent
    table[v] += n
    queue.push([v, u])
  end
end

ans = N.times.map do |n|
  table[n]
end.join(' ')
puts ans


Measured memory_bytes: 58620
n,W=map(int,raw_input().split())
w=[]
val=[]
for i in range(n):
    p=map(int,raw_input().split())
    w.append(p[0])
    val.append(p[1])
dp = [0]*(W+1)
for i in range(n):
    for j in range(W,w[i]-1,-1):
        dp[j]=max(dp[j],dp[j-w[i]]+val[i])
print(dp[-1])

Measured memory_bytes: 31852
n,m=map(int,input().split())
if n%2==1:
    for i in range(m):
        print(i+1,n-i)
else:
    for i in range(m):
        if i<m/2:
            print(i+1,n-i)
        else:
            print(i+1,n-i-1)

Measured memory_bytes: 9208