akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cout << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 1000000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;

int ara[5][4][11];
int b,f,r,v;



int main() {
    //read,write;
    int n,x;
    while(1){
        int cnt=0;
        cin >> n >> x;
        if(n==0 && x==0) break;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x){
                        cnt++;
                        //cout << i << j << k << "-----" << endl;  
                    } 
                }
            }
        }
        cout << cnt << endl;
    }
 


    return 0;
}



Measured memory_bytes: 3104
N = int(input())
A = list(map(int, input().split()))
L = {}

count = 0

for i in range(N):
    l = i + A[i]
    r = i - A[i]
    if r in L.keys():
        count += L[r]
    if l in L.keys():
        L[l] += 1
    else:
        L[l] = 1
print(count)

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

int n, k;
string s;

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

	if (s.at(k-1)=='A')
	{
		s.at(k-1) = 'a';
	}

	if (s.at(k-1)=='B')
	{
		s.at(k-1) = 'b';
	}

	if (s.at(k-1)=='C')
	{
		s.at(k-1) = 'c';
	}

	cout << s << endl;
}

Measured memory_bytes: 256
import heapq

N,M = list(map(int, input().split()))

rewards_list_vs_days = [[] for _ in range(M+1)]
for _ in range(N):
    days,reward = list(map(int, input().split()))
    if days <= M:
        rewards_list_vs_days[days].append(reward)

#print(rewards_list_vs_days)

minus_rewards_of_available_jobs = []

total_reward = 0

for day in reversed(list(range(M))):
    rest_days = M-day
    for reward in rewards_list_vs_days[rest_days]:
        heapq.heappush(minus_rewards_of_available_jobs, -reward)
    if len(minus_rewards_of_available_jobs) > 0:
        max_reward = - heapq.heappop(minus_rewards_of_available_jobs)
        total_reward += max_reward
    
print(total_reward)


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

int par[100005];
ll rank_[100005];
void init(int n){
  for(int i=0; i<n; i++){
    par[i] = i;
    rank_[i] = 1;
  }
}

int find(int x){
  if(x==par[x]){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

ll unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x==y) return 0;
  ll tmp = rank_[x]*rank_[y];
  if(rank_[x]<rank_[y]){
    par[x]=y;
    rank_[y] += rank_[x];
    rank_[x] = rank_[y];
    return tmp;
  }else{
    par[y]=x;
    rank_[y] += rank_[x];
    rank_[x] = rank_[y];
    return tmp;
  }
}

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

 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = (a-c) * (b-d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3520
char buf[5],out[2<<17];
sz,outsz;
j;
N;
char fs[501]="01213121412131215121312141213121612131214121312151213121412131217121312141213121512131214121312161213121412131215121312141213121812131214121312151213121412131216121312141213121512131214121312171213121412131215121312141213121612131214121312151213121412131219121312141213121512131214121312161213121412131215121312141213121712131214121312151213121412131216121312141213121512131214121312181213121412131215121312141213121612131214121312151213121412131217121312141213121512131214121312161213121412131215121";
main(){
	read(0,buf,5);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;--N;)for(j=N;j--;)
	{
		out[outsz++]=fs[N-j];
		out[outsz++]='\n';
	}
	write(1,out,outsz);
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  char mp[h][w];
  int kazu = 0;
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      cin>>mp[i][j];
      if(mp[i][j]=='#')kazu++;
    }
  }
  if(kazu != h+w-1){
    cout << "Impossible" << endl;
    return 0;
  }
  int nwx = 0;
  int nwy = 0;
  while(true){
    if(mp[nwx+1][nwy]=='#')nwx++;
    else if(mp[nwx][nwy+1]=='#')nwy++;
    else{
      cout << "Impossible" << endl;
      return 0;
    }
    if(nwx+nwy==kazu-1)break;
  }
  cout << "Possible" << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int x,y;
    cin>>x>>y;
    string a,b;
    cin>>a>>b;
    int p=x,q=y;
    REP(i,n){
        if(a[i]=='D'){
            p++;
        }
        if(p>h){
            cout<<"NO"<<endl;
            return 0;
        }
        if(b[i]=='U'){
            if(p>1)p--;
        }
    }
    p=x;q=y;
    REP(i,n){
        if(a[i]=='U'){
            p--;
        }
        if(p<=0){
            cout<<"NO"<<endl;
            return 0;
        }
        if(b[i]=='D'){
            if(p<h)p++;
        }
    }
    p=x;q=y;
    REP(i,n){
        if(a[i]=='L'){
            q--;
        }
        if(q<=0){
            cout<<"NO"<<endl;
            return 0;
        }
        if(b[i]=='R'){
            if(q<w)q++;
        }
    }
    p=x;q=y;
    REP(i,n){
        if(a[i]=='R'){
            q++;
        }
        if(q>w){
            cout<<"NO"<<endl;
            return 0;
        }
        if(b[i]=='L'){
            if(q>1)q--;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 776
#!/usr/bin/env python3
import sys
from collections import defaultdict
sys.setrecursionlimit(10**8)

INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, src, dest, w=1):
        self.E[src].append((dest, w))
        self.E[dest].append((src, w))  # 無向グラフ


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    g = Graph(N)

    for a, b in zip(A, B):
        g.add_edge(a-1, b-1)

    cnt = 0
    for node in range(N):
        if all([H[child] < H[node] for child, w in g.E[node]]):
            cnt += 1
    print(cnt)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 104256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    if (a + b) % 2 == 1 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (a + b) / 2);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <ios>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <vector>
