akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    int acE[300001] = {};
    int acW[300001] = {};

    int N;
    cin >> N;

    string S;
    cin >> S;

    for (int i=1; i<=N; ++i) {
        acE[i] = acE[i-1] + (S[i-1] == 'E' ? 1 : 0);
        acW[i] = acW[i-1] + (S[i-1] == 'W' ? 1 : 0);
    }

    int ans = INT_MAX;
    for (int i=0; i<N; ++i) {
        ans = min(ans, acW[i] + (acE[N] - acE[i+1]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int ctoi(char c){return c - '0';}

bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll a,b;cin>>a>>b;
  ll ab = gcd(a,b);
  auto p = primes(ab);
  UNIQUE(p);
  print(p.size()+1);
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 205
using namespace std;

int n, ans, d[N][N];
int main() {
	int i, j, k, t;
	cin >> n;
	for(i=0; i<n; i++) for(j=0; j<n; j++) {
		scanf("%1d", &t);
		d[i][j] = (t==1 || i==j ? t : 1e9);
	}
	for(k=0; k<n; k++) for(i=0; i<n; i++) for(j=0; j<n; j++) {
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	for(i=0; i<n; i++) for(j=0; j<n; j++) {
		ans = max(ans, d[i][j]);
		for(k=0; k<n; k++) {
			if((d[i][k] + d[k][j] + d[i][j]) % 2) return puts("-1")*0;
		}
	}
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
  a[i], b[i] = map(int, input().split())
  
index_b = a.index(max(a))
ans = max(a) + b[index_b]
print(ans)


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

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

  h[0]--;
  for(int i = 1; i < n; i++){
    if(h[i-1] < h[i]){
      h[i]--;
    }

    if(h[i-1] > h[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1024
mod = 10 ** 9 + 7

# permutation: n * (n-1) * …… * (n-k+1) (mod p)
def prm(n, k, p=10**9+7):
    res = 1
    for i in range(k):
        res = res * (n-i) % p
    return res

# combination: nPk / k! (mod p), note: p must be a prime number
def cmb(n, k, p=10**9+7):
    k = min(k, n - k)
    return prm( n, k ) * pow( prm(k, k), p-2, p ) % p

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

#何も選ばない1通りを除く
ans = pow(2,n,mod) - 1 - cmb(n,a) - cmb(n,b)
print(ans % mod)

Measured memory_bytes: 3064
<?php
	$i = 1;
	$output = array();
	while( $i ) {
		fscanf( STDIN, "%d", $x );
		if( 0 != $x ) {
			array_push( $output, "Case ".$i.": ".$x );
		} else {
			print implode( "\n", $output );
			break;
		}	
		$i++;
	}
?>

Measured memory_bytes: 8496
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 1000000000
#define limit 200001
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
    lli n;
    cin >> n;

    lli cnt = 0, p = 1, pos, d;
    rep(i, 100)
    {
        if(cnt + p*26 >= n)
        {
            d = i+1;
            pos = n - cnt; 
            break;
        }
        p = p * 26;
        cnt += p;
    }
    vlli p26(14,1);
    loop(i,1,14,1)
        p26[i] = p26[i-1]*26;


    str ans = "";
    while(d)
    {
        lli cnt = 0;
        rep(j,26)
        {
            if(cnt + p26[d-1] >= pos)
            {
                ans += char('a'+j);
                pos -= cnt;
                break;
            }
            cnt += p26[d-1];
        }
        d--;
    }
    cout << ans << '\n';






}
 
int main()
{
    

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 3660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 600010


int main() {
	long long nex[N];
	long long nexa[N];
	long long a[N];
	long long sylas[N];
	long long bef[N];
	long long ans[N];
	f(i, N) {
		a[i] = 0;
		nex[i] = 0;
		nexa[i] = 0;
		sylas[i] = 0;
		bef[i] = 0;
		ans[i] = 0;
	}
	long long n, k, kk;
	long long x, y, z;
	long long fians;
	bool used[N];
	stack<long long> q;
	bool v = true;
	scanf("%lld %lld", &n, &kk);
	f(i, n) {
		scanf("%lld", &a[i]);
		a[(n + i)] = a[i];
	}
	f(i, N)bef[i] = -1;
	f(i, (2 * n)) {
		if (bef[a[i]] != -1) {
			x = bef[a[i]] / n;
			y = (i + 1) / n;
			z = (i + 1) % n;
			nexa[bef[a[i]]] = y - x;
			nex[bef[a[i]]] = z;
		}
		bef[a[i]] = i;
	}
	f(i, N)sylas[i] = -1;
	k = 0;
	sylas[0] = 0;
	k = nexa[0];
	x = nex[0];
	sylas[k] = x;
	fians = 0;
	while (x != 0&&fians<(2*n)) {
		k += nexa[x];
		x = nex[x];
		sylas[k] = x;
		fians++;
	}
	kk = kk % k;
	if (kk == 0) {
		printf("\n");
		return 0;
	}
	if (sylas[kk - 1] < 0) {
		printf("\n");
		return 0;
	}
	while(!q.empty())q.pop();
	x = sylas[kk - 1];
	f(i, N)used[i] = false;
	for (long long i = x; i < n; i++) {
		if (!used[a[i]]) {
			q.push(a[i]);
			used[a[i]] = true;
		}
		else {
			x = q.top();
			while (x != a[i]&& !q.empty()) {
				used[x] = false;
				q.pop();
				x = q.top();
			}
			q.pop();
			used[a[i]] = false;
		}
	}
	if (q.empty()) {
		printf("\n");
		return 0;
	}
	fians = 0;
	while (!q.empty()) {
		if (!q.empty())x = q.top();
		ans[fians] = x;
		fians++;
		if (!q.empty())q.pop();
	}
	f(i, fians) {
		printf("%lld", ans[fians - i - 1]);
		if (i < (fians - 1))printf(" ");
		else printf("\n");
	}

	return 0;
}


Measured memory_bytes: 31288
N=int(input())
S1=input()
S2=input()

p=0
prev=0
ans=3

if S1[p]==S2[p]:
    p+=1
    prev=1
else:
    p+=2
    prev=2
    ans*=2

while p<N:
    if S1[p]==S2[p]:
        p+=1
        if prev==1:
            ans*=2
        prev=1
    else:
        p+=2
        if prev==1:
            ans*=2
        else:
            ans*=3
        prev=2
    ans%=1000000007
print(ans)


    


Measured memory_bytes: 38256
#pragma warning (disable:4996)
#include<cstdio>
#include<cmath>
using namespace std;
int sum(int n) {
	int i = 0, s = 0, a[10] = { 0 };
	while (n>0) {
		a[i++] = n % 10;
		n /= 10;
	}
	for (; i >= 0; i--)s += a[i];
	return s;
}

int main()
{
	int n, a, b, min=99999999;
	scanf("%d", &n);
	for (a = 1; a <= n / 2; a++)
	{
		b = n - a;
		int s = sum(a) + sum(b);
		if (s < min) min = s;
	}
	printf("%d", min);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;

class Main{
    public static void main(String[] args) throws Exception{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String num1 = br.readLine();
        String[] num2 = num1.split(" ");

        int W = Integer.parseInt(num2[0]);
        int H = Integer.parseInt(num2[1]);
        int x = Integer.parseInt(num2[2]);
        int y = Integer.parseInt(num2[3]);
        int r = Integer.parseInt(num2[4]);

        if(x - r < 0 || y - r < 0){
            System.out.println("No");
        }else if(x + r > W || y + r > H){
            System.out.println("No");
        }else {
            System.out.println("Yes");
        }

    }
}

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

int main(void)
{
	int N, M;
	int i;
	int num;
	char jud[4];
	int flag=0, count=0;
	int ac[100001]={0}, wa[100001]={0};
	scanf("%d%d", &N, &M);
	for(i=1;i<=M;i++)
	{
		scanf("%d %s", &num, jud);
		if(!ac[num])
		{
			if(jud[0]=='A')
			{
				ac[num]++;
				count++;
			}
			else 
			{
				wa[num]++;
			}
		}
	}
	for(i=1;i<=N;i++)
	{
		if(ac[i])
		{
			flag+=wa[i];
		}
	}
	printf("%d %d", count, flag);

	return 0;
}


Measured memory_bytes: 896
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
	  String S = sc.next();
      String T = sc.next();
      for(int i=0;i<S.length();i++){
      	if(S.equals(T)){
        	System.out.println("Yes");
            return;
      	}
        S = S.substring(S.length()-1)+S.substring(0,S.length()-1);
      }
      System.out.println("No");
    }
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep1(i, n) {
        int k = n / i;
        ans += (ll)k * (k+1) / 2 * i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll N;
  cin >> N;
  vector<ll> A;
  vector<ll> B;
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    A.pb(a);
    B.pb(b);
  }
  SORT(A);
  SORT(B);

  ll ans = 0;
  if (N % 2 == 1) {
    ll l = A[N / 2];
    ll r = B[N / 2];
    ans = r - l + 1;
  } else {
    ll l = A[N / 2] + A[N / 2 - 1];
    ll r = B[N / 2] + B[N / 2 - 1];
    ans = r - l + 1;
  }
  COUT(ans);
  return 0;

  // // 奇数の時
  // ll index = INF;

  // rep(i, N) {
  //   P p = AB[i];
  //   ll left = 0;
  //   ll right = 0;
  //   bool flag = false;
  //   rep(j, N) {
  //     if (i == j) {
  //       continue;
  //     }
  //     P jp = AB[j];
  //     if (p.first >= jp.first) {
  //       left++;
  //     }
  //     if (p.second >= jp.second) {
  //       right++;
  //     }
  //     if (N % 2 == 1) {
  //       if (left >= N / 2 && right >= N / 2) {
  //         flag = true;
  //       }
  //     } else {
  //       if (left >= (N - 1) / 2 && right >= (N - 1) / 2) {
  //         flag = true;
  //       }
  //     }
  //   }
  //   if (flag) {
  //     index = i;
  //     break;
  //   }
  // }

  // debug(index);
  // if (N % 2 == 1) {
  //   COUT(AB[index].second - AB[index].first + 1);
  // } else {
  //   COUT(AB[index].second - AB[index].first);
  // }
  // return 0;
}

Measured memory_bytes: 6684
#include <iostream>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>
#include <vector>
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;

const double EPS = 1e-8;

struct C{
  P c;
  double r;
  C(P c=P(0,0), double r=0.0):c(c),r(r){}
};

double dot(P a, P b){return real(conj(a)*b);}
double cross(P a, P b){return imag(conj(a)*b);}
bool equal(double a, double b){return fabs(a-b) < EPS;}

P proj(P p, L l){
  return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);
}

bool isInterSP(L s, P p){
  if(dot(s.second - s.first, p - s.first) < -EPS) return equal(0.0, abs(p-s.first));
  if(dot(s.first - s.second, p - s.second) < - EPS) return equal(0.0, abs(p-s.second));
  return equal(0.0, abs(cross(s.second - s.first, p - s.first) / abs(s.second - s.first)));
}

vector<P> getInterCS(C c, L s){
  vector<P> res;
  P h = proj(c.c, s);
  double d = abs(c.c - h);
  if(d > c.r + EPS);
  else if(d > c.r - EPS){
    if(isInterSP(s, h)) res.push_back(h);
  } else {
    P v = s.second - s.first;
    v = (sqrt(c.r*c.r - d*d) / abs(v)) * v;
    if(isInterSP(s, h+v)) res.push_back(h+v);
    if(isInterSP(s, h-v)) res.push_back(h-v);
  }
  return res;
}

int n,m;
vector<P> v[2];
P ce;

double calc(P a, P b1, P b2){
  double res = arg(b2-a) - arg(b1-a);
  res *= 180.0 / M_PI;
  while(res < 0) res += 360.0;
  while(res > 360.0) res -= 360.0;
  return res;
}

void solve(){
  double ans = 360.0;
  for(int i=0;i<m;i++){
    C c = C(ce, abs(ce-v[1][i]));
    for(int j=0;j<n;j++){
      L l = L(v[0][j], v[0][(j+1)%n]);
      vector<P> cp = getInterCS(c, l);
      for(int k=0;k<cp.size();k++)
	ans = min(ans, calc(ce, v[1][i], cp[k]));
    }
  }

  for(int i=0;i<n;i++){
    C c = C(ce, abs(ce-v[0][i]));
    for(int j=0;j<m;j++){
      L l = L(v[1][j], v[1][(j+1)%m]);
      vector<P> cp = getInterCS(c, l);
      for(int k=0;k<cp.size();k++)
	ans = min(ans, calc(ce, cp[k], v[0][i]));
    }
  }


  printf("%.7f\n",ans);
}

int main(){
  while(cin >> n >> m && (n|m)){
    double x,y;
    for(int i=0;i<2;i++) v[i].clear();
    for(int i=0;i<n;i++){
      cin >> x >> y;
      v[0].push_back(P(x,y));
    }
    for(int i=0;i<m;i++){
      cin >> x >> y;
      v[1].push_back(P(x,y));
    }
    cin >> x >> y;
    ce = P(x,y);
    solve();
  }
}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}

// friend ostream & operator << (ostream &out, const Complex &c); 
// friend istream & operator >> (istream &in,  Complex &c); 



void solve()
{

 int x[6];

 for(int i=1;i<=5;i++) cin >> x[i];

  int an =-1;

for(int i=1;i<=5;i++)
{
  if(x[i]==0)an=i;
}

cout<<an<<endl;

}


int32_t main()
{
  //pr_init();
  fastio;
  solve();

 }
      
      

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <math.h>
#include <iterator>
using namespace std;

int main() {
	while (true) {
		int t, n,a = 0;
		scanf("%d", &t);
		if (t == 0) goto end;
		scanf("%d", &n);
		for (int i = 0;i < n;++i) {
			int s = 0, f = 0;
			scanf("%d%d", &s, &f);
			a += f - s;
		}
		if (a >= t) {
			printf("OK\n");
		}
		else {
			printf("%d\n", (t - a));
		}
	}
end:;
}


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

typedef long long int ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    
    int res = (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
program sample
	implicit none
    character(len=3) :: a
    
    read(*,*) a
    
    if(len_trim(a)==2) then
    	write(*,*) a
    else
    	write(*,'(3a)') a(3:3),a(2:2),a(1:1)
    end if
    
    stop
end program sample

Measured memory_bytes: 2940
s=input()
n=len(s)
k=['R','U','D']
g=['L','U','D']
for i in range(n):
  if (i+1)%2!=0 and s[i] not in k:
    print('No')
    exit()
  elif (i+1)%2==0 and s[i] not in g:
    print('No')
    exit()
print('Yes')
     

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define YesNo(cond) Cout((cond) ? "Yes" : "No");
using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    YesNo(!(a % 1000 % 111) || !(a / 10 % 111));
}


Measured memory_bytes: 256
# 別変数の整数複数個
H1, M1, H2, M2, K = [int(x) for x in input().strip().split(" ")]

B = H1 * 60 + M1
A = H2 * 60 + M2
if H1 > H2:
    A += 24 * 60

print(A-B-K)

Measured memory_bytes: 9068
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        List<int> list = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList();
        list.Insert(0,0);//番兵
        list.Add(0);//番兵
        var sum = list.Zip(list.Skip(1), (prev, next) => Math.Abs(prev - next)).Sum();
        int dif;
        for(var i=0;i<N;i++){
            //経路i~i+2において、点iを経由する時の距離と経由しない時の距離の差を求める
            dif = Math.Abs(list[i+1] - list[i]) + Math.Abs(list[i+2] - list[i+1]) - Math.Abs(list[i+2] - list[i]);
            Console.WriteLine(sum - dif);
        }
    }
}

Measured memory_bytes: 27740
#include <bits/stdc++.h>
using namespace std;
long long s(int a)
{
    return a*a;
}
bool p(long long a)
{
    for(int i=0;i<1000;++i)
        if(s(i)==a)
        return true;
    return false;
}
int main()
{
    int n,d,x[11][11],cnt=0;
    cin>>n>>d;
    for(int i=0;i<n;i++)
        for(int j=0;j<d;j++)
            cin>>x[i][j];
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<n;++j)
        {
            long long h=0;
            for(int k=0;k<d;++k)
            {
                h+=s(x[i][k]-x[j][k]);
            }
            if(p(h))
                cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> G[n];
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            v--;
            G[u].push_back(v);
        }
    }

    vector<bool> visited(n, false);
    vector<int> d(n, -1);
    queue<int> que;
    que.push(0);
    visited[0] = true;
    d[0] = 0;

    while (!que.empty()) {
        int u = que.front(); que.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (!visited[v]) {
                que.push(v);
                visited[v] = true;
                d[v] = d[u] + 1;
            }
        }
    }

    for (int i = 0; i < n; i++)
        cout << i + 1 << " " << d[i] << endl;
    return 0;
}


