akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
using namespace std;

int main(){
    set<char>chrs;
    int N;cin>>N;
    for(int i=0;i<N;i++){
        char c;cin>>c;
        chrs.insert(c);
    }
    
    cout<<(chrs.size() == 3? "Three" : "Four")<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,box1,box2,minv,maxv,i,j;
	scanf("%d",&n);
	scanf("%d",&box1);
	scanf("%d",&box2);
	if(box1<box2) minv=box1;//初期値設定
	else minv=box2;
	maxv=box2-box1;
	for(i=1;i<n-1;i++){
		scanf("%d",&box1);
		if(maxv<box1-minv) maxv=box1-minv;//iまでの最大の差を保存
		if(minv>box1) minv=box1;//iまでの最小値を保存
	}
	
	printf("%d\n",maxv);
	return 0;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pie 3.141592653589793
#define fi first
#define se second
using namespace std ;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define MAXN   1000001 
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
int getFactorization(int x) 
{ 
    vector<int> ret;
  	vll tem; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        lli c=0;
        lli lol=spf[x];
        while(x%lol==0){
         	x = x / lol;
        	c++;
    	}
    	tem.pb(c);

    } 
    lli rett=1;
    for(auto te:tem)rett*=(te+1);
    return rett; 
} 
void solve()
{
	sieve();
	lli n;
	cin>>n;
	lli tem[n];
	lli ani=0;
	for(lli i=1;i<n;i++){
		ani+=getFactorization(n-i);
	}
	cout<<ani;
}
int main()
{
/////////////////////////////////////
    fastio;
/////////////////////////////////////  
    lli t,m;
    //cin>>t;
    t=1;
    while(t--)
    {
    	solve();  
    	m++;  
    	cout<<endl;
    }
}

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

