akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}
using namespace std;
const ll inf=(ll)1e14;
//const int MOD=(ll)1e10+7;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
ll n,m,h,w;
string s;

ll cal(ll b,ll n){
  if(b<2)return -1;
  if(n<b)return n;
  else return cal(b,n/b)+n%b;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n>>m;
  if(n==m){
    print(n+1);
    return 0;
  }
  for(ll i=2;i<=(int)sqrt(n)+1;i++){
    if(cal(i,n)==m){
      print(i);
      return 0;
    }
  }
  ll minans=inf;
  for(ll i=1;i<=(int)sqrt(n)+1;i++){
    ll q=i;
    if(cal((n-m+q)/q,n)==m){
      minans=min(minans,(n-m+q)/q);
    }
  }
  if(minans==inf)print(-1);
  else print(minans);
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}






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

signed main() {
  int x;
  cin >> x;
  if(x<600) cout << 8 << endl;
  else if(x<800) cout << 7 << endl;
  else if(x<1000) cout << 6 << endl;
  else if(x<1200) cout << 5 << endl;
  else if(x<1400) cout << 4 << endl;
  else if(x<1600) cout << 3 << endl;
  else if(x<1800) cout << 2 << endl;
  else cout << 1 << endl;

}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int d;
    cin >> d;
    
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26, 0));
    vector<int> l(26);
    vector<int> ans(d);
    for(int ic=0;ic<26;ic++) {
        cin >> c.at(ic);
    }
    for(int id=0;id<d;id++) {
        for(int iw=0;iw<26;iw++) {
            cin >> s.at(id).at(iw);
        }
    }

    llint tmax, ttmp, q, v;
    vector<int> ltmp(26);
    v = 0;
    for(int id=0;id<d;id++) {
        q = 0;
        tmax = 0;
        for(int iw=0;iw<26;iw++) {
            ttmp = s.at(id).at(iw);
            for(int jw=0;jw<26;jw++) {
                ltmp.at(jw) = l.at(jw);
            }
            ltmp.at(iw) = id + 1;
            for(int il=0;il<26;il++) {
                ttmp -= c.at(il)*(id + 1 - ltmp.at(il));
            }
            if(ttmp>tmax) {
                q = iw;
                tmax = ttmp;
            }
        }
        l.at(q) = id + 1;
        ans.at(id) = q + 1;
        v += tmax;
        // cout << v << endl;
    }

    vector<vector<int>> res(10000, vector<int>(d, 0));
    llint maxi = 0;
    for(int id=0;id<d;id++) {
        res.at(0).at(id) = ans.at(id);
    }

    vector<int> ansrep(d);
    llint vrep;
    for(int i=1;i<10000;i++) {
        vector<int> lrep(26);
        vrep = 0;
        for(int id=0;id<d;id++) {
            if(rand()%2==0) ansrep.at(id) = (res.at(maxi).at(id) + rand())%26;
        }
        for(int id=0;id<d;id++) {
            vrep += s.at(id).at(ansrep.at(id));
            lrep.at(ansrep.at(id)) = id + 1;
            for(int il=0;il<26;il++) {
                vrep -= c.at(il)*(id + 1 - lrep.at(il));
            }
        }
        for(int id=0;id<d;id++) {
            res.at(i).at(id) = ansrep.at(id);
        }
        // cout << vrep << endl;
        if(vrep>v) {
            v = vrep;
            maxi = i;
        }
    }
    for(int id=0;id<d;id++) {
        cout << res.at(maxi).at(id) << endl;
    }
    // cout << v << endl;
    return 0;
}


Measured memory_bytes: 18064
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		while(sc.hasNext()){
			Stack<Double> st = new Stack<Double>();
			String str[] = sc.nextLine().split(" ");
			for(int i = 0;i < str.length;i++){
				if(str[i].equals("+")){
					double x1 = st.pop();
					double x2 = st.pop();
					st.push(x1 + x2);
				}else if(str[i].equals("-")){
					double x1 = st.pop();
					double x2 = st.pop();
					st.push(x2 - x1);
				}else if(str[i].equals("*")){
					double x1 = st.pop();
					double x2 = st.pop();
					st.push(x1 * x2);
				}else if(str[i].equals("/")){
					double x1 = st.pop();
					double x2 = st.pop();
					st.push(x2 / x1);
				}else{
					st.push(Double.parseDouble(str[i]));
				}
			}
			double ans = st.pop();
			System.out.println(ans);
		}
	}
	public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