Measured memory_bytes: 3168
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>

#define OCT(A,B,C,D,E,F,G,H) ((H) + (G)*8 + (F)*64 + (E)*512 + (D)*4096 + (C)*32768 + (B)*262144 + (A)*2097152)
using namespace std;

struct state { int _0,_1,_2,_3,_4,_5,_6,_7; };
typedef struct state state;
typedef pair<state,int> P;
unsigned short int map[0100000000];

int main(void) {
    int _0,_1,_2,_3,_4,_5,_6,_7;
    queue<P> q;
    q.push( P({0,1,2,3,4,5,6,7},0));

    memset(map, 0, sizeof(map));
    while(~scanf("%d%d%d%d%d%d%d%d",&_0,&_1,&_2,&_3,&_4,&_5,&_6,&_7)) {
        if(_0==0&&_1==1&&_2==2&&_3==3&&_4==4&&_5==5&&_6==6&&_7==7) {
            printf("0\n");
            continue;
        }

        while(map[OCT(_0,_1,_2,_3,_4,_5,_6,_7)] == 0) { 
            P e = q.front(); q.pop();
            state t = e.first;

            if(map[OCT(t._0,t._1,t._2,t._3,t._4,t._5,t._6,t._7)]) continue;

            map[OCT(t._0,t._1,t._2,t._3,t._4,t._5,t._6,t._7)] = e.second;

            if(t._0 == 0) {
                q.push(P({t._1,t._0,t._2,t._3,t._4,t._5,t._6,t._7}, e.second+1));
                q.push(P({t._4,t._1,t._2,t._3,t._0,t._5,t._6,t._7}, e.second+1));
            }else if(t._1 == 0) {
                q.push(P({t._1,t._0,t._2,t._3,t._4,t._5,t._6,t._7}, e.second+1));
                q.push(P({t._0,t._5,t._2,t._3,t._4,t._1,t._6,t._7}, e.second+1));
                q.push(P({t._0,t._2,t._1,t._3,t._4,t._5,t._6,t._7}, e.second+1));
            }else if(t._2 == 0) {
                q.push(P({t._0,t._2,t._1,t._3,t._4,t._5,t._6,t._7}, e.second+1));
                q.push(P({t._0,t._1,t._3,t._2,t._4,t._5,t._6,t._7}, e.second+1));
                q.push(P({t._0,t._1,t._6,t._3,t._4,t._5,t._2,t._7}, e.second+1));
            }else if(t._3 == 0) {
                q.push(P({t._0,t._1,t._3,t._2,t._4,t._5,t._6,t._7}, e.second+1));
                q.push(P({t._0,t._1,t._2,t._7,t._4,t._5,t._6,t._3}, e.second+1));
            }else if(t._4 == 0) {
                q.push(P({t._4,t._1,t._2,t._3,t._0,t._5,t._6,t._7}, e.second+1));
                q.push(P({t._0,t._1,t._2,t._3,t._5,t._4,t._6,t._7}, e.second+1));
            }else if(t._5 == 0) {
                q.push(P({t._0,t._1,t._2,t._3,t._5,t._4,t._6,t._7}, e.second+1));
                q.push(P({t._0,t._5,t._2,t._3,t._4,t._1,t._6,t._7}, e.second+1));
                q.push(P({t._0,t._1,t._2,t._3,t._4,t._6,t._5,t._7}, e.second+1));
            }else if(t._6 == 0) {
                q.push(P({t._0,t._1,t._6,t._3,t._4,t._5,t._2,t._7}, e.second+1));
                q.push(P({t._0,t._1,t._2,t._3,t._4,t._6,t._5,t._7}, e.second+1));
                q.push(P({t._0,t._1,t._2,t._3,t._4,t._5,t._7,t._6}, e.second+1));
            }else if(t._7 == 0) {
                q.push(P({t._0,t._1,t._2,t._7,t._4,t._5,t._6,t._3}, e.second+1));
                q.push(P({t._0,t._1,t._2,t._3,t._4,t._5,t._7,t._6}, e.second+1));
            }
        }
        printf("%d\n", map[OCT(_0,_1,_2,_3,_4,_5,_6,_7)]);
    }

    return 0;
}