int main() {
    int64_t n, k; cin >> n >> k;
    int64_t sum = 0;
    for (int64_t i = k; i <= n+1; i++) {
        sum += (i * (2 * n + 1 - i) / 2 - i * (i - 1) / 2) % MOD + 1;
        sum %= MOD;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
int n;cin>>n;
string s;cin>>s;
string ans="Yes";
if(n%2!=0){
  cout<<"No"<<endl;
}else{
  if(s.substr(0,n/2)==s.substr(n/2,n/2)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#define int long long

const int MAXN = 100000;

int n, ans;
int f[200005], a1[200005], a2[200005];

int read() {
    int ret, f = 1;
    char ch;
    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);
    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');
    return ret * f;
}

void print(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

void init(int x) {
    for(int i = 1; i <= x; ++i) f[i] = i;
}

int find(int x) {
    return f[x] == x ? x : f[x] = find(f[x]);
}

void merge(int x, int y) {
    f[find(x)] = find(y + MAXN);
}

signed main() {
    n = read();
    init(MAXN << 1);
    for(int i = 1; i <= n; ++i)
        merge(read(), read());
    for(int i = 1; i <= MAXN; ++i) ++a1[find(i)];
    for(int i = MAXN + 1; i <= MAXN << 1; ++i) ++a2[find(i)];
    for(int i = 1; i <= MAXN << 1; ++i)
        ans += a1[i] * a2[i];
    return print(ans - n), 0;
}

Measured memory_bytes: 4096
#10_D
import math
n=int(input())
x_v=list(map(int,input().split()))
y_v=list(map(int,input().split()))

p=1
while(p<5):
    d=0
    if(p==4):
        my_list=[]
        for i in range(n):
            my_list.append(abs(x_v[i]-y_v[i]))
        d=max(my_list)
        print(d)
    else:
        for i in range(n):
            d+=abs(x_v[i]-y_v[i])**p
        d=pow(d,1/p)
        print(d)
    p+=1


Measured memory_bytes: 5696
import sys


def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = [0] * nsq
    is_seated = [0] * nsq
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = [-n2, -1, 1, n2]

    ans = 0

    for p in ppp:
        i, j = divmod(p - 1, n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        q = []
        for di in MOVES:
            ni = i + di
            if seats[ni] > res:
                seats[ni] = res
                q.append(ni)

        while q:
            j = q.pop()
            val = seats[j]

            if is_seated[j]:
                val += 1
            for dj in MOVES:
                nj = j + dj
                if seats[nj] > val:
                    seats[nj] = val
                    q.append(nj)

    return ans


n, *ppp = map(int, sys.stdin.buffer.read().split())

print(solve(n, ppp))


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 10010;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }

    void add(int x, int val) {
        x += (n - 1);
        node[x] = (node[x] + val) % mod;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = (node[2*x+1] + node[2*x+2]) % mod;
        }
    }
 
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = (node[2*x+1] + node[2*x+2]) % mod;
        }
    }
    // hannkaikukann 
    int getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return (vl + vr) % mod;
    }
};


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    vector<int> w(N);
    for(int i = 0; i < N; i++) cin >> w[i];
    w.push_back(-1);
    w.push_back(W + 1);
    sort(w.begin(), w.end());
    vector<int> wsum(N + 1);
    for(int i = 1; i <= N; i++) {
        wsum[i] = wsum[i-1] + w[i];
    }
    SegmentTree seg;
    seg.add(W, 1);
    int ans = 0;
    if(wsum[N] <= W) {
        cout << 1 << endl;
        return 0;
    }
    for(int index = N + 1; index >= 2; index--) {
        for(int val = 0; val <= W; val++) {
            if(w[index] + val <= W) {
                int ADD = seg.getsum(val + w[index], val + w[index] + 1);
                seg.add(val, ADD);
            }
        }
        int lowerbound = 0;
        int upperbound = w[index-1];
        lowerbound += wsum[index-2];
        lowerbound = min(lowerbound, W + 1);
        upperbound += wsum[index-2];
        upperbound = min(upperbound, W + 1);
        ans = (ans + seg.getsum(lowerbound, upperbound)) % mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<algorithm>
using namespace std;
struct point { double x; double y; };

int main() {
	int n, m;
	cin >> n >> m;
	int x[100001];
	int y[100001];
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	sort(x, x + m);
	for (int i = 0; i < m - 1; i++) {
		y[i] = x[i + 1] - x[i];
	}
	sort(y, y + m - 1);
	int ans=0;
	if (m - n <= 0) ans = 0;
	else {
		for (int i = 0; i < m - n; i++) {
			ans = ans + y[i];
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 1024
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

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

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N, A; cin >> N >> A;
    cout << N * N - A << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<algorithm>
#include<climits>
#include<string>
#include<map>
#include<queue>
using namespace std;

int main(){

	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif

	long long int n,a,b,sum=0;

	
	bool ans = true;
	vector<pair<long long int,long long int>> inp;
	cin>>n;

	for(int i=0;i<n;i++){
		cin>>a>>b;
		inp.push_back(make_pair(b,a));
	}

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

	for(int i=0;i<n;i++){
		sum = sum+inp[i].second;
		if(sum>inp[i].first){
			ans=false;
			break;
		}
	}

	if(ans)
		cout<<"Yes";
	else
		cout<<"No";


	return 0;
}

Measured memory_bytes: 6128
import sys

def S():
	return sys.stdin.readline().rstrip()


def main():
	N = S()
	N1 = int(N[-1])
	if N1 == 3:
		print("bon")
	elif N1 in [0, 1, 6, 8]:
		print("pon")
	else:
		print("hon")

if __name__ == "__main__":
	main()

Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = 1;
    int cntmax = 0;
    for (int i = 1; i <= n; ++i)
    {
        int num = i;
        int cnt = 0;
        while (num > 0)
        {
            if (num % 2 == 0)
            {
                num /= 2;
                ++cnt;
            }
            else
            {
                break;
            }
        }
        if (cnt >= cntmax) 
        {
            cntmax = cnt;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int keta(int x){
    int s = 0;
    while(x > 0){
        s += x%10;
        x /= 10;
    }
    return s;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    //cout << keta(84) << endl;
    for(int i=1;i<=n;i++){
        int sum = keta(i);
        if(sum >= a && sum <= b){
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
using namespace std;
string s;
int main(){
	cin>>s;
	for (int i=1;i<4;i++){
		if (s[i]==s[i-1]){
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
	return 0;
}

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

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

  set<ll> s;
  multiset<ll> ms;
  for (int i = 0; i < n; i++) {
    s.insert(a[i]);
    ms.insert(a[i]);
  }
  vector<ll> wh;
  for (auto itr = s.rbegin(); itr != s.rend(); itr++) {
    if (ms.count(*itr) >= 4) {
      wh.push_back(*itr);
      wh.push_back(*itr);
      break;
    } else if (ms.count(*itr) >= 2) {
      wh.push_back(*itr);
      if (wh.size() > 1) break;
    }
  }
  if (wh.size() >= 2) {
    cout << wh[0] * wh[1] << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 13516
#include <stdio.h>
#include <string.h>

int main(void) {
	int n, i;
	int ayaneru = 0, asumisu = 0;
	char tomatu[128], sumipe[128];
	if (scanf("%d", &n) != 1) return 1;
	for (i = 0; i < n; i++) {
		int mareitaso;
		if (scanf("%127s%127s", tomatu, sumipe) != 2) return 1;
		mareitaso = strcmp(tomatu, sumipe);
		if (mareitaso > 0) ayaneru += 3;
		else if (mareitaso < 0) asumisu += 3;
		else ayaneru++, asumisu++;
	}
	printf("%d %d\n", ayaneru, asumisu);
	return 0;
}




Measured memory_bytes: 2100
#include <cstdio>
double dp[3000];
int main() {
	int n;
	scanf("%d", &n);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		double p;
		scanf("%lf", &p);
		for (int j = i + 1; j > 0; j--) {
			dp[j] = dp[j-1] * p + dp[j] * (1 - p);
		}
		dp[0] = dp[0] * (1 - p);
	}
	double ans = 0;
	for (int i = 0; i <= n; i++) {
		if (i > n - i) {
			ans += dp[i];
		}
	}
	printf("%.12f\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main()
{
	int A, B;
	int ans;

	std::cin >> A;
	std::cin >> B;

	if (A + B < A - B) {
		ans = A - B;
	}
	else {
		ans = A + B;
	}

	if (ans < A * B) {
		ans = A * B;
	}

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

	return 0;
}

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

typedef long long LL;
const LL M = 1000000007;

inline LL mul(LL a, LL b) {
  return (a*b)%M;
}

inline LL add(LL a, LL b) {
  return (a+b)%M;
}

LL ppow(LL a, LL e) {
  LL ans = 1;
  while(e) {
    if(e&1) ans = mul(ans, a);
    a = mul(a,a);
    e /= 2;
  }
  return ans;
}

LL n, a, b;
int main() {
  cin >> n >> a >> b;
  LL pp = ppow(2, n);

  LL c1 = 1;
  LL n1 = n;
  for(int i = 0; i < a; i++)
    c1 = mul(c1, n1--);

  LL af = 1;
  for(int i = 1; i <= a; i++)
    af = mul(af, i);
  LL nc1 = mul(c1, ppow(af, M-2));

  LL c2 = 2;
  LL n2 = n;
  for(int i = 0; i < b; i++)
    c2 = mul(c2, n2--);

  LL bf = 2;
  for(int i = 1; i <= b; i++)
    bf = mul(bf, i);
  LL nc2 = mul(c2, ppow(bf, M-2));
  cout << (2*M + pp - nc1 - nc2 - 1) % M;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 0;
    ll res = 0;
    map<int,int> mp;
    rep(i,n){
        cin >> a[i];
        res += mp[a[i]];
        mp[a[i]]++;
    }
    
    rep(i,n){
        ans = res -(mp[a[i]])*(mp[a[i]]-1)/2+ (mp[a[i]]-1)*(mp[a[i]]-2)/2;
        cout  << ans << endl;
        
    }

    return 0;
}

Measured memory_bytes: 8320
while True:
    a,b,c = map(int,input().split())
    if a == b == c == -1: break
    if a==-1 or b==-1:
        print('F')
        continue
    if 80 <= a+b:
        print('A')
        continue
    elif 65 <= a+b:
        print('B')
        continue
    elif 50 <= a+b:
        print('C')
        continue
    elif 30 <= a+b:
        if 50 <= c:
            print('C')
            continue
        else:
            print('D')
            continue
    elif a+b<30: print('F')
    



Measured memory_bytes: 5596
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        System.out.println(gcd(x, y));
    }

    public static int gcd(int x, int y) {
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        if (a % b == 0) {
            return b;
        } else {
            return gcd(b, a % b);
        }
    }
}



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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i ++) cin >> a[i];
    vector<int> b(n, 0);
    bool j = true;
    int l = 0;
    int r = n-1;
    for(int i = n-1; i >= 0; i --) {
        if(j) {
            b[l] = a[i];
            l ++;
            j = false;
        }
        else {
            b[r] = a[i];
            r --;
            j = true;
        }
    }
    for (int i = 0; i < n; i++) {
        if(i==n-1) cout << b[i] << endl;
        else cout << b[i] << " ";
    }
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n, x, y; cin >> n >> x >> y;
	G g(n+1);
	g[x].push_back(y);
	g[y].push_back(x);
	int ans[2005];
	for(int i=1;i<n;i++){
		g[i].push_back(i+1);
		g[i+1].push_back(i);
		ans[i] = 0;
	}

	queue<pii> q;
	int d[2005];
	for(int i=1;i<=n;i++){
		d[i] = -1;
	}
	for(int i=1;i<=n;i++){
		q.push({i,0});
		while(!q.empty()){
			int a = q.front().first;
			d[a] = q.front().second;
			ans[d[a]]++;
			q.pop();
			for(auto c: g[a]){
				if(d[c]<=d[a] && d[c]!=-1) continue;
				else if(d[c]==-1){
					d[c] = d[a]+1;
					q.push(make_pair(c, d[c]));
				}
			}
		}
		for(int i=1;i<=n;i++){
			d[i] = -1;
		}
	}

	for(int k=1;k<n;k++){
		cout << ans[k]/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 384
//QuickSort
//参考 JudgeId 1909380 By EMINE
using System;
using System.Linq;


namespace tst
{
    class Program
    {
        public struct Card
        {//charとintを同じ配列に
            internal char suit;
            internal int value;
        }
        public static void Quicksort(Card[] A, int p, int r)
        {
            if (p < r)
            {
                //対象の部分配列を前後二つの部分配列に分割（Divide）
                int q = Partition(A, p, r);
                //前方の部分配列についてソート
                Quicksort(A, p, q - 1);
                //後方の部分配列についてソート
                Quicksort(A, q + 1, r);
            }
        }
        public static int Partition(Card[] A, int p, int r)
        {
            int x = A[r].value;
            int i = p - 1;
            for (int j = p; j < r; j++)
            {
                if (A[j].value <= x)
                {
                    i++;
                    Card temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            }
            Card temp2 = A[i + 1];
            A[i + 1] = A[r];
            A[r] = temp2;
            return i + 1;
        }
        public static bool IsStable(Card[]A, Card[] B, int n)
        {
            for(int i=0; i<n; i++)
            {
                if (A[i].suit != B[i].suit) return false;
            }
            return true;
        }
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            Card[] A = new Card[n];
            for (int i = 0; i < n; i++)
            {
                string[] In = Console.ReadLine().Split(' ');
                A[i].suit = Convert.ToChar(In[0]);
                A[i].value = int.Parse(In[1]);

            }
            Card[] B = A;
            B = B.OrderBy(b => b.value).ToArray();
            Quicksort(A, 0, n - 1);
            //安定か不安定か
            string mes = "Not stable";
            if (IsStable(A, B, n))
            {
                mes = "Stable";    
            }
            Console.WriteLine(mes);
            for (int i=0; i<n; i++)
            {
                Console.WriteLine("{0} {1}", A[i].suit, A[i].value);
            }
        }

    }
}


Measured memory_bytes: 27072
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string S;

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

  cin >> S;
  int N = S.size();
  int idx = 0;
  rep(i, N/2) {
    if (S[i]!=S[N-1-i]) idx++; 
  }
  cout << idx << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long t = 1e18;
int main(){
    int n;
    bool flg=false;
    cin >> n;
    long long s=1;
    for(int i=0; i<n; i++){
        long long tmp;
        cin >> tmp;
        if(tmp==0){
            cout << 0 <<"\n";
            return 0;
        }
        if(flg||(t+1)/s<tmp||s*tmp>t){
            flg = true;
        }
        s *= tmp;
    }
    if(flg){
        cout << -1 << "\n";
        return 0;
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define endl '\n'
#define fastio ios::sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

ll F(ll n) {
	return n & 1 ? n + 1 >> 1 & 1 : n >> 1 & 1 ^ n;
}
int main() {
	fastio;
	ll A, B;
	cin >> A >> B;

	cout << (F(A - 1) ^ F(B));

	return 0;
}

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

struct SieveOfEstosthenes {
    int n;
    vector<bool> is_prime;
    vector<int> prime;
    SieveOfEstosthenes(int n) : n(n), is_prime(n, true) {
        is_prime[0] = is_prime[1] = false;
        for (int i = 2; i <= n; ++i) {
            if (is_prime[i]) {
                prime.push_back(i);
                for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
            }
        }
    }
};

/*
    verified https://onlinejudge.u-aizu.ac.jp/problems/0009
*/
int main() {
    int n;
    while (cin >> n) {
        SieveOfEstosthenes era(n);
        cout << era.prime.size() << endl;
    }
}



Measured memory_bytes: 3692
def readinput():
    n,k=map(int,input().split())
    h=list(map(int,input().split()))
    return n,k,h

def main(n,k,h):
    if k>=n:
        return 0
    
    h.sort(reverse=True)
    ans=0
    for i in range(k,n):
        ans+=h[i]
    return ans

if __name__=='__main__':
    n,k,h=readinput()
    ans=main(n,k,h)
    print(ans)


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

const long Beneath=250000;
//配列の大きさはBeneath+1で定義する。添字はBeneathまで。1.72*10^8で大体2s

const long mod=998244353;



vector<long> fac(Beneath+1),ifac(Beneath+1);

long mpow(long x,long n){
  long ans=1;
  while(n!=0){
    if(n&1) ans=ans*x%mod;
    x=x*x%mod;
    n= n>>1;
  }
  return ans;
}

long comb(long a,long b){
  //long tmp;
  if(a==0 && b==0) return 1;
  if(a<b || a<0) return 0;
  long tmp=ifac.at(a-b)*ifac.at(b)%mod;
  return tmp*fac.at(a)%mod;
}






int main(){
  long N,M,K;cin>>N>>M>>K;
  
  vector<long> pow_(Beneath+1);
  
  fac.at(0)=1;ifac.at(0)=1;
  for(long i=1;i<Beneath+1;i++){
    fac.at(i)=fac.at(i-1)*i%mod;
    ifac.at(i)=ifac.at(i-1)*mpow(i,mod-2)%mod;
  }
  
  pow_.at(0)=1;
  for(long i=1;i<Beneath;i++) pow_.at(i)=pow_.at(i-1)*(M-1)%mod;
  
  long ans=0;
  
  for(long i=0;i<=K;i++){
    long A=M;
    A= A*comb(N-1,i)%mod;
    A= A*pow_.at(N-1-i)%mod;
    ans+=A;
    ans%=mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 9004
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main (void)
{
  int i,a,b,k,d,gcd,c=0;
  cin>>a>>b>>k;
  while(1)
  {
    d=a%b;
    if(d==0){gcd=b;break;}
    a=b;
    b=d;
  }
  for(i=1;i<gcd;i++)
  {
    if(gcd%i==0)c++;
    if(c==k){break;}
  }
  cout<<gcd/i<<endl;
}

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

long long MOD = 1000000007;

long long modpow(long long a, long long n){
  long long x = 1;
  for(long long i = 0; i < n; i++){
    x = x * a % MOD;
  }
  return x;
}

int main(){
  long long n, ans;
  cin >> n;
  ans = modpow(10, n) - modpow(9, n) - modpow(9, n) + modpow(8, n);
  ans = ans % MOD;
  ans = (ans + MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <algorithm>
#define MAX 100005
int dp[MAX];
using namespace std;
int main() {

  int n;
  int h[MAX];

  cin >> n;

  for ( int i = 1; i <= n; i++ ) cin >> h[i];

  dp[0] = 1000000000;

  for ( int i = 2; i <= n; i++ ) {
    dp[i] = min(dp[i-2] + abs(h[i-2]-h[i]),dp[i-1] + abs(h[i-1]-h[i]));
  }

  cout << dp[n] << endl;

  return 0;
  
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + K - s_z + 1)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		sc.nextLine();

		String[] cards = sc.nextLine().split(" ");
		String[] cardsbub = cards.clone();
		String[] cardssel = cards.clone();

		bubble(cardsbub, n);
		for (int i=0; i < n-1; i++) {
			System.out.print(cardsbub[i] + " ");
		}
		System.out.println(cardsbub[n-1]);
		System.out.println("Stable");

		selection(cardssel, n);
		for (int i=0; i < n-1; i++) {
			System.out.print(cardssel[i] + " ");
		}
		System.out.println(cardssel[n-1]);
		if ( isStable(cards, cardssel, n) ) System.out.println("Stable");
		else System.out.println("Not stable");

	}

	static void bubble(String[] c, int n) { // c:cards, n:c.length

		for (int i=0; i < n; i++) {
			for (int j=n-1; i+1 <= j; j--) {
				// cj:c[j].value, cjm1:c[j-1].value
				int cj = Integer.parseInt( c[j].substring(1, 2) );
				int cjm1 = Integer.parseInt( c[j-1].substring(1, 2) );

				if (cjm1 > cj) {
					String temp = c[j-1];
					c[j-1] = c[j];
					c[j] = temp;
				}
			}
		}

	}

	static void selection(String[] c, int n) {

		for (int i=0; i < n; i++) {

			int minj = i;
			for (int j=i; j < n; j++) {
				// cj:c[j].value, cminj:c[minj].value
				int cj = Integer.parseInt( c[j].substring(1, 2) );
				int cminj = Integer.parseInt( c[minj].substring(1, 2) );

				if (cminj > cj) {
					minj = j;
				}
			}

			/*
			 * ... c[i] ... c[minj] ...
			 *     c[i] >= c[minj]
			 */
			String temp = c[minj];
			c[minj] = c[i];
			c[i] = temp;

		}
	}

	static boolean isStable(String[] in, String[] out, int n) {

		for (int i=0; i < n; i++) {
			for (int j=i+1; j < n; j++) {

				for (int a=0; a < n; a++) {
					for (int b=a+1; b < n; b++) {

						int ini = Integer.parseInt( in[i].substring(1, 2) );
						int inj = Integer.parseInt( in[j].substring(1, 2) );
						int outa = Integer.parseInt( in[a].substring(1, 2) );
						int outb = Integer.parseInt( in[b].substring(1, 2) );

						/*
						 * cards in : ... in[i]  ... in[j] ...
						 * cards out: ... out[a] ... out[b] ...
						 *
						 */
						if ( ini == inj &&
								in[i].equals(out[b]) &&
								in[j].equals(out[a]) ) {
							return false;
						}

					}
				}

			}
		}
		return true;

	}
}

Measured memory_bytes: 32236
N, Q = map(int, input().split())
S = input()
lr_list = [list(map(int, input().split())) for i in range(Q)]
ac_sum = [0]
count = 0
for i, char in enumerate(S):
    if i != 0:
        if char == "C" and buf == "A":
            count += 1
    ac_sum.append(count)
    buf = char

for lr in lr_list:
    print(ac_sum[lr[1]] - ac_sum[lr[0]])


Measured memory_bytes: 30700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split("");
        int x = 0;
        for (int i = 0; i < s.length; i++) {
            int a = Integer.parseInt(s[i]);
            if (a == 1) {
                x++;
            }
        }
        System.out.println(x);
        scanner.close();
    }
}


Measured memory_bytes: 27028
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll x1(n), y1(n), x2(n), y2(n);
    vll xv, yv;
    for(ll i = 0; i < n; i++) {
        cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        xv.push_back(x1[i]);
        xv.push_back(x2[i]);
        yv.push_back(y1[i]);
        yv.push_back(y2[i]);
    }
    sort(xv.begin(), xv.end());
    sort(yv.begin(), yv.end());
    xv.erase(unique(xv.begin(), xv.end()), xv.end());
    yv.erase(unique(yv.begin(), yv.end()), yv.end());
    
    vvll plain(yv.size(), vll(xv.size()));
    for(ll i = 0; i < n; i++) {
        ll xi1 = lower_bound(xv.begin(), xv.end(), x1[i]) - xv.begin();
        ll xi2 = lower_bound(xv.begin(), xv.end(), x2[i]) - xv.begin();
        ll yi1 = lower_bound(yv.begin(), yv.end(), y1[i]) - yv.begin();
        ll yi2 = lower_bound(yv.begin(), yv.end(), y2[i]) - yv.begin();
        plain[yi1][xi1]++;
        plain[yi2][xi2]++;
        plain[yi1][xi2]--;
        plain[yi2][xi1]--;
    }
    for(ll i = 0; i < yv.size() - 1; i++) {
        for(ll j = 0; j < xv.size(); j++) {
            plain[i + 1][j] += plain[i][j];
        }
    }
    for(ll i = 0; i < yv.size(); i++) {
        for(ll j = 0; j < xv.size() -  1; j++) {
            plain[i][j + 1] += plain[i][j];
        }
    }
    ll ans = 0;
    for(ll i = 0; i < yv.size() - 1; i++) {
        for(ll j = 0; j < xv.size() - 1; j++) {
            if(plain[i][j] == 0) continue;
            ans += (yv[i + 1] - yv[i]) * (xv[j + 1] - xv[j]);
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

const int N = 505;

int n, x[N], rem[N], a[N * N];
vector<int> vec;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		a[--x[i]] = i;
		rem[i] = i - 1;
	}
	for (int i = 0; i < n * n; i++)
		if (a[i])
			vec.push_back(a[i]);
	int p = 0;
	for (int num: vec)
		while (rem[num]--) {
			while (a[p])
				p++;
			if (p > x[num])
				break;
			a[p] = num;
		}
	for (int i = 1; i <= n; i++)
		rem[i] = n - i;
	for (int num: vec)
		while (rem[num]--) {
			while (a[p] || p < x[num])
				p++;
			if (p >= n * n)
				break;
			a[p] = num;
		}
	for (int i = 0; i < n * n; i++)
		if (a[i] == 0) {
			cout << "No\n";
			return 0;
		}
	cout << "Yes\n";
	for (int i = 0; i < n * n; i++)
		cout << a[i] << ' ';
}


Measured memory_bytes: 2176
#include <stdio.h>

int main(void){
  long long int a,b,x,y;
  int z;
  while(scanf("%lld%lld",&a,&b) != EOF){
    x = a;
    y = b;
    if(a < 0)x = a * (-1);
    if(b < 0)y = b * (-1);

    while(x % y != 0){
        z = x % y;
        x = y;
        y = z;
    }

    printf("%lld %lld\n",y,a*b/y);
  }
  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
 
int main() {
	int H,W,N;
	scanf("%d", &H);
	scanf("%d", &W);
	scanf("%d", &N);
	int counts = 0, result = 0;
	while (N > result){
		if(W >= H){
			result = result + W;
			counts++;
		}else if(H > W){
			result = result +H;
			counts++;
		}
	}
	printf("%d\n",counts);
	
	return 0;
}

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

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if(4*a*b < (c-a-b)*(c-a-b) && c > a + b) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
while True:
    a, op, b = input().split()

    if op == '?':
        break

    a = int(a)
    b = int(b)

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    else:
        print(a // b)



Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++) cin >> a[i];
  ll x=0,y=0,xc=0,yc=0;
  for(ll i=0;i<n;i++){
    xc+=a[i];
    if(i%2==0&&xc<=0){
      x+=1-xc;
      xc=1;
    }
    else if(i%2==1&&xc>=0){
      x+=1+xc;
      xc=-1;
    }
  }
  for(ll i=0;i<n;i++){
    yc+=a[i];
    if(i%2==0&&yc>=0){
      y+=1+yc;
      yc=-1;
    }
    else if(i%2==1&&yc<=0){
      y+=1-yc;
      yc=1;
    }
  }
  cout << min(x,y) << endl;
}

Measured memory_bytes: 1024
<?php
define('X_P', 10000);
define('Y_P', 5000);
define('Z_P', 1000);
fscanf(STDIN, '%d %d', $n, $a);

//$x = $y = $z = 0;

for ($i_x = 0; $i_x <= $n; $i_x++) {
    $hoge = $n - $i_x;
    for ($i_y = 0; $i_y <= $hoge; $i_y++) {
        $i_z = $n - $i_x - $i_y;
        if ($i_x * X_P + $i_y * Y_P + $i_z * Z_P === $a) {
            echo "$i_x $i_y $i_z" . PHP_EOL;
            return;
        }
    }
}
echo "-1 -1 -1" . PHP_EOL;


Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> s(H);
  REP(i, H) cin >> s[i];

  int ans = INF;
  REP(bit, (1<<(H-1))){
    bool ng = false;
    int row = 1;
    REP(i, H-1) if((bit >> i)&1) row++;

    int cur = row-1;
    vector<int> choko(row, 0);

    REP(j, W){
      int now = 0;
      vector<int> add(row, 0);
      REP(i, H){
        if(s[i][j] == '1') add[now]++;
        if((bit >> i)&1) now++;
      }

      bool flag = true;
      REP(i, row) if(add[i] > K) flag = false;
      if(!flag) ng = true;
      REP(i, row) if(add[i]+choko[i] > K) flag = false;
      if(!flag){
        REP(i, row) choko[i] = add[i];
        cur++;
      }else{
        REP(i, row) choko[i] += add[i];
      }
    }
    if(!ng) chmin(ans, cur);
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
	 int k;

	 cin >> k;
//	for(int k = 1;k<=179;k++)
	{
	 vector<int> sin(91),cos(91);
	int now = 0;
	for(int i =0;;i++)
	{
		if(now <= 90)
		{
			sin[now]++;
			cos[now]++;
		}
		else if(now<=180)
		{
			int x = 180 - now;
			sin [x] ++;
			cos[x] --;
		}
		else if(now<=270)
		{
			int x = now-180;
			sin[x]--;
			cos[x]--;
		}
		else
		{
			int x = 360 - now;
			sin[x]--;
			cos[x] ++;
		}
		bool flg = true;
		for(int j = 1;j<91;j++)if(sin[j])flg=false;
		for(int j = 0;j<90;j++)if(cos[j])flg=false;
		if((i+1)*k%360==0)
		{
			cout<<i+1<<endl;
			break;
			return 0;
		}
		(now += k)%=360;
	}
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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() {
    int X;
    cin >> X;
    if(X >= 30) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

int vet[MAXN*3];
int memo[MAXN*3];
int n;

int solve(int d){
    if(memo[d]!=-1) return memo[d];

    if(d>3*n) return 0;

    int pos1=-INF,pos2=-INF;
    
    if(d%3==1){
        pos1 = vet[d] + solve(d+4);
        pos2 = vet[d] + solve(d+5);
    }else if(d%3==2){
        pos1 = vet[d] + solve(d+2);
        pos2 = vet[d] + solve(d+4);
    }else{
        pos1 = vet[d] + solve(d+1);
        pos2 = vet[d] + solve(d+2);
    }

    return memo[d] = max(pos1,pos2);
}

int main(){
    cin>>n;

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

    memset(memo,-1,sizeof(memo));

    int saida=0;
    for(int i=1;i<=3;i++){
        saida=max(saida,solve(i));
    }

    cout<<saida;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, A, B; cin >> N >> A >> B;
	int minR = 0;
	if (N <= A + B){
		minR = A + B - N;
	} // end if	
	int maxR = min(A, B);
	cout << maxR << ' ' << minR << endl;

	return 0;
}

Measured memory_bytes: 256
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define fst first
#define snd second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int bf0 = (1<<0);
const unsigned int bf1 = (1<<1);
const unsigned int bf2 = (1<<2);
const unsigned int bf3 = (1<<3);
const unsigned int bf4 = (1<<4);
const unsigned int bf5 = (1<<5);
const unsigned int bf6 = (1<<6);
const unsigned int bf7 = (1<<7);


//#include <boost/format.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
namespace bm = boost::math;

int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}

int main(void){
  int n; cin>>n;
  vector<int> h(n);
  FOR(i,0,n){cin>>h[i];}

  int cnt_max=0;
  int cnt=0;
  FORQ(i,0,n-2){
    if (h[i]>=h[i+1]) {
      cnt++;
    }else{
      cnt_max=max(cnt,cnt_max);
      cnt=0;
    }
  }
  cout << max(cnt,cnt_max) << endl;
    
  return 0;
}



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

int main() {
    string s,t;
    cin>> s >> t;
    string ans;

    ans = t;
    ans += s;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int r[10];
int d[222][222];

int main() {
	int N, M, R;
	cin >> N >> M >> R;
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		--r[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			d[i][j] = 1e9;
		}
		d[i][i] = 0;
	}
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		--a; 
		--b;
		d[a][b] = d[b][a] = c;
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	//for (int i = 0; i < N; i++) {
	//	for (int j = 0; j < N; j++)
	//		cout << d[i][j] << " ";
	//	cout << endl;
	//}
	vector<int> perm(R);
	for (int i = 0; i < R; i++)
		perm[i] = i;
		
	int ans = 1e9;
	while (next_permutation(perm.begin(), perm.end())) {
		int sum = 0;
		for (int i = 0; i < R-1; i++) {
			sum += d[r[perm[i]]][r[perm[i+1]]];
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
using System;

namespace CSharp_0430
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int H = int.Parse(input[0]);    //H行の取得
            int W = int.Parse(input[1]);    //W列の取得

            string[] input2 = Console.ReadLine().Split(' ');
            int h = int.Parse(input2[0]);    //h行の取得
            int w = int.Parse(input2[1]);    //w列の取得

            Console.WriteLine((H-h)*(W-w));

        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#define MAX 100000
 
typedef struct{
  int p;
  int l;
  int r;
}id;
   
id A[MAX];
int n,B[MAX];
 
   
void rec(int x,int y){
  B[x] = y;
  if(A[x].r != -1) rec(A[x].r,y);
  if(A[x].l != -1) rec(A[x].l,y + 1);
}


int main(){
  int c,d,i,j,v,l,r,n,op;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].p = A[i].l = A[i].r = -1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) A[v].l=c;
      else A[l].r = c;
      l=c;
      A[c].p = v;
    }
  }
  for(i=0;i<n;i++){
    if(A[i].p == -1) r=i;
  }
 
  rec(r,0);
 
  for(i=0;i<n;i++){
    
    printf("node %d: parent = %d, depth = %d,",i,A[i].p,B[i]);
    if(A[i].p == -1) printf(" root,");
    else if(A[i].l == -1 ) printf(" leaf,");
    else printf(" internal node,");
    printf(" [");
    op=A[i].l;
    for(j=0;op!=-1;j++){
      if(j != 0) printf(", ");
      printf("%d",op);
      op = A[op].r;
    }
    printf("]\n");  
  }
 
  return 0;
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> all;
    for (int i = 1; i < 1000; ++i) {
        all.push_back((a * i) % b);
    }
    vector<bool> dp(c + 1);
    dp[0] = true;
    for (int i = 0; i <= c; ++i) {
        for (auto j : all) {
            if (i - j >= 0) {
                dp[i] = dp[i] | dp[i - j];
            }
        }
    }
    if (dp[c]) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}

Measured memory_bytes: 256