#include <array>
#include <bitset>
#include <cstring>
#include <string>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <chrono>
#include <random>
#include <iterator>
using namespace std;
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Rof(a, b, c) for(int a = b; a >= c; --a)
#define Fv(a, b) for(auto &a : b)
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define int long long
#define db double
#define bit(x, i) (x >> i & 1ll)
#define onbit(x, i) (x | (1ll << i))
#define offbit(x, i) (x & (~(1ll << i)))

const int N = 1e5 + 5;
int n, m, dd[N], h[N];
vector<int> ad[N], save;
int mdist;

int dfs(int i) {
    if(h[i] != -1) return h[i];
    h[i] = 0;
    Fv(v, ad[i]) {
        h[i] = max(h[i], 1 + dfs(v));
    }
    return h[i];
}

main() {
    cin >> n >> m;
    For(i, 1, m) {
        int u, v;
        cin >> u >> v;
        ad[u].pb(v);
    }
    int ans = 0;
    reset(h, -1);
    For(i, 1, n) {
        ans = max(ans, dfs(i));
    }
    cout << ans;
}


Measured memory_bytes: 7808
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int length = scan.nextInt();
		int min = 0, max = 0;
		BigDecimal sum = new BigDecimal(0);
		ArrayList<Integer> elems = new ArrayList<Integer>();
		for (int i = 0; i < length; i++) {
			int elem = scan.nextInt();
			elems.add(elem);
			sum = sum.add(new BigDecimal(elem));
		}
		scan.close();
		Collections.sort(elems);
		min = elems.get(0);
		max = elems.get(elems.size() - 1);
		System.out.println(min + " " + max + " " + sum);
	}
}

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