Measured memory_bytes: 35496
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));


const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
vec primes;


int main()
{
    int h,n;
    cin >> n >> h;
    ll sum=0;
    vec v(n);
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
    }

    sort(ALL(v));
    if(h>=n)
    {
        cout<<0<<endl;
        return 0;
    }
    int a=n-h;
    for(int i=0;i<a;i++)
        sum+=v[i];
    cout<<sum<<endl;
    return 0;
}





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


void solve(long long N, std::vector<long long> a){
  cout << abs(*max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end())) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A<B){
    if (A<C && C<B){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  if (A>B){
    if (A>C && C>B){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import qualified Data.List as L

main :: IO ()
main = getLine >>= print . solve . map read . words

solve :: [Int] -> Int
solve [n, m] = maximum [g | g<-divisors m, div m g >= n]

smallPrimes :: [Int]
smallPrimes = 2 : [ n | n<-[3,5..46337], all ((>0).rem n) $ takeWhile (\x->x*x<=n) smallPrimes]

primeFactors :: Int -> [Int]
primeFactors n | n < 2 = []
primeFactors n = go n smallPrimes
  where
    go !n pps@(p:ps)
        | n < p * p = [n]
        | r > 0     = go n ps
        | otherwise = p : go q pps
      where
        (q, r) = quotRem n p
    go n [] = [n]

divisors :: Int -> [Int]
divisors n = L.sort . map product . mapM (scanl (*) 1) . L.group $ primeFactors n


Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
using namespace std;
int V,E;
vector< vector<int> > A;
vector<int> c;
stack<int> F;

void dfsVisit(int u) {
    c[u] = 1;
    for(int i=0; i<A[u].size(); i++) {
        int v = A[u][i];
        if(c[v] == 0) dfsVisit(v);
    }
    F.push(u);
}

int main() {
    cin >> V >> E;
    A.resize(V);
    c.resize(V);

    for(int i=0; i<V; i++) A[i].clear();
    
    for(int i=0; i<E; i++) {
        int s,t;
        cin >> s >> t;
        A[s].push_back(t);
    }

    for(int i=0; i<V; i++) c[i] = 0;
    for(int i=0; i<V; i++) {
        if(c[i] == 0) dfsVisit(i);
    }

    while(!(F.empty())) {
        cout << F.top() << endl;
        F.pop();
    }
    
    return 0;
}


Measured memory_bytes: 3532
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> v2;

#define INF (1e9)

int H, W;

int main() {
    cin >> H >> W;

    vvi A(H, vi(W, INF));
    string s;
    queue<v2> q;

    for (int i = 0; i < H; i++) {
        cin >> s;
        for (int j = 0; j < W; j++) {
            if (s[j] == '#') {
                A[i][j] = 0;
                q.push(v2(i, j));
            }
        }
    }

    while (!q.empty()) {
        v2 p = q.front();
        q.pop();
        int xx = p.second;
        int yy = p.first;
        if (xx > 0 && A[yy][xx - 1] == INF) {  // L
            A[yy][xx - 1] = A[yy][xx] + 1;
            q.push(v2(yy, xx - 1));
        }
        if (xx < W - 1 && A[yy][xx + 1] == INF) {  // R
            A[yy][xx + 1] = A[yy][xx] + 1;
            q.push(v2(yy, xx + 1));
        }
        if (yy > 0 && A[yy - 1][xx] == INF) {  // U
            A[yy - 1][xx] = A[yy][xx] + 1;
            q.push(v2(yy - 1, xx));
        }
        if (yy < H - 1 && A[yy + 1][xx] == INF) {  // D
            A[yy + 1][xx] = A[yy][xx] + 1;
            q.push(v2(yy + 1, xx));
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, A[i][j]);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12432
#include<stdio.h>
  
#define MAX 10000
#define NIL -1
  
typedef struct{
  int parent,left,right;
}Node;
  
Node Ans[MAX];
int Depth[MAX],Height[MAX],n;
  
void calcDepth(int,int);
int calcHeight(int);
int getSibling(int);
void print(int);

void calcDepth(int u, int d){
  
  if(u == NIL)return;
  Depth[u] = d;
  calcDepth(Ans[u].left,d+1);
  calcDepth(Ans[u].right,d+1);
}
  
int calcHeight(int u){
  int h1,h2;
  
  h1 = h2 = 0;
  if(Ans[u].left != NIL)h1 = calcHeight(Ans[u].left) + 1;
  if(Ans[u].right != NIL)h2 = calcHeight(Ans[u].right) + 1;
  return Height[u] = (h1 > h2 ? h1 : h2); 
}
  
int getSibling(int u){
  
  if(Ans[u].parent == NIL)return NIL;

  if(Ans[Ans[u].parent].left != u && Ans[Ans[u].parent].left != NIL)
    return Ans[Ans[u].parent].left;

  if(Ans[Ans[u].parent].right != u && Ans[Ans[u].parent].right != NIL)
    return Ans[Ans[u].parent].right;

  return NIL;
}
  
void print(int u){
  int deg = 0;
  
  printf("node %d: parent = %d, sibling = %d, ",u,Ans[u].parent,getSibling(u));
  
  deg = 0;
  
  if(Ans[u].left != NIL)deg++;
  if(Ans[u].right != NIL)deg++;
  
  printf("degree = %d, depth = %d, height = %d, ",deg,Depth[u],Height[u]);
  
  if(Ans[u].parent == NIL)printf("root\n");
  else if(Ans[u].left == NIL && Ans[u].right == NIL)printf("leaf\n");
  else printf("internal node\n");
}

int main(){
  int i,node,left,right,root = 0;
  
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    Ans[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&node,&left,&right);
    Ans[node].left = left;
    Ans[node].right = right;
    if(left != NIL)Ans[left].parent = node;
    if(right != NIL)Ans[right].parent = node;
  }
  
  for(i=0;i<n;i++){
    if(Ans[i].parent == NIL)root = i;
  }
   
  calcDepth(root,0);
  calcHeight(root);
  
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

Measured memory_bytes: 620
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  double N;
  cin >> N;
  deque<double> A(N);
  for (double i = 0; i < N; i++) {
    cin >> A[i];
  }
  while (A.size() > 1) {
    sort(begin(A), end(A));
    auto sum = (A[0] + A[1]) / 2.0;
    A.pop_front();
    A.pop_front();
    A.push_front(sum);
  }

  cout << A[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace	std;
int main()
{
  int N;
  cin >> N;
  bool flag = false;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      int mul =	i * j;
      if(N == mul) {
        flag = true;
      } 
    }
  }
  if(flag == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,x;
    ci(n>>x);
  vll A(n+1);
  vll P(n+1);
  A[0]=1;
  P[0]=1;

  FOR(i,1,n+1){
    A[i]=2*A[i-1]+3;
    P[i]=2*P[i-1]+1;
  }

  ll ans=0;

  while(true){
    
    if(x==1&&n!=0){
      co(0+ans)
      break;
    }
    else if(x==1&&n==0){
      co(1+ans)
      break;
    }

    else if(1<x&&x<=A[n-1]+1){
      n--;
      x--;
    }

    else if(x==A[n-1]+2){
      co(P[n-1]+1+ans)
      break;
    }

    else if(A[n-1]+2<x&&x<=2*A[n-1]+2){
      ans+=P[n-1]+1;
      x-=A[n-1]+2;
      n--;
    }

    else{
      co(2*P[n-1]+1+ans)
      break;
    }

  }
}

Measured memory_bytes: 1024
# https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b

S = input()
# 2文字以上の回分になってしまう条件
# 同じ文字が隣り合う
# 一文字挟んで同じ文字が隣り合う

# 部分文字列が2文字以上の回分にならない文字列
# abcabcabcとかbcabcaとか ようはサイクリックに繰り返せば良い

# 3回繰り返し＋a, 3回繰り返し＋ab,3回繰り返し の3パターンだけあるのだから
# Sのcntがn,n+1,n+2の関係ならば'Yes'

from collections import Counter
cnt = Counter(S + 'abc')
ns = sorted(cnt.values())
n = ns[0]
print('YES' if n <= ns[1] <= n + 1 and n <= ns[2] <= n + 1 else 'NO')


Measured memory_bytes: 73880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    ll sum=0;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        sum^=a[i];
    } 
    vector<ll> ans(n);
    rep(i,n){
        ans[i]=sum^a[i];
    }
    rep(i,n) cout<<ans[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 6308
//https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    int N;
    int A,B;
    cin>>N>>A>>B;
    cout<<min(A,B)<<" "<<max(A+B-N,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
 
 main(){
  int i,j,k,l,count=0,a[N],b,c[N],d;
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&a[i]);
  }
 
  scanf("%d",&d);
  for(j=0;j<d;j++){
    scanf("%d",&c[j]);
  }
 
 for(i=0;i<d;i++){
    for(j=0;j<b;j++){
      if(a[j]==c[i]){  
    count++;
    break;
      }
    }
  }
 printf("%d\n",count);
 return 0;
 }

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	int c = n%1000;
	if(c==0){
		cout << c << endl;
	}
	else{
		int sum = 1000-c;
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;;
public class Main {
	
	static Integer []a;
	static Integer []b;
	static Integer []c;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		a = new Integer [n];
		b = new Integer [n];
		c = new Integer [n];
				
		for(int i = 0; i < n ;i++) {
			a[i] = sc.nextInt();
		}
		for(int i= 0; i < n;i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < n ;i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		
		long ans = 0;
		
		for(int i = 0 ; i < n; i++) {
			int temp1 = ~Arrays.binarySearch(a, b[i],(x,y)-> x.compareTo(y) >=0 ? 1:-1) - 1;
			int temp2 = ~Arrays.binarySearch(c, b[i],(x,y)-> x.compareTo(y) > 0 ? 1:-1);
			ans += (long)(temp1 + 1)* (n - temp2);
		}
		
		System.out.println(ans);
		
		
	}
	
}

Measured memory_bytes: 100616
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

typedef long long LL;
const int N = 1e5 + 10;
struct E {int v, nt;} e[N<<1];
int n, m, su, sv, cri, tot, h[N], s[N];
int f[N], g[N], A[N], dep[N], vis[N]; LL ans;

inline int abs(int x) {return x < 0 ? -x : x;}
inline void add(int u, int v) {
	e[++tot] = (E){v, h[u]}, h[u] = tot;
	e[++tot] = (E){u, h[v]}, h[v] = tot;
}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline void dfs(int x, int p) {
	for (int v, i = h[x]; i; i = e[i].nt) {
		if ((v = e[i].v) == p) continue;
		if (!f[v]) f[v] = -f[x], dfs(v, x);
		else su = x, sv = v, cri = (f[v] == f[x]);
	}
}

inline void dfs2(int x, int p) {
	s[x] = f[x];
	for (int v, i = h[x]; i; i = e[i].nt) {
		v = e[i].v;
		if (v == p || (x==su&&v==sv) || (x==sv&&v==su)) continue;
		dfs2(v, x), s[x] += s[v], g[x] += g[v];
	}
}

int main() {
	int u, v; in(n), in(m);
	for (int i = 1; i <= m; ++i) in(u), in(v), add(u, v);
	f[1] = 1, dfs(1, 0);
	if (m == n - 1) {
		dfs2(1, 0);
		if (s[1]) {puts("-1"); return 0;}
		for (int i = 1; i <= n; ++i) ans += abs(s[i]);
	} else if (cri & 1) {
		dfs2(1, 0);
		if (s[1]%2) {puts("-1"); return 0;}
		int tmp = s[1];
		f[su] -= tmp >> 1, f[sv] -= tmp >> 1, ans = abs(tmp >> 1);
		dfs2(1, 0);
		for (int i = 1; i <= n; ++i) ans += (LL)abs(s[i]);
	} else {
		++g[su], --g[sv];
		dfs2(1, 0);
		if (s[1]) {puts("-1"); return 0;}
		int tmp, num = 0;
		for (int i = 1; i <= n; ++i)
			if (!g[i]) ans += (LL)abs(s[i]);
			else if (g[i]) A[++num] = s[i];
			else A[++num] = -s[i];
		A[++num] = 0;
		sort(A + 1, A + num + 1);
		tmp = A[num + 1 >> 1];
		for (int i = 1; i <= num; ++i) ans += (LL)abs(tmp - A[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
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); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n,k;
           cin>>n>>k;
           int ans=1;
           rep(i,0,n){
            if(ans*2>=ans+k)ans+=k;
             else ans*=2;
           }
           cout<<ans<<endl;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii(a); ii(b); ii(x); YN(a+b>=x && a<=x);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORd(i,a,b) for(int i=(a);i>=(b);i--)
#define FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................



int main()
{
    fast
    ll n,k;
    cin>>n>>k;
    ll p=n%k;
    cout<<min(p,abs(k-p))<<"\n";
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
int main(){
	int n,m;
	//multiset<string>blue,red;
	map<string,int>blue,red;
	cin>>n; 
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		//printf("%s\n", s.c_str());
		blue[s]++;
	}
	//printf("\n");
	cin>>m; 
	for(int i=0;i<m;i++){
		cin>>s;
		//printf("%s\n", s.c_str());
		red[s]++;
	}
	
	map<string,int>:: iterator it;
	int mx = 0;
	for(it = blue.begin();it!=blue.end(); it++){
		string s = (*it).first;
		int cnt_r = red[s], cnt_b = blue[s];
		//if(!(cnt_r>=0 and cnt_r<=m)) cnt_r =0;
		//printf("%s %d %d\n", s.c_str(), cnt_b, cnt_r);
		mx = max(mx, cnt_b-cnt_r);
	}
	printf("%d\n",mx);
	return 0;
}

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

using namespace std;

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

	int cnt = 0;

	int yaku = 1;

	for (int i = 101; i <= n; i += 2) {
		yaku = 1;
		for (int j = 1; j < i; j++) {
			if (i % j == 0) {
				yaku++;
			}
		}

		if (yaku == 8)
			cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cstdio>
using namespace std;
int *a;
int find_top(int i)
{
	while(a[i] != i) i = a[i];
	return i;
}
void union_find(int x,int y)
{
	a[x] = find_top(x);
	a[y] = find_top(y);
	a[a[x]] = a[y];
}
int main(void)
{
	int n,m,u,v;
	scanf("%d %d",&n,&m);
	a = new int [n];
	for(int i = 0;i < n;i++) a[i] = i;
	while(m--)
	{
		scanf("%d %d",&u,&v);
		union_find(u,v);
	}
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d %d",&u,&v);
		a[u] = find_top(u); a[v] = find_top(v);
		printf("%s\n",a[u] == a[v]?"yes":"no");
	}
	return 0;
}


Measured memory_bytes: 3472
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        for (int i = 0; i < 3; i++) {
            sum += Integer.parseInt(sc.next());
        }
        System.out.println(sum >= 22 ? "bust" : "win");
    }
}


Measured memory_bytes: 23764