Measured memory_bytes: 17200
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
   
using namespace std;
   
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
   
const int INF = 1e9+7;
const ll LINF = 1e18+12;
const int maxn = 1e5+7;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int a[maxn], b[maxn];
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (int i = 0; i < n; i++){
        int v;
        cin >> v;
        if (i & 1) b[v]++;
        else a[v]++;
    }
    int ans_a = 0, ans_b = 0, pre_a = 0, pre_b = 0, va, vb;
    for (int i = 0; i < maxn; i++){
        if (a[i] >= ans_a) {
            va = i;
            pre_a = ans_a;
            ans_a = a[i];
        }
        if (i != va)
            if (a[i] >= pre_a)
                pre_a = a[i];
        if (b[i] >= ans_b) {
            vb = i;
            pre_b = ans_b;
            ans_b = b[i];
        }
        if (i != vb)
            if (b[i] >= pre_b)
                pre_b = b[i];
    }
    if (va == vb) {
        if (ans_a > ans_b)
            ans_b = pre_b;
        else if (ans_a < ans_b)
            ans_a = pre_a;
        else {
            if (pre_a > pre_b){
                ans_a = pre_a;
            }
            else ans_b = pre_b;
        }
    }
    cout << n - ans_a - ans_b;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    int ans = 0;
    int pre = 0;
    for(int num: arr) {
        if (num > pre)
            ans += num - pre;
        pre = num;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef vector<int> vi;

const int mod = 1e9 + 7;
int n;
vi adj[100005];
int dp[100005][2];

int mul(int &a, int b){
	a %= mod; b %= mod;
	a *= b;
	a %= mod;
	return a;
}

int dfs(int u, int prev){
//	cout << u << ' ' << prev<<'\n';
	dp[u][0] = dp[u][1] = 1;
	for (int v : adj[u]){
		if (v == prev) continue;
		dfs(v,u);
		mul(dp[u][0], (dp[v][0] + dp[v][1])%mod);
		mul(dp[u][1], dp[v][0]);
	}
	return dp[u][0] + dp[u][1];
}
void solve(){
	cout << (dfs(1,0)%mod) << '\n';
}

int32_t main(){
	cin >> n;
	for (int i = 1, u, v; i < n; i++){
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	solve();
	return 0;
}


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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main()
{
  int N, M;

  cin >> N >> M;

  if( abs(N - M) >= 2 ) cout << 0 << endl;
  else {
    int ans = 1;
    Rep(i, N) {
      ans *= N - i;
      ans %= 1000000007;
    }
    Rep(i, M) {
      ans *= M - i;
      ans %= 1000000007;
    }

    if( N == M ) cout << ans * 2 % 1000000007 << endl;
    else cout << ans << endl;
  }
}


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


int main() {
    int n; cin >> n;
    vector<int> table(n);
    for (int i = 1; i <= n; ++i) {
        int a; cin >> a;
        table[a - 1] = i;
    }
    for (const auto& item : table)
        cout << item << " ";
    cout << endl;
}

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

int main(){
    int x, y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        if(2*i+4*(x-i)==y){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    bool ok = true;
    for(int i = 0; i < s.size(); i += 2)
    {
        if(s[i] == 'L') ok = false;
    }
    for(int i = 1; i < s.size(); i += 2)
    {
        if(s[i] == 'R') ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}



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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var a = new int[n + 1];
            for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
            var b = getArray(a);
            getAns(b, m);
        }
    }
    static void getAns(int[] a, int m)
    {
        var ans = 0;
        var aL = a.Length;
        for (int i = 0; i < aL; i++)
        {
            if (a[i] > m) break;
            var w = BS(a, m, a[i]);
            if (w != -1) ans = Max(ans, w + a[i]);
            else break;
        }
        Console.WriteLine(ans);
    }
    static int BS(int[] a, int m, int t)
    {
        var aL = a.Length;
        if (a[aL - 1] + t <= m) return  a[aL - 1];
        if (t == m) return 0;
        if (t > m) return -1;
        var ok = 0; var ng = aL - 1;
        while (ng - ok > 1)
        {
            var mid = ok + (ng - ok) / 2;
            if (a[mid] + t <= m) ok = mid;
            else ng = mid;
        }
        return a[ok];
    }
    static int[] getArray(int[] a)
    {
        var aL = a.Length;
        var hs = new HashSet<int>();
        for (int i = 0; i < aL; i++)
            for (int j = 0; j < aL; j++)
                hs.Add(a[i] + a[j]);
        return hs.OrderBy(x => x).ToArray();
    }
}



Measured memory_bytes: 49572
#include<iostream>
#include<set>
using namespace std;
int main(){
  int n;
  set<int>s;
  cin>>n;
  for(int i=0;i<n;i++){
    int te;
    cin>>te;
    s.insert(te);
  }
  int l = s.size();
  if(l==n)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define vint vector<signed>
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define yn(a) cout<<((a)?"Yes":"No")<<endl;
#define YN(a) cout<<((a)?"YES":"NO")<<endl;
#define call(a) for(auto i:(a))cout<<i<<" ";cout<<endl;

signed main(){
  int n=3;
  vint a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int res=0,dif=a[1]-a[0];
  res=dif/2+(a[2]-a[1]);
  if(dif%2!=0)res+=2;
  cout<<res;
  


  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans =  A > 12 ? B : A > 5 ? B / 2 : 0;
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <math.h>
using namespace std;

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

  int ans = 0;
  int answer = 0;
  for(int i=1; i<=n; i++){
  	for(int j=1; j<=i; j++){
  		if(i % j == 0){
  			ans += 1;
  		}
 	 }
 	 if(ans == 8){
 	 	answer += 1;
 	 }
 	 i++;
         ans = 0;
  }



  cout << answer << '\n';

  return 0;
}






Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("YES") if fl else print("NO")
import collections
import math
import itertools
import heapq as hq
n = ni()
P = lma()
cnt = 0
for i in range(n):
    if P[i] != i+1:
        cnt+=1
f = False
if cnt==2 or cnt==0:
    f=True
yn(f)


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n;
ll a[100005], b[100005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
    cin >> n;
    FOR(i, n) cin >> a[i];
    FOR(i, n) cin >> b[i];
    ll sum = 0;
    vector<ll> v;
    FOR(i, n) {
        if (a[i] < b[i]) sum += b[i] - a[i];
        else {
            v.push_back(a[i]-b[i]);
        }
    }
    sort(v.rbegin(), v.rend());
    int cnt;
    for (cnt = 0; cnt < v.size() && sum > 0; cnt++) {
        sum -= v[cnt];
    }
    if (sum <= 0) cout << cnt+n-v.size() << endl;
    else cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

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

int main(int argc, char *argv[])
{
    int a, b, c;
    std::cin >> a >> b >> c;

    if (a == b+c || b == c+a || c == a+b) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>

using namespace std;
int main()
{
   int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
        cout<<k;
    }
    else if(k<=a+b)
    {
        cout<<a;
    }
    else
    {
        cout<<2*a+b-k<<endl;
    }
    cout<<endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3624
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

N = int(readline())
info = []
for i in range(N):
    A = int(readline())
    for _ in range(A):
        x,y = map(int,readline().split())
        info.append((i,x-1,y))
        
A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)
for i,x,y in info:
    bl = (~A[:,i]) | (A[:,x] == bool(y))
    A = A[bl]

answer = A.sum(axis = 1).max()
print(answer)


Measured memory_bytes: 18440
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  using pii = pair<int, int>;
  Cin(int, n, t);
  vector<pii> vp(n);
  for (auto& e : vp) {
    Cin(int, fir, sec);
    e = {fir, sec};
  }
  sort(all(vp), [](pii a, pii b) { return a.first < b.first; });

  for (auto e : vp) {
    if (e.second > t)
      continue;
    else {
      cout << e.first << endl;
      return;
    }
  }

  puts("TLE");
  return;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  ll N;

  cin >> N;

  vector<P> lst;

#ifdef DEBUG
  cout << "N=" << N << endl;
#endif

  map<ll, ll> dict;
  ll key;
  ll val;
  for(int i = 0; i < N; ++i){
    cin >> val >> key;
    if(dict.count(key) == 0){
      dict[key] = val;
    } else {
      dict[key] += val;
    }
  }

  vector<P> vec;
  for(auto i = dict.begin(); i != dict.end(); i++){
    //for(const auto& [key, val] : dict ){
    //cout << "key=" << key << ", value=" << val << endl;
    //cout << "key=" << i->first << ", value=" << i->second << endl;
    vec.emplace_back(P(i->first, i->second));
  }
  sort(vec.begin(), vec.end());
  
  string res = "Yes";
  ll margin = 0;
  ll prekey = 0;
  for(auto x:vec){
    //cout << "key=" << x.fs << ", value=" << x.sc << ", margin=" << margin << endl;
    if(x.sc > (x.fs - prekey + margin)){
      res = "No";
      break;
    }
    margin = x.fs - prekey + margin - x.sc;
    prekey = x.fs;
  }

  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = false;
    for(int i = 0; i < n-1; i++){
        if(s[i] == 'A' && s[i+1] == 'C') flag = true;
    }    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())

a = []
c = []

for i in range(n):
    a.append(list(map(int, input().split())))
    c.append(a[i][0])
    del a[i][0]

INF = 100000000

ans = INF

for i in range(1 << n):
    cost = 0
    d = [0] * m
    for j in range(n):
        if i >> j & 1:
            cost += c[j]
            for k in range(m):
                d[k] += a[j][k]
    ok = True
    for j in range(m):
        if d[j] < x:
            ok = False
    if ok:
        ans = min(ans, cost)
if ans == INF:
    print(-1)
else:
    print(ans)



Measured memory_bytes: 9160
#include<stdio.h>
#include<string.h>
 
int main(){
    char str[1001];
    char order[32];
    char p[1001];
    int a,b;
    int q,loop;
    int i,j;
     
    scanf("%s",str);
    scanf("%d",&q);
    for(loop=1;loop<=q;loop++){
        scanf("%s %d %d",order,&a,&b);
        if(strcmp(order,"print")==0){
            for(i=a;i<=b;i++){
                printf("%c",str[i]);
            }
            printf("\n");
        }
        else if(strcmp(order,"reverse")==0){
            j=0;
            for(i=a;i<=b;i++){
                p[j]=str[b-j];
                j++;
            }
            j=0;
            for(i=a;i<=b;i++){
                str[i]=p[j];
                j++;
            }
        }
        else{
            scanf("%s",p);
            j=0;
            for(i=a;i<=b;i++){
                str[i]=p[j];
                j++;
            }
        }
    }
     
    return 0;
}

Measured memory_bytes: 576
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

char s[2][N];

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out1.txt","w",stdout);
#endif
    int n;
    scanf("%d",&n);
    scanf("%s%s",s[0],s[1]);
    LL ans = 0;
    int m = 0;
    bool pre = 0;
    if( s[0][0] == s[1][0] ){
        ans = 3;
        m = 1;
        pre = 1;
    }else{
        ans = 6;
        m = 2;
        pre = 0;
    }
    while( m < n ){
        if( s[0][m] == s[1][m] ){
            m++;
            if( pre ){
                ans = ans*2%mz;
            }else{
                pre = 1;
            }
        }else{
            m+=2;
            if( pre ){
                ans = ans*2%mz;
                pre = 0;
            }else{
                ans = ans*3%mz;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int A,B;
  scanf("%d %d",&A,&B);
  if(A>=B+1)
  	printf("%d",2*A-1);
  else if(A==B)
    printf("%d",2*A);
  else
    printf("%d",2*B-1);
  return 0;
}


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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define debug(x) cerr << #x << " == " << (x) << '\n';

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;


const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

ll modpow(ll a, ll p, ll m)
{
    if (p == 0)
        return 1;
    if (p == 1)
        return a % m;

    ll r = modpow(a, p / 2, m);
    return ((r * r % m) * (p % 2 ? a : 1)) % m;
}

int main()
{
    ll X, Y; cin >> X >> Y;

    ll mod = 1e9 + 7;

    vector<ll> f(X + 1); f[0] = 1;
    vector<ll> inv(X + 1); inv[0] = 1;
    for (ll i = 1; i <= X; ++i)
    {
        f[i] = i * f[i - 1] % mod;
        inv[i] = modpow(f[i], mod - 2, mod);
    }


    ll sum = 0;

    for (ll i = 0; i <= X; ++i)
    {
        if ((X - i) % 2 == 0 && Y == 2 * i + (X - i) / 2)
        {
            ll diff = f[i + (X - i) / 2] * inv[i] % mod;
            diff = diff * inv[(X - i) / 2] % mod;
            sum = (sum + diff) % mod;
        }
    }

    cout << sum << endl;

    exit(0);
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
const double PI =acos(-1);
double a2(double a,double b){
   return atan2(a,b) *180/PI;
}
int main() {
  ll n,k;
  cin>> n >> k;
  vector<ll> a(n),f(n);
  rep(i,n)
   cin>>a[i];
  rep(i,n)
   cin>>f[i];
  sort(a.begin(),a.end(),greater<ll>());
  sort(f.begin(),f.end());
  
  ll l=0,r=1e12+1,mid,sum,ans;
  while(l<=r){
     mid=(l+r)/2;
     sum=k;
     // (a-k)*f=ans; k=a-ans/f;
     rep(i,n){
        if(mid/f[i]<a[i])
          sum-=a[i]-mid/f[i];
     }
     if(sum<0){
        l=mid+1; 
     }else{
        ans=mid;
        r=mid-1; 
     }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3328
function Main(input) {
	var lines = input.split("\n");
	var parsed = lines[0].split(" ").map(function(v,i,a){return parseInt(v,16);});
    var x = parsed[0], y = parsed[1];
	console.log(x > y ? '>' : x < y ? '<' : '=');
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, a[114514], res;
map<int,int> p;

signed main() {
	cin >> n >> m;
	rep(i,n) {
		cin >> a[i];
		if (i) a[i] += a[i-1];
		p[a[i]%m]++;
	}
	p[0]++;
	each(i,p) res += i.se*(i.se-1)/2;
	cout << res << ln;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n,m;
    cin>>n>>m;
    vector <int> a(n);
    int tot=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        tot+=a[i];
    }
    int c=0;
    for(int x:a){
        if(x*4*m>=tot)
            c++;
    }
    if(c>=m)
        cout<<"Yes";
    else
        cout<<"No";
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */

int main(){
    string S, T;
    cin >> S >> T;
    map<char, int> a;
    a['a'] = 0;
    int count = 1;
    for(int i = 0;i < S.size();++i){
        if(a[T[i]] == 0){
            a[T[i]] = count;
            ++count;
        }
        T[i] = a[T[i]] + '0';
    }
    map<char, int> b;
    count = 1;
    for(int i = 0;i < S.size();++i){
        if(b[S[i]] == 0){
            b[S[i]] = count;
            ++count;
        }
        S[i] = b[S[i]] + '0';
        if(S[i] != T[i]){
            cout << "No" << endl;return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define INF 1e9
#define LINF 1e18
#define ld double
#define ll long long
#define ull unsigned long long

template <typename T> void read(T &x) {
	x = 0; int f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c);c = getchar()) x = (x<<3) + (x<<1) + (c^48);
	x *= f;
}

const int N = 2005;
int n, a[N];
bool used[N], canuse[N];
ull g[N][N], vis[N];
int que[N], lb, rb;

int bfs(int s) {
	lb = rb = 0;
	que[rb ++] = s;
	vis[s >> 6] |= 1ull << (s & 63);
	int mn = n;
	while (lb < rb) {
		int u = que[lb ++];
		if (canuse[u] && u < mn) mn = u;
		for (int i = 0; (i << 6) < n; ++ i) {
			if ((g[u][i] & vis[i]) != g[u][i]) {
				for (int j = i << 6; j < ((i + 1) << 6); ++ j) {
					if (g[u][i] & 1ull << (j & 63)) {
						if (!(vis[i] & 1ull << (j & 63))) {
							vis[i] |= 1ull << (j & 63);
							que[rb ++] = j;
						}
					}
				}
			}
		}
	}
//	for (int i = 0; i < lb; ++ i) fprintf(stderr, " %d", que[i]);
//	fprintf(stderr, " |");
	return mn;
}

void print() {
	memset(vis, 0, sizeof vis);
	for (int i = 0; i < n; ++ i) if (used[i]) vis[i >> 6] |= 1ull << (i & 63);
	int mx = 0;
	for (int i = 0; i < n; ++ i) if (!(vis[i >> 6] & 1ull << (i & 63))) {
		int cur = bfs(i);
		if (cur != n) mx = max(mx, cur);
	}
//	fprintf(stderr, "\n");
	printf("%d", a[mx]);
	used[mx] = 1;
	for (int i = 0; i < n; ++ i) if (!used[i]) {
		if (g[mx][i >> 6] & 1ull << (i & 63)) canuse[i] = 1;
		else { if (a[i] > a[mx]) canuse[i] = 0; }
	}
}

int main() {
	read(n);
	for (int i = 0; i < n; ++ i) read(a[i]);
	sort(a, a + n);
	for (int i = 0; i < n; ++ i) for (int j = 0; j < n; ++ j) if (i != j && __gcd(a[i], a[j]) != 1) g[i][j >> 6] |= 1ull << (j & 63);
	for (int i = 0; i < n; ++ i) canuse[i] = 1;
	for (int i = 0; i < n; ++ i) {
		print();
		putchar(" \n"[i + 1 == n]);
	}
	return 0;
}

Measured memory_bytes: 29696
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T, class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<char c = ' ',class T> void write(T a){cout << fixed << setprecision(4) << a << endl;}
template<char c = ' ',class T,class ...Args> void write(T a, Args... args){cout << fixed << setprecision(4) << a << c; write<c>(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ull gcd(ull a, ull b){while(true){ull k = a % b;if(k == 0)return b;a = b;b = k;}}
ull comb(ull n, ull m){ull p=1;m=min(m,n-m);for(ull i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    int dp[5][100]={0};
    dp[0][0]=1;
    rep(i,4){
        rep(j,10){
            rrep(k,55){
                dp[i+1][k+j]+=dp[i][k];
            }
        }
    }
    while(!cin.eof()){
        string n;
        cin>>n;
        if(n=="")break;
        write(dp[4][atoi(n.c_str())]);
    }
    return 0;
}

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

int N,M,A[100010];

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < M; i++)scanf("%d",A + i);
    int cnt = 0;
    for(int i = 0; i < M; i++)if(A[i] % 2)cnt++;
    if(cnt > 2)
    {
        printf("Impossible\n");
        return 0;
    }
    if(N == 1)
    {
        printf("1\n");
        printf("1\n");
        printf("1\n");
    }
    else if(M == 1)
    {
        printf("%d\n",A[0]);
        printf("2\n");
        printf("%d %d\n",A[0] - 1,1);
    }
    else if(M == 2)
    {
        printf("%d %d\n",A[0],A[1]);
        printf("%d\n",2 - (A[0] == 1));
        if(A[0] != 1)printf("%d ",A[0] - 1);
        printf("%d\n",A[1] + 1);
    }
    else
    {
        bool F = true;
        for(int i = 0; i < M; i++)
        {
            if(A[i] % 2)
            {
                if(F)
                {
                    swap(A[i],A[0]);
                    F = false;
                }
                else swap(A[i],A[M - 1]);
            }
        }
        for(int i = 0; i < M; i++)
        {
            printf("%d",A[i]);
            if(i != M - 1)printf(" ");
        }
        printf("\n");
        printf("%d\n",M - (A[0] == 1));
        if(A[0] != 1)printf("%d ",A[0] - 1);
        for(int i = 1; i < M - 1; i++)
            printf("%d ",A[i]);
        printf("%d\n",A[M - 1] + 1);
    }
    return 0;
}


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

import collections
import math


class Vector2(collections.namedtuple("Vector2", ["x",  "y"])):

    def __add__(self, other):
        return Vector2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector2(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):  # cross product
        return Vector2(self.x * scalar, self.y * scalar)

    def __neg__(self):
        return Vector2(-self.x, -self.y)

    def __pos__(self):
        return Vector2(+self.x, +self.y)

    def __abs__(self):  # norm
        return math.sqrt(float(self.x * self.x + self.y * self.y))

    def dot(self, other):  # dot product
        return self.x * other.x + self.y * other.y

    def cross(self, other):  # cross product
        return self.x * other.y - self.y * other.x


if __name__ == '__main__':

    a, b, c, d = map(int, input().split())
    p1 = Vector2(a, b)
    p2 = Vector2(c, d)
    base = p2 - p1
    q = int(input())

    for _ in range(q):
        e, f = map(int, input().split())
        hypo = Vector2(e - a, f - b)
        x = p1 + base * (hypo.dot(base) / abs(base)**2)

        print(x.x, x.y)



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

using namespace std;
  
int main() {
  int n, s;
  cin >> n >> s;
  int arr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  long long ans(0);
  vector<long long> dp(s + 1);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    long long t(dp[s]);
    for (int j = s; j >= 0; --j) {
      if ((dp[j] || j == 0) && j + arr[i] <= s) {
        if (j == 0) {
          dp[arr[i]] += i + 1;
        } else {
          dp[j + arr[i]] += dp[j];
        }
        dp[j + arr[i]] %= 998244353;
      }
      
    }
    ans += ((dp[s] + 998244353 - t) * (n - i)) % 998244353;
      ans %= 998244353;
  }
  
  cout << ans << '\n';
  return 0;
}

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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(b);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1e9+7;

ll add_up(string &s,ll r,ll l){
	string t = s.substr(r,l-r);
	ll n = 0;
	for(int i=0;i<t.length();i++){
		n = 10*n + t[i]-'0';
	}
	//cout<<n<<"\n";
	return n;
}

void solve(){
	string s;
	cin>>s;
	ll n = s.length();
	ll up = pow(2,n-1)-1;
	if(n==1){
		cout<<s;
		return;
	}
	ll sum=0;
	ll r,l;
	rep(i,0,up){
		r=n-1;l=n;
		rep(j,0,n-1){
			if(chkbit(i,j)){
				//cout<<i<<" "<<r<<" "<<l<<" ";
				sum += add_up(s,r,l);
				l = r;
				r--;
			} else {
				r--;
			}
			if(r==0){
				//cout<<i<<" "<<r<<" "<<l<<" ";
				sum += add_up(s,r,l);
			}
		}
	}
	cout<<sum<<"\n";
}


int main(){
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}	
}
/*input
5
9999999999
125
*/

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

#define N_MAX 100005

using namespace std;

int X;

long long pow5(long long X)
{
    return X * X * X * X * X;
}

long long is5thPow(long long C)
{
    int sgn = 1;
    if(C < 0) {
        C *= -1;
        sgn = -1;
    }

    int x = pow(C, 1 / 5.);

    for(int add = -1; add <= 1; add++) {
        if(pow5(x + add) == C) {
            return sgn * (x + add);
        }
    }

    return LLONG_MAX;
}

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

    int B = 0;
    while(1) {
        long long B5 = pow5(B);
        long long Ap = X + B5;
        long long Am = X - B5;

        long long ap = is5thPow(Ap);
        long long am = is5thPow(Am);

        if(ap != LLONG_MAX) {
            cout << ap << " " << B << "\n";
            return 0;
        }

        if(am != LLONG_MAX) {
            cout << am << " " << -B << "\n";
            return 0;
        }
        B++;
    }
    return 0;
}


Measured memory_bytes: 4020
N = int(input())
A = sorted(list(map(int, input().split())))

n = A[-1]
r_val = -float('inf')
r_row = None
for idx in range(N - 1):
    if r_val < min(n - A[idx], A[idx]):
        r_val = min(n - A[idx], A[idx])
        r_row = A[idx]
print(n, r_row)


Measured memory_bytes: 14052
package main

import "fmt"
import "strings"

func main() {
	var ia, ib, ic string
	fmt.Scan(&ia)
	fmt.Scan(&ib)
	fmt.Scan(&ic)

	sa := strings.Split(ia, "")
	sb := strings.Split(ib, "")
	sc := strings.Split(ic, "")

	turn := "a"
	for {
		switch turn {
		case "a":
			l := len(sa)
			if l > 0 {
				turn = sa[0]
				sa = sa[1:l]
			} else {
				fmt.Println("A")
				return
			}
		case "b":
			l := len(sb)
			if l > 0 {
				turn = sb[0]
				sb = sb[1:l]
			} else {
				fmt.Println("B")
				return
			}
		case "c":
			l := len(sc)
			if l > 0 {
				turn = sc[0]
				sc = sc[1:l]
			} else {
				fmt.Println("C")
				return
			}
		}
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
ll mod=1000000007;
typedef pair<int, int> P;

ll N,K;
vector<P> small, big;

void print(vector<P> v){
    for(int i=0; i<v.size(); i++){
        cout << v[i].first;
    }
}

int main()
{
    //-1が1のタイルより左下にあれば良い
    cin >> N;
    for(int i=0; i<N; i++){
        int a,b;
        cin >> a >> b;
        small.push_back(P(a,b));
    }
    for(int i=0; i<N; i++){
        int a,b;
        cin >> a >> b;
        big.push_back(P(a,b));
    }
    sort(small.begin(), small.end());
    sort(big.begin(), big.end());
    int ans=0;
    for(auto M: big){
        P tmp=P(-1, -1);//firstがy座標、secondが位置
        int cnt=0;
        for(auto m: small){
            if(M.first<=m.first) break;
            
            if(M.second>m.second && tmp.first < m.second){
                tmp=P(m.second, cnt);
            }
            cnt++;
        }
        if(tmp.second!=-1){
            small.erase(small.begin()+tmp.second);
            ans++;
        }
    }
   
    cout << ans << endl;
    
    

    return 0;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

ll oddSolve(ll a) {
  return (((a + 1) / 2) % 2 == 0) ? 0 : 1;
}

ll sumXOR(ll a) {
  if (a % 2 == 1)
    return oddSolve(a);
  else
    return oddSolve(a + 1) ^ (a + 1);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A, B;
  cin >> A >> B;
  cout << (sumXOR(B) ^ sumXOR(A - 1)) << 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++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int H, A; cin >> H >> A;
    cout << H/A + (H%A != 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;



int32_t main(){

int n;cin>>n;
vi v(n),vv(n);for(int i=0;i<n;i++)cin>>v[i];
for(int i=0;i<n;i++)cin>>vv[i];
vi x(n);
iota(all(x),1);
int z=0;int zz=0;
int cnt=1;
while(next_permutation(all(x))){
   bool b=0;
   for(int i=0;i<n;i++){
        if(x[i]==v[i]){}else{ b=1;break;}
   }
   if(!b){z=cnt;break;}
   cnt+=1;
}
iota(all(x),1);
cnt=1;
while(next_permutation(all(x))){
   bool b=0;
   for(int i=0;i<n;i++){
        if(x[i]==vv[i]){}else{ b=1;break;}
   }
   if(!b){zz=cnt;break;}
   cnt+=1;
}
cout<<abs(z-zz)<<endl;

}

Measured memory_bytes: 256
N, L = map(int, input().split())
a = list(map(int, input().split()))
b = 0
c = 0
for i in range(N-1):
	if a[i] + a[i+1] >= L:
		print("Possible")
		b = 1
		c = i
		break
else:
	print("Impossible")
if b == 1:
	for i in range(1,c+1):
		print(i)
	for i in range(N-1, c, -1):
		print(i)

Measured memory_bytes: 14148
program bm
implicit none
integer::A,B,C,D
read*,A,B,C,D
do
    C=C-B
    if(C<=0)then
        print"(A)","Yes"
        stop
    endif
    A=A-D
    if(A<=0)then
        print"(A)","No"
        stop
    endif
end do

contains
end program bm

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

struct BinaryIndexedTree {
private:
    int n,b;
    vector<int> bit;
public:
    BinaryIndexedTree(int n_) {
        n = n_+10;
        b = 1;
        while (b < n) b <<= 1;
        b >>= 1;
        bit = vector<int>(n,0);
    }

    void add(int a,int w) {
        a++;
        for (int x = a;x < n;x += x&-x) bit[x] += w;
    }

    int sum(int a) {
        a++;
        int ret = 0;
        for (int x = a;x > 0;x -= x&-x) ret += bit[x];
        return ret;
    }

    void update(int a,int w) {
        // a++;
        int v = w-sum(a)+sum(a-1);
        add(a,v);
    }

    int lower_bound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int k = b;k > 0;k /= 2) {
            if (x+k < n && bit[x+k] < w) {
                w -= bit[x+k];
                x += k;
            }
        }
        return x;
    }
};

struct query {
    int l,r,i;
    bool operator<(const query& a) const {
        return r < a.r;
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    vector<int> c(n);
    BinaryIndexedTree bit(n);
    vector<query> a(q);
    vector<int> ans(q),b(n,-1);
    for (int i = 0;i < n;++i) {scanf("%d",&c[i]);c[i]--;}
    for (int i = 0;i < q;++i) {
        scanf("%d%d",&a[i].l,&a[i].r);
        a[i].i = i;
    }
    sort(a.begin(),a.end());
    int j = 0;
    for (int i = 0;i < n;++i) {
        if (b[c[i]] >= 0) bit.add(b[c[i]],-1);
        bit.add(i+1,1);
        b[c[i]] = i+1;
        while (j < q && a[j].r <= i+1) {
            ans[a[j].i] = bit.sum(a[j].r)-bit.sum(a[j].l-1);
            j++;
        }
    }
    for (int i = 0;i < q;++i) cout << ans[i] << newl;
}


Measured memory_bytes: 17364