int main() {
  int k,q;
  cin>>k>>q;
  vector<ll> d(k),D(k);
  rep(i,k){
      cin>>d.at(i);
  }
  rep(i,q){
      ll n,x,m;
      cin>>n>>x>>m;
      ll ans=n-1;
      rep(j,k){
          D.at(j)=d.at(j)%m;
      }
      ll count0=0;
      rep(j,k){
          if(D.at(j)==0){count0++;}
      }
      count0*=(n-1)/k;
      rep(j,(n-1)%k){
          if(D.at(j)==0){count0++;}
      }
      ans-=count0;

      ll up=0;
      rep(j,k){
          up+=D.at(j);
      }
      up*=(n-1)/k;
      rep(j,(n-1)%k){
          up+=D.at(j);
      }
      up+=x%m;
      ans-=up/m;
      cout<<ans<<endl;
  }
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin >>n;
    vector<int> array;
    vector<int> p,q;

    rep(i,n)array.pb(i+1);
    rep(i,n){
        int pi;
        cin >>pi;
        p.pb(pi);
    }
    rep(i,n){
        int pi;
        cin >>pi;
        q.pb(pi);
    }

    if(p == q){
    puts("0");
    return 0;
    }

    int cnt=0,cnt1=0;
    do {
        cnt++;
        if(array == p || array == q){
            cnt1++;
            //db3(cnt,cnt1,ans);

            if(cnt1 == 2){
                ans = abs(ans - cnt);
                break;
            }
            ans = cnt;
        }
    } while(next_permutation(array.begin(), array.end()));

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    for(int i =0; i < 5; i++){
       int a; cin >> a;
       if(a == 0) cout << i+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int plag = 1;
    int count = 0;


    if(2 <= a && a <= 20 && 1<= b && b <= 20){

      for(int i = 1;i < 20;i++){

        if(plag >= b){
          break;
        }

        plag += a-1;
        count++;
      }


      System.out.println(count);
    }

  }

}


Measured memory_bytes: 23764
#include<stdio.h>
#include<string.h>
#define rep(i,n) for(i=0; i<n; i++)

int main(void){
	char s[11], t[11], u[11];
	int a, b, k;
	scanf("%s%s", s, t);
	scanf("%d%d", &a, &b);
	scanf("%s", u);
	if(strcmp(u,s) == 0){
		a--;
	}else{
		b--;
	}
	printf("%d %d", a, b);
	return 0;
}

Measured memory_bytes: 128
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	int a, b;
	cin >> a >> b;
	cout << a * b;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;
typedef pair<int,int> P;
string s;
int k;
int INF=1000000000;
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

int main(){
    int h,w;
    cin>>h>>w;
    char maze[h+1][w+1];
    int dis[h][w];
    int countw=0;
    rep(i,0,h){
        rep(j,0,w){
            cin>>maze[i][j];
            if(maze[i][j]=='.') countw++;
            dis[i][j]=INF;
        }
    }
    queue<pair<int,int> > que;
    que.push(make_pair(0,0));
    dis[0][0]=1;
    bool flag=false;
    while(!que.empty()){
        pair<int,int> p=que.front();que.pop();
        if(p.first==h-1&&p.second==w-1){
            flag=true;
            break;
        }
        for(int i=0;i<4;i++){
            int nh=p.first+dh[i];
            int nw=p.second+dw[i];
            if(nh<0||nh>=h||nw<0||nw>=w) continue;
            if(maze[nh][nw]=='#') continue;
            if(dis[nh][nw]!=INF) continue;
            que.push(make_pair(nh,nw));
            dis[nh][nw]=dis[p.first][p.second]+1;
        }
    }
    if(!flag){
        cout<<-1<<endl;
        return 0;
    }
    cout<<(countw-dis[h-1][w-1])<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[20], k;
bool ok(int n){
	int f = 1;
	while(n > 0){
		int t = n%10;
		rep(i,k)if(a[i] == t)f = 0;
		n /= 10;
	}
	return f;
}

signed main(){
	int n;
	scanf("%lld%lld", &n, &k);
	rep(i,k)scanf("%lld", &a[i]);
	rrep(i,100000){
		if(i >= n and ok(i)){
			printf("%lld\n", i);
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    int a, b;
    vector<int> v(101);
    while (1) {
        fill(v.begin(), v.end(), 0);
        while (1) {
            if (!(cin >> a >> b)) return 0;
            if ( ! a && ! b) break;
            v[a] ++;
            v[b] ++;
        }
        bool ok = true;
        if (v[1] % 2 == 0 || v[2] % 2 == 0) {
            ok = false;
        }
        for (int i=3; i<101; ++i) {
            if (v[i] % 2 != 0) {
                ok = false;
            }
        }
        cout << (ok ? "OK" : "NG") << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
li mpow(li x,li y)
{
  li ans=1;
  while(y)
  {
    if(y%2!=0)
    ans=((ans%mod)*(x%mod))%mod;
    y/=2;
    x=((x%mod)*(x%mod))%mod;
  }
  return ans;
}
int main()
{
fast_io
li n;
cin>>n;
cout<<n/2+n%2;
  return  0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int max = 0;
		int min = 0;


		if(a < b) {
			max = b;
			min = a;
		} else {
			max = a;
			min = b;
		}

		int resultMin = min - (n - max);

		if(resultMin < 0) {
			resultMin = 0;
		}


		System.out.println(min + " " + resultMin);

		sc.close();
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    ll N; double A, B, C, D, E; cin >> N >> A >> B >> C >> D >> E;
    cout << (ll)ceil(N / min(A, min(B, min(C, min(D, E))))) + 4 << endl;
    return 0;
}

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

int main(){
  int M, N, Q, L, R, p, q, ans;
  cin >> N >> M >> Q;
  
  int T[N+1][N+1] = {}, C[N+1][N+1] = {}, A[Q];
  
  for (int i = 0; i < M; i++){
    cin >> L >> R;
    T[L][R]++;
  }
  
  for (int i = 1; i < N+1; i++){
    for (int j = 1; j < N+1; j++){
      C[i][j] = C[i][j-1] + T[i][j];
    }
  }
  for (int i = 0; i < Q; i++){
    ans = 0;
    cin >> p >> q;
    for (int j = p; j < q+1; j++){
      ans += C[j][q] - C[j][p-1];
    }
  cout << ans << endl;
  }  
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	double t,a;
	cin>>n>>t>>a;
	double h[n+1];
	double minv=10000;
	int ans;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
		h[i]=t-h[i]*0.006;
		double cha=abs(h[i]-a);
		if(cha<minv)
		{
		   minv=cha;
		   ans=i;
	}
}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int H, W, d;
char grid[2][2] = {{'R', 'Y'},
                   {'G', 'B'}};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> H >> W >> d;
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            int x = i - j + H + W;
            int y = i + j + H + W;
            x /= d;
            y /= d;
            cout << grid[x & 1][y & 1];
        }
        cout << endl;
    }
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int size = s.size();
    int i;
    string c;
    if(s==t){
        cout << "Yes" << endl;
    }else{
        for(i=0;i<size;++i){
            c = s.at(size-1);
            s.insert(0,c);
            s.pop_back();
            if(s==t){
                cout << "Yes" << endl;
                break;
            }
        }
        if(i==size){
            cout << "No" << endl;
        }
    }
    return 0;
}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
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;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	map<ll ,ll> mp;
	ll n;
	cin>>n;
	bool f = true;
	rep(i, 0, n) {
		ll x;
		cin>>x;
		if(mp[x] == 1) f = false;
		mp[x] = 1;
	}
	if(f) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


int main()
{
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e5+7;

int main()
{
    FAST
    ll tc,i,j,k;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
       string s;
       cin>>s;
       ll sum=0;
       for(i=0; i<s.size(); i++)
       {
           ll val=s[i]-'0';
           sum+=val;
           sum%=9;
       }
       sum%=9;
       if(!sum)
        cout<<"Yes"<<"\n";
       else
        cout<<"No"<<"\n";

    }
    return 0;
}





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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  ll n = S.size();
  string t;
  for (ll i = 0; i < n; i++) {
    t = t + "x";
  }
  cout << t << endl;

  return 0;
}



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

using namespace std;

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

	int i, sum = 0;
	bool flag = false;
	size_t size = N;

	sort(A.begin(), A.end());

	for(i = 0; i < size - 1; i++) {
		if(A[i] == A[i + 1]) {
			if(i == size - 3) flag = true;
			i++;
		}
		else {
			sum++;
			if(i == size - 2) flag = true;
		}
	}
	if(flag) sum++;
	cout << sum << endl;
}


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

int main()
{
    char S;
    cin >> S;
    switch (S)
    {
    case 'S':
        cout << "Cloudy" << endl;
        break;
    case 'C':
        cout << "Rainy" << endl;
        break;
    case 'R':
        cout << "Sunny" << endl;
        break;

    default:
        break;
    }
    return 0;
}


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

static const long M = 1000000007;

long p[2000000];

void getp(){
    p[0] = 1;
    for(int i = 1; i <= 2000000; i++)
        p[i] = i * p[i - 1] % M;
    return;
}

long power(long n, long m){
    long ans = 1;
    if(m > 0){
        ans = power(n, m / 2);
        if(m % 2 == 0) ans = (ans * ans) % M;
        else ans = (((ans * ans) % M) * n) % M;
    }
    return ans;
}

int main(){
    long X, Y;
    cin >> X >> Y;
    if((X + Y) % 3 != 0) cout << 0 << endl;
    else{
        long d = (X + Y) / 3;
        if(X < d || Y < d) cout << 0 << endl;
        else{
            getp();
            cout << (((p[X + Y - 2 * d] * power(p[X - d], M - 2)) % M) * power(p[Y - d], M - 2)) % M << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 15872
N,Y = map(int,input().split())
def otoshidamaBomb():
    global N, Y
    for i in range(N + 1)[::-1]:
        # intXは1万円の枚数
        intX = i * 10000
        # 1万円だけだと、Y円を超える場合はコンテで減らす
        if intX > Y:
            continue

        # 総枚数 - 1万円の枚数　分ループ
        for j in range(N - i + 1)[::-1]:
            # intYは5千円の枚数
            intY = j * 5000
            # intZは千円の枚数
            intZ = (N - i - j) * 1000
            # 合計金額が一致したら出力
            if intX + intY + intZ == Y:
                return i, j, N - i - j

    # 全探索終了 == そんなものは無い
    return -1, -1, -1

x,y,z = otoshidamaBomb()
print("{0} {1} {2}".format(x, y, z))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  if (s == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const int MAXN = 1e5+2;
const int MAX = 1e9+5;
const int MOD = 1e9+7;

int main(){
	int n; cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		int x; cin >> x;
		if(i % 2 != 0)
			if(x % 2 != 0)
				++ans;
	}
	cout << ans << endl;

	return 0;
}	


Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, K;
    cin >> N >> K;
    VEC(int) P(N);
    READVEC(P);
    double sum = 0.0, ret = 0.0;
    FOR(i, 0, N) {
        sum += P[i];
        if (i < K - 1) {
            continue;
        }

        if (i >= K)
            sum -= P[i - K];

        ret = max(ret, 0.5 * (K + sum));
    }

    cout << fixed << setprecision(10) << ret << endl;
    return 0;
};

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!

COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0

EPS = 0.0000000001

class Point:
    
    global EPS
    
    def __init__(self, x = 0, y = 0):
        self.x = x
        self.y = y
        
        
    def __add__(a, b):
        s = a.x + b.x
        t = a.y + b.y
        return Point(s, t)
        
    def __sub__(a, b):
        s = a.x - b.x
        t = a.y - b.y
        return Point(s, t)
            
    def __mul__(self, a):
        s = a * self.x
        t = a * self.y
        return Point(s, t)
        
    def __truediv__(self, a):
        s = self.x / a
        t = self.y / a
        return Point(s, t)
            
            
            
            
    def norm(self):
        return self.x * self.x + self.y * self.y
        
    def abs(self):
        return self.norm() ** 0.5
            
    
            
            
    def __eq__(self, other):
        return abs(self.x - other.y) < self.EPS and abs(self.y - other.y) < self.EPS
            
            
            
    def dot(self, b):
        return self.x * b.x + self.y * b.y
        
    def cross(self, b):
        return self.x * b.y - self.y * b.x
    
    
class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2


def ccw(p0, p1, p2):
    a = p1-p0
    b = p2-p0
    
    if a.cross(b) > 0:
        return COUNTER_CLOCKWISE
    elif a.cross(b) <0:
        return CLOCKWISE
    elif a.dot(b) < 0:
        return ONLINE_BACK
    elif a.abs() < b.abs():
        return ONLINE_FRONT
    else:
        return ON_SEGMENT
        
        
nums=list(map(int,input().split()))
p1 = Point(nums[0], nums[1])
p2 = Point(nums[2], nums[3])
n = int(input())
for i in range(n):
    nums=list(map(int,input().split()))
    p = Point(nums[0], nums[1])
    result = ccw(p1, p2, p)
    if result == COUNTER_CLOCKWISE:
        print("COUNTER_CLOCKWISE")
    elif result == CLOCKWISE:
        print("CLOCKWISE")
    elif result == ONLINE_BACK:
        print("ONLINE_BACK")
    elif result == ONLINE_FRONT:
        print("ONLINE_FRONT")
    elif result == ON_SEGMENT:
        print("ON_SEGMENT")





Measured memory_bytes: 5720
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<40){
		a=40;
	}
	if(b<40){
		b=40;
	}
	if(c<40){
		c=40;
	}
	if(d<40){
		d=40;
	}
	if(e<40){
		e=40;
	}
	printf("%d\n",(a+b+c+d+e)/5);
	return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string s;
    bool flag = false;

    cin >> s;
    if(s[0] == s[1]){
        if(s[2] == s[3] && s[2] != s[0]){
            flag = true;
        }
    } else if(s[0] == s[2]){
        if(s[1] == s[3] && s[1] != s[0]){
            flag = true;
        }
    } else if(s[0] == s[3]){
        if(s[1] == s[2] && s[1] != s[0]){
            flag = true;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

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

using namespace std;

using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<ll> va(n);
  bool z = false;
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
    if (va[i] == 0) {
      z = true;
    }
  }

  if (z) {
    cout << 0 << '\n';
    return 0;
  }

  ll limit = pow(10, 18);
  ll ans = 1;
  for (int i = 0; i < n; ++i) {
    if (limit / ans < va[i]) {
      ans = -1;
      break;
    }

    ans *= va[i];
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 4004
#include <algorithm>
#include <cstdio>
#include <vector>
#define MOD 1000000007
typedef long long ll;
inline ll quick_pow(ll a, int n)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
std::vector<int> vec[200005], bel[200005];
int idx[200005], col[200005], w[200005], fa[200005], app[200005];
int getfa(int u)
{
	if (u == fa[u])
		return u;
	return fa[u] = getfa(fa[u]);
}
inline void unite(int u, int v)
{
	u = getfa(u);
	v = getfa(v);
	fa[u] = v;
}
int main()
{
	// freopen("AGC012-D.in", "r", stdin);
	int n, a, b, cnt = 0;
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", col + i, w + i);
		vec[--col[i]].push_back(i);
		fa[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		if (vec[i].size())
			idx[cnt++] = i;
		std::sort(vec[i].begin(), vec[i].end(), [&] (const int &x, const int &y)
		{
			return w[x] < w[y];
		});
		for (int j = 1; j < vec[i].size() && w[vec[i][0]] + w[vec[i][j]] <= a; j++)
			unite(vec[i][0], vec[i][j]);
	}
	std::sort(idx, idx + cnt, [&] (const int &x, const int &y)
	{
		return w[vec[x][0]] < w[vec[y][0]];
	});
	for (int i = 0; i < n; i++)
	{
		if (cnt)
		{
			int x = vec[idx[0]][0];
			if (col[i] != col[x] && w[i] + w[x] <= b)
				unite(i, x);
		}
		if (cnt >= 2)
		{
			int x = vec[idx[1]][0];
			if (col[i] != col[x] && w[i] + w[x] <= b)
				unite(i, x);
		}
	}
	ll ans = 1;
	for (int i = 0; i < n; i++)
	{
		bel[getfa(i)].push_back(i);
		ans = ans * bel[fa[i]].size() % MOD;
	}
	for (int i = 0; i < n; i++)
	{
		for (int x : bel[i])
			app[col[x]] = 0;
		for (int x : bel[i])
			ans = ans * quick_pow(++app[col[x]], MOD - 2) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 23296
#include <iostream>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <tuple>
using namespace std;

template <class T> void chmax(T &x, T y) {if(x<y) x=y;}
template <class T> void chmin(T &x, T y) {if(x>y) x=y;}

#include <string>
#include <cassert>

bool comp(char x,char y)
{
    if(x=='?' or y=='?') return true;
    return x==y;
}

using p32=pair<int,int>;

main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);

    string s[3]; cin>>s[0]>>s[1]>>s[2];
    const int offs=4040;
    bool dif[3][3][offs*3]={};
    for(int i=0; i<3; ++i)
    {
        for(int j=0; j<3; ++j)
        {
            auto &now=dif[i][j];
            for(int x=0; x<(int)s[i].size(); ++x)
            {
                for(int y=0; y<(int)s[j].size(); ++y)
                {
                    now[x-y+offs]|=!comp(s[i][x],s[j][y]);
                }
            }
        }
    }
  

    int ans=6000;
    for(int i=-offs; i<offs; ++i)
    {
        if(dif[0][1][i+offs]) continue;
        for(int j=-offs; j<offs; ++j)
        {
            if(!dif[0][2][j+offs] and (j-i+offs<0 or !dif[1][2][j-i+offs]))
            {
                int l=min({0,i,j});
                int r=max({(int)s[0].size(),i+(int)s[1].size(),j+(int)s[2].size()});
                chmin(ans, r-l);
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
using namespace std;
int main(void){
    int h, w;
    cin >> h >> w;
    
    vector<string> m(h);
    FOR(i, h) cin >> m[i];
    
    // h
    FOR(i, m.size()){
        bool f = true;
        FOR(j, w){
            if(m[i][j] == '#'){
                f = false;
                break;
            }
        }
        if(f){
            m.erase(m.begin() + i--);
        }
    }
    
    // w
    FOR(j, m[0].size()){
        bool f = true;
        FOR(i, m.size()){
            if(m[i][j] == '#'){
                f = false;
                break;
            }
        }
        if(f){
            FOR(i, m.size()) m[i].erase(m[i].begin() + j);
            j--;
        }
    }
    
    FOR(i, m.size()) cout << m[i] << "\n";
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> p(N);
    REP(i, N) cin >> p[i];


    int ans = 0;
    int cnt = 0;
    REP(i, N) {
        if (i+1 == p[i]) {
            cnt++;
        } else {
            if (cnt > 0) {
                if (cnt % 2 == 0) {
                    ans += cnt / 2;
                } else {
                    ans += (cnt + 1) / 2;
                }
            }
            cnt = 0;
        }
    }
    if (cnt > 0) {
        if (cnt % 2 == 0) {
            ans += cnt / 2;
        } else {
            ans += (cnt + 1) / 2;
        }
    }
    print(ans);

}

signed main() {
    solve();
}


Measured memory_bytes: 640
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
A,B = map(int,input().split())
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
print(A*B//gcd(A,B))

  

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

int main() {
    long long N, NN;
    cin >> N;
    NN = N;
    long long s = 0;
    while (NN){
        s += (NN % 10);
        NN /= 10;
    }
    if (N % s == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
#define kill _kill

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll btc = 30;
const ld eps = 1e-8;
const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(1e9 + 239);
const int MOD = 1e9 + 7;

//random
#ifdef ONPC
mt19937_64 rnd(239);
#else
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

//constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 19;
const int T = (1 << 18) + 239;
const int B = 500;
const int X = 210;

int n;
string s;
ll a[X];

ll func(ll x)
{
    for (ll i = 0; i < 63; i++)
        if ((x >> i) & 1LL)
            return i;
    return -1;
}

void solve()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cin >> s;
    vector<pair<ll, ll>> v;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == '1')
        {
            ll x = a[i];
            for (pair<ll, ll> t : v)
                if ((x >> t.first) & 1LL)
                    x ^= t.second;
            if (x != 0)
            {
                cout << "1\n";
                return;
            }
        }
        else
        {
            ll x = a[i];
            for (pair<ll, ll> t : v)
                if ((x >> t.first) & 1LL)
                    x ^= t.second;
            if (x == 0)
                continue;
            ll s = func(x);
            for (pair<ll, ll>& t : v)
                if ((t.second >> s) & 1LL)
                    t.second ^= x;
            v.push_back(make_pair(s, x));
        }
    }
    cout << "0\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
vector<int>g[110000];
int dist[110000];
int ans;
int dfs(int a,int b){
	int rem=0;
	for(int i=0;i<g[a].size();i++){
		if(g[a][i]==b)continue;
		int q=dfs(g[a][i],a);
		rem+=q;
	}
	if(rem>1)ans=1;
	if(rem==1)return 0;
	return 1;
}
int main(){
	int a;scanf("%d",&a);
	if(a==2){
		printf("Second\n");return 0;
	}
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	int t=0;
	for(int i=0;i<a;i++)if(g[i].size()>1)t=i;
	dfs(t,-1);
	if(ans)printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

using Pi = pair<int, int>;

int N;
vector<int>L, R;

int main()
{
	int C = 1000000000;
	cin >> N;
	L = vector<int>(N);
	R = vector<int>(N);
	
	auto Q = vector<Pi>(0);


	for (int i = 0; i < N; i++) {
		cin >> L[i];
		cin >> R[i];

		Q.push_back(make_pair(L[i],R[i]));
	}

	sort(Q.begin(), Q.end(), [](Pi const& l, Pi const& r) {
		if (l.first == r.first) {
			return l.second > r.second;
		}
		return l.first < r.first;
		});

	vector<int> rmin_ary(N);
	rmin_ary[0] = Q[0].second;
	for (int i = 1; i < N; i++) {
		rmin_ary[i] = min(rmin_ary[i-1],Q[i].second);
	}

	int ans = 0;

	int opp_r = C;
	int opp_l = 0;
	for (int i = N-1; i > 0; i--) {
		opp_r = min(opp_r,Q[i].second);
		opp_l = max(opp_l,Q[i].first);

		int fun1 = max(0,opp_r - opp_l + 1) + max(0,rmin_ary[i - 1] - Q[i - 1].first + 1);
		int fun2 = max(0, min(opp_r,rmin_ary[i - 1]) - opp_l + 1) + max(0, Q[i - 1].second - Q[i - 1].first + 1);
		int fun = max(fun1,fun2);
		ans = max(ans, fun);

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

int main(){
	double h;
	while(cin >> h){
		if(h <= 48.0) cout << "light fly" << endl;
		else if(h <= 51.0) cout << "fly" << endl;
		else if(h <= 54.0) cout << "bantam" << endl;
		else if(h <= 57.0) cout << "feather" << endl;
		else if(h <= 60.0) cout << "light" << endl;
		else if(h <= 64.0) cout << "light welter" << endl;
		else if(h <= 69.0) cout << "welter" << endl;
		else if(h <= 75.0) cout << "light middle" << endl;
		else if(h <= 81.0) cout << "middle" << endl;
		else if(h <= 91.0) cout << "light heavy" << endl;
		else cout << "heavy" << endl;
	}
}

Measured memory_bytes: 1220