akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vpii rxy(n),byx(n);
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        pii p=make_pair(x,y);
        rxy[i]=p;
    }
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        pii p=make_pair(y,x);
        byx[i]=p;
    }
    vb fixedr(n,false);
    int cnt=0;
    sort(rxy.begin(),rxy.end());
    sort(byx.begin(),byx.end());
    rep(bi,0,n){
        int  bx=byx[bi].second;
        int  by=byx[bi].first;
        int rfi=-1,vrf=0;
        rep(ri,0,n){
            if(fixedr[ri])continue;
            int rx,ry;
            rx=rxy[ri].first;
            ry=rxy[ri].second;
            if(rx<bx&&ry<by){
                rfi=ri;
            }
        }
        if(rfi!=-1){
            cnt++;
            fixedr[rfi]=true;
        }
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
// cerr<<1.0/CLOCKS_PER_SEC<<endl;
using namespace std;
#define N  100000000000007LL
#define MAXN   100005
//ll int dp[1001][100005];
ll int a[405];
ll int dp[405][405];
ll int pre[405];
ll int fun(ll int l,ll int r)
{
if(l==r)
	return 0;
ll int &x=dp[l][r];
if(x!=-1)
	return x;
x=N;
rep(i,l,r)
x=min(x,fun(l,i)+fun(i+1,r)+pre[r]-pre[l-1]);
return x;
}
int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(10);
ll int n;
cin>>n;
pre[0]=0;
rep(i,1,n+1)
{cin>>a[i];
	pre[i]=pre[i-1]+a[i];
}
memset(dp,-1,sizeof(dp));
cout<<fun(1,n);
}

Measured memory_bytes: 1536
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // ----------------------
    int n ;
    cin >> n ; 
    ll sum = 0  , m = 0;
    for (int i = 0; i < n; i++)
    {
        ll a; cin >> a;
        sum+=a;
        m = max(m , a);
    }
    sum-=m;
    sum+=(m/2);
    cout << sum << endl ;
    return 0;
}



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

bool solve() {
    string S;
    cin >> S;
    for ( int i = 0; i < S.size(); i++ ) {
        for ( int j = i; j < S.size(); j++ ) {
            string a;
            a.append(S.substr(0,i));
            a.append(S.substr(j,S.size()-j));
            if ( a == "keyence" ) return true;
        }
    }
    return false;
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string a,b;
	cin>>a>>b;
	bool h=false;
	rep(i,a.size()){
		if(a==b)h=true;
		a=a.substr(1)+a[0];
	}
	if(h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}







Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define ull unsigned long long

int main (){
  ull N, K, S;
  cin >> N >> K >> S;
  ull A[N];
  for (int i = 0; i < K; ++i) {
    A[i] = S;
  }
  for (int i = K; i < N; ++i) {
    if (S > 100) {
      A[i] = S - 1;
    } else {
      A[i] = S + 1;
    }
  }

  for (int i = 0; i < N; ++i) {
    if (i != 0) {
      cout << " ";
    }
    cout << A[i];
  }
  return 0;
}


Measured memory_bytes: 2048
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,lb,ub,mid;
string s,ans="",lst,fis;
vector <int> r,b;

bool check()
{
	cout.flush();
	cout<<"? ";
	for(int i=mid;i<=mid+n-1;i++) cout<<i<<' ';
	cout<<endl;
	cin>>s;
	if(s=="-1") exit(0);
	return s!=fis;
}

int main()
{
	cin>>n;
	cout.flush();
	cout<<"? ";
	repn(i,n) cout<<i<<' ';
	cout<<endl;
	cin>>s;
	fis=s;
	rep(i,n*2) ans.pb('a');
	lb=1;
	ub=n+1;
	while(lb<ub)
	{
		mid=(lb+ub)/2;
		if(check()) ub=mid;
		else lb=mid+1;
	}
	ub=lb+n-2;
	repn(i,n*2)
	{
		if(lb<=i&&i<=ub) continue;
		cout.flush();
		cout<<"? ";
		cout<<i<<' ';
		for(int j=lb;j<=ub;j++) cout<<j<<' ';
		cout<<endl;
		cin>>s;
		if(s=="-1") return 0;
		if(s[0]=='R') ans[i-1]='R';
		else ans[i-1]='B';
	}
	repn(i,n*2)
	{
		if(ans[i-1]=='R'&&r.size()<n/2) r.pb(i);
		if(ans[i-1]=='B'&&b.size()<n/2) b.pb(i);
	}
	//cout<<r.size()<<' '<<b.size()<<endl;
	for(int i=lb;i<=ub;i++)
	{
		cout.flush();
		cout<<"? ";
		cout<<i<<' ';
		rep(j,r.size()) cout<<r[j]<<' ';
		rep(j,b.size()) cout<<b[j]<<' ';
		cout<<endl;
		cin>>s;
		if(s=="-1") return 0;
		if(s[0]=='R') ans[i-1]='R';
		else ans[i-1]='B';
	}
	cout<<"! "<<ans<<endl;
	return 0;
}

Measured memory_bytes: 724
#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
	string s,t;
	cin>>s>>t;
	ll c=0;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		c++;
	}
	
	cout<<c<<endl;
}

Measured memory_bytes: 3828
def solve(n, W):
    last = ''
    d = {}
    for w in W:
        if last and last != w[0] or w in d:
            return 'No'
        last = w[-1]
        d[w] = None
    return 'Yes'

_n = int(input())
_W = [input() for _ in range(_n)]
print(solve(_n, _W))

Measured memory_bytes: 3060
import java.util.*;
import java.util.regex.Pattern;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0; i < n; i++){
			String str = sc.next();
			boolean result = Pattern.matches(">'(=+)#(=)+\\~", str);
			if(result){
				String str1 = str.replaceAll(">'(=+)#=+\\~", "$1");
				String str2 = str.replaceAll(">'=+#(=+)\\~", "$1");
				if(str1.length() == str2.length()){
					System.out.println("A");
				}
				else{
					System.out.println("NA");
				}
			}
			else{
				result = Pattern.matches(">\\^(Q=)+\\~\\~", str);
				if(result)
					System.out.println("B");
				else
					System.out.println("NA");
			}
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

bool check(){
	rep(i,b.size()){
		if(b[i]!=i+1)return false;
	}
	return true;
}
void shift(){
	for(int i=b.size()-1;i>=0;i--){
		if(b[i]==0)	b.erase(b.begin()+i);
	}	
}
bool act(){
	
	rep(i,b.size()){b[i]--;}
	int s=b.size();
	shift();
	b.push_back(s);
	if(check())return true;
	else return false;
}
signed main(){
	while(true){
		cin>>N;
		if(N==0)return 0;
		b.clear();
		rep(i,N){int in;cin>>in;b.push_back(in);}
		
		if(check()){cout<<0<<endl;goto end1;}
		rep(t,10000){
			if(act()){cout<<t+1<<endl; goto end1;}
		}
		cout<<-1<<endl;
end1:;
	}

	return 0;

}

Measured memory_bytes: 1236
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static int N;
	static int M;
	static 		ArrayList<ArrayList<Integer>> map;



	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		N = sc.nextInt();
		M = sc.nextInt();
		if(N % 3 == 0 || M % 3 == 0 || (N+M) % 3 == 0 ){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");

		}

	}

}




Measured memory_bytes: 22480
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<vector<ll>> pascals_triangle(int n) {
    vector<vector<ll>> combi(n + 1, vector<ll>(n + 1));
    REP(i, n + 1) REP(j, i + 1) {
        if (j == 0 || j == i) combi[i][j] = 1LL;
        else combi[i][j] = combi[i - 1][j - 1] + combi[i - 1][j];
    }
    return combi;
}

ll gcd(ll m, ll n) {
    return n != 0 ? gcd(n, m % n) : m;
}

ll lcm(ll m, ll n) {
    // If both m and n are large numbers, the result is overflow without parentheses.
    return m * (n / gcd(m, n));
}

void solve() {
    string s;
    cin >> s;
    ll b = 0;
    ll ans = 0;
    REPS(c, s) {
        if (c == 'B') b++;
        else ans += b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 720
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int N;
vector<int> A(30);

bool check(int n, int m){
    if(m == 0){
        return true;
    } 
    else if(n == N) return false;
    else {
        bool ans = check(n + 1, m - A[n]) || check(n + 1, m);
        return ans;
    }
}

int main(){
    cin >> N;
    rep(i, N) cin >> A[i];
    int Q;
    cin >> Q;

    rep(i, Q){
        int m;
        cin >> m;
        if(check(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3092
// 2011/01/14 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1)
		prime[0] = false;
	if(n>=2)
		prime[1] = false;

	for(int i=2; i<n; i++)
		prime[i] = true;

	for(int i=2; i<n; i++){
		if(!prime[i])
			continue;
		for(int j=i+i; j<n; j+=i)
			prime[j] = false;
		if(n<i*i)
			return;
	}
}

int main()
{
	bool prm[1000001];
	eratos(prm, 1000001);

	while(true){
		int n, x;
		cin >> n >> x;
		if(n==0&&x==0)
			break;

		int K[30];
		for(int i=0; i<n; i++)
			cin >> K[i];

		bool T[1000001];
		T[0] = true;
		for(int i=1; i<=x; i++)
			T[i] = false;

		for(int i=0; i<n; i++)
			for(int j=K[i]; j<=x; j++)
				if(T[j-K[i]])
					T[j] = true;

		int ans = -1;
		for(int i=x; i>=0; i--)
			if(T[i]&&prm[i]){
				ans = i;
				break;
			}

		if(ans!=-1)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 2820
import math
from itertools import permutations, combinations,combinations_with_replacement,product

N = int(input())
list_aaa = []
for i in range(N):
    list_aaa.append(list(map(int,input().split())))

def distance_aaa(arg_list):
    result =[]
    for i in range(len(arg_list)-1):
        result.append(math.sqrt((list_aaa[arg_list[i]][0]-list_aaa[arg_list[i+1]][0])**2+(list_aaa[arg_list[i]][1]-list_aaa[arg_list[i+1]][1])**2))
    return sum(result)


loop_x =list(permutations(range(N)))

result_aaa =[]

for i in loop_x:
    result_aaa.append(distance_aaa(i))

print(sum(result_aaa)/math.factorial(N))


Measured memory_bytes: 9332
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}





void test_case() {

    
    string ans = "";

    int n , m;
    cin>>n>>m;


    rep(i,n) {
        ans = ans + ".";
    }

    rep(i,m) {
        int a , b;
        cin>>a>>b;


        int pos = a-1;

        if(ans[pos] != '.' && ans[pos] != '0' + b) {
            cout<<-1<<endl;
            return;
        }

        if(ans[pos] == '.') {
            ans[pos] = '0' + b;
        }
        // cout<<ans<<endl;
    }

    if(n == 1 && ans[0] == '.') {
        ans = "0";
    }

    else if(ans[0] == '.') {
        ans[0] = '1';
    }

    for(int i=0; i<n; i++) {
        if(ans[i] == '.') {
            ans[i] = '0';
        }
    }

    if(n != 1 && ans[0] == '0') {
        cout<<-1<<endl;
        return;
    }

    cout<<ans<<endl;
    




    



}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    //    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
   //  cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 3656
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll>ans,anss;
    while(true){
        ll b;
        cin>>b;
        if(b==0)break;
        for(ll i=100000;i>=0;i--){
            if((b-i*(i+1)/2)%i==0&&(b-i*(i+1)/2)/i+1>=1){
                anss.push_back(i);
                ans.push_back((b-i*(i+1)/2)/i+1);
                break;
            }
        }
        //n*(1+n)/2+(m-1)*n　1からnこの等差数列にmを足す
        /*
        ll r=2;
        ll sum=1;
        for(ll l=1;l<=b;l++){
            while(sum+r<=b){
                sum+=r;
                r++;
            }
            if(sum==b){
                ans.push_back(l);
                anss.push_back(r-l);
                break;
            }
            sum-=l;
        }
        */
    }
    rep(i,ans.size()){
        cout<<ans[i]<<" "<<anss[i]<<"\n";
    }
}



Measured memory_bytes: 3212
#include <iostream>
using namespace std;
int main(){
    int x, y;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0)
           break;
        if(x < y)
           cout << x << " " << y << endl;
        else
           cout << y << " " << x << endl;
    }
    return 0;
}

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

int X, N, p[102];
int minVal=0x3f3f3f3f, numVal;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> X >> N;
    for (int i = 1; i <= N; i++)cin >> p[i];
    for (int i = -1000; i <= 1000; i++) {
        bool isinp = false;
        for (int j = 1; j <= N && !isinp; j++) {
            if(i==p[j]) isinp = true;
        }
        if(isinp) continue;
        int val = abs(X-i);
        if(val<minVal){
            minVal = val;
            numVal = i;
        }
    }
    cout << numVal << '\n';
    return 0;
}

Measured memory_bytes: 3648
n, m = map(int, input().split())
a1 = []
bn = []

for i in range(m):
  a, b = map(int, input().split())
  if a == 1:
    a1.append(b)
  elif b == n:
    bn.append(a)
la = len(a1)
lb = len(bn)
sa = set(a1)
sb = set(bn)
if len(sa | sb) < la + lb:
  print('POSSIBLE')
  exit()
print('IMPOSSIBLE')

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

int main(){
  int N,K;
  cin >>N>>K;
  
  int h;
  int ans = 0;
  rep(i,0,K){
    cin >> h;
    if(h>=K) ans++;
  }
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef pair<int,int> pii;
int main() {
  int n, k;
  cin >> n >> k;
  if ((n-1)*(n-2)/2 < k) {
    cout << -1 << el;
    return 0;
  }
  vector<pii> edge;
  vector<pii> buang;
  for (int i = 2; i < n; i++) {
    for (int j = i+1; j <= n; j++) {
      buang.push_back({i, j});
    }
  } 
  for (int i = 2; i <= n; i++) edge.push_back({1, i});
  int res = (n-1)*(n-2)/2 - k;
  for (int i = 0; i < res; i++) {
    edge.push_back(buang[i]);
  }
  cout << edge.size() << el;
  for (auto edgy: edge) {
    cout << edgy.first << " " << edgy.second << el;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2);
  return x*POW(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll POL(ll n, ll x)
{
  if(x==0)return 0;
  if(x==POW(2,n+2)-3)return POW(2,n+1)-1;
  if(x<=POW(2,n+1)-2)return POL(n-1,x-1);
  if(x==POW(2,n+1)-1)return POL(n-1,x-2)+1;
  if(x<=POW(2,n+2)-4)return POL(n-1,x-POW(2,n+1)+1)+1+POL(n-1,POW(2,n+1)-3);
}

int main()
{
  ll n,x;
  cin >> n >> x;
  printf("%lld",POL(n,x));
}

Measured memory_bytes: 256
k = int(input())

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 18;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N][2];
int b[N][2];
int dp[(1 << M)][55];

void upd (int &a, int b) {
	if (a == -1) {
		a = b;
		return;
	}
	if (b == -1) return;
	a = min(a, b);
}

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

	for (int i = 0; i < n; i ++) {
		cin >> a[i][1];
	}
	for (int i = 1; i <	(1 << M); i ++)
		for (int j = 0; j <= 50; j ++)
			dp[i][j] = -1;
	
	for (int msk = 0; msk < (1 << n); msk++) {
		int pos = __builtin_popcount(msk);
		int cnt = 0;

		for (int i = n - 1; i >= 0; i --) {
			if (msk & (1 << i)) {
				cnt++;
				continue;
			}
			int now = i + cnt;
			now -= pos;
			now += cnt;

			for (int j = 0; j <= a[i][now%2]; ++j) if (dp[msk][j] != -1) {
				upd(dp[msk | (1 << i)][a[i][now%2]], dp[msk][j] + now - cnt);
			}
		}
	}

	int res = -1;
	for (int j = 0; j <= 50; j ++)
		upd(res, dp[(1 << n) - 1][j]);
	cout << res << '\n';

    return Accepted;
}

// B...a

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

n = int(input())
a = list(map(int, input().split()))
a = [[i,0] for i in a]

for i in range(n-1):
    if a[i][0] < a[i+1][0]:
        a[i][1] = -1
    elif a[i][0] > a[i+1][0]:
        a[i][1] = 1

kabu = 0
kane = 1000
for i in range(n):
    if a[i][1] < 0:
        kabu += kane // a[i][0]
        kane = kane % a[i][0]
    elif a[i][1] > 0:
        kane += kabu * a[i][0]
        kabu = 0

kane += kabu * a[i][0]

print(kane)

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n % 10 == 9){
        cout << "Yes" << endl;
        return 0;
    }
    n /= 10;
    if (n % 10 == 9){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
N,M = gets.chomp.split.map(&:to_i)
if N == 1 && M == 1
	p 1
	exit
end
if N == 2 || M == 2
	p 0
	exit
end
if N == 1
	edgeN = 1
else
	edgeN = N - 2
end
if M ==1
	edgeM = 1
else
	edgeM = M - 2
end
p edgeN*edgeM

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


/* macro */
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */


struct Union_Find{
    vector<int> par;
    vector<int> rank;

    Union_Find(int n){
        for(int i = 0; i < n; i++){
            par.push_back(i);
            rank.push_back(0);
        }
    }

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

    void merge(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

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

};

int rangesum(int a){
    return a * (a - 1) / 2;
}

signed main(){

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

    int n, m; cin >> n >> m;



    Union_Find uf = Union_Find(n);

    rep(i,0,m){
        int f, t; cin >> f >> t; f--; t--;
        uf.merge(f, t);
    }

    int c1 = 0, c2 = 0, c3 = 0;

    rep(i,0,n){
        int r = uf.root(i);
        int r0 = uf.root(0);
        int r1 = uf.root(1);

        if(r == r0) c1++;
        if(r == r1) c2++;
        if(r != r0 && r != r1) c3++;

    }



    print(rangesum(max(c1, c2) + c3) + rangesum(min(c1, c2)) - m);




}





Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define ROR(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define F first
#define S second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
typedef long long ll;
const ll N = 1e5 + 5;
#define M 1000000007

int main()
{
    FAST
    ll n;
    cin>>n;
    ll a[n];
    FOR(i,0,n)
    cin>>a[i];
    if(n==1)
    { cout<<a[0]; return 0; }
    
    ll i=0,j=n-1;
    ll sum1=a[i];
    ll sum2=a[j];
    ll ans=abs(sum1-sum2);
    i++;
    j--;
    while(i<=j)
    {
        if(sum1<=sum2)
        { sum1+=a[i]; i++; ans=abs(sum1-sum2); }
        else
        {
            sum2+=a[j]; j--; ans=abs(sum1-sum2);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split();
            int a = int.Parse(st[0]);
            int b = int.Parse(st[1]);
            if(a < 10 && b < 10)
            {
                Console.WriteLine(a * b);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }

Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
    int n,i,r,x,y;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0; i<n; i++)
    {
        r=a[i]%2;
        if(r==0)
        {
            x=a[i]%3;
            y=a[i]%5;
            if((x!=0)&&(y!=0))
            {
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
 
}


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



int main() {
    string s;
    cin>>s;
    string str1,str2;
    str1 = "s";
    str2 = "es";

    if(s[s.size()-1]=='s'){
        s.append(str2);
    }
    if(s[s.size()-1]!='s'){
        s.append(str1);
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3628
while True:
    x , y = (int(i) for i in input().split())
    if x == 0 and y ==0:
            break
    
    for r in range(x):
        
        if r % 2 != 0:
            for z in range(y):
                if z %2 != 0:
                    print('#' ,end ='')
                else :
                    print('.' ,end ='')
            print()   
        else:
            for n in range(y):
                if n %2 != 0:
                    print('.' ,end ='')
                else :
                    print('#' ,end ='')
            print()   
    print()    


Measured memory_bytes: 7016
using System;
class ITP1_9_C
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int st = 0, sh = 0;
        for (int i = 0; i < n; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            switch (string.Compare(input[0], input[1]))
            {
                case 1:
                    st += 3;
                    break;
                case -1:
                    sh += 3;
                    break;
                default:
                    sh++;
                    st++;
                    break;
            }
        }
        Console.WriteLine("{0} {1}", st, sh);
    }
}

Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
	LL n;
	cin >> n;
	if (n % 2 == 1) {
		cout << "0\n";
	} else {
		LL answer = 0;
		LL p = 1;
		while (n / (10 * p) != 0) {
			answer += n / (10 * p);
			p *= 5;
		}
		cout << answer << '\n';
	}
	return 0;
}


Measured memory_bytes: 3628
n, a, b = map(int, input().split())
S = [str(i) for i in range(1, n + 1)]

B = []
for s in S:
    x = 0
    for i in s:
        x += int(i)
    if a <= x <= b:
        B.append(int(s))
        
print(sum(B))

Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, A[3000], a, b;
vector<int>v[3000];

bool f(int x) {
	bool b = false;
	for (int i : v[x]) {
		if (A[i] < A[x] && !f(i)) {
			b = true;
		}
	}
	return b;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 1; i < N; ++i) {
		cin >> a >> b;
		--a;
		--b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i = 0; i < N; ++i) {
		if (f(i)) {
			cout << i + 1 << endl;
		}
	}
}

Measured memory_bytes: 384
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,1);
  //約数の個数＝素数1の出現回数+1 * 素数2の出現回数+1 * ・・・
  //素数の出現回数を保持
  var list = new Array(input+1).fill(0);
  var mod = 1000000007;
  for(var i = 1; i <= input; i++){
    if(i == 1){
      list[1] = 1; continue;
    }else{
      var tmp = i;
      for(var j = 2; j <= tmp;){
        if(tmp % j == 0){
           list[j]++;
          tmp /= j;
        }else{
          j++;
        }
      }
    }
  }
  var output = 1;
  for(var i = 2; i < list.length; i++){
    if(list[i] != 0){
       output = output * (list[i]+1) % mod;
    }
  }
  //myout(list);
  myout(output);
}

Main(myin());


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  vector<ll> A(N + 1);
  vector<ll> B(N);
  each(x, A) in(x);
  each(x, B) in(x);
  ll ans = 0;
  rrep(i, N - 1, -1) {
    ll t1 = min(A[i + 1], B[i]);
    ll t2 = min(A[i], B[i] - t1);
    A[i] -= t2;
    ans += t1 + t2;
  }
  print(ans);
}


Measured memory_bytes: 1792
[n, c] = map(int, raw_input().split())
cs = [None] * c
for i in range(c):
    cs[i] = list()
for i in range(n):
    [s, t, ci] = map(int, raw_input().split())
    cs[ci - 1].append((s, t))
starts = []
ends = []
for i in range(c):
    if len(cs[i]) == 0: continue
    cs[i].sort()
    j = 0
    k = 0
    while j + k < len(cs[i]) - 1:
        a = cs[i][j+k][1]
        b = cs[i][j+k+1][0]
        if a == b:
            k += 1
        else:
            start = cs[i][j][0]
            end = cs[i][j+k][1]
            starts.append(start)
            ends.append(end)
            j += k + 1
            k = 0
    start = cs[i][j][0]
    end = cs[i][j+k][1]
    starts.append(start)
    ends.append(end)
starts.sort()
ends.sort()
i = 0
j = 0
d = 0
while i < len(starts) and j < len(ends):
    if starts[i] < ends[j]:
        i += 1
    elif starts[i] == ends[j]:
        i += 1
    else:
        j += 1
    d = max(d, i - j)
print d


Measured memory_bytes: 20724
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author deepanshu
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASecurity solver = new ASecurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASecurity {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char arr[] = new char[4];
            String n = in.next();
            arr = n.toCharArray();
            for (int i = 0; i < 3; i++) {
                if (arr[i] == arr[i + 1]) {
                    out.println("Bad");
                    return;
                }
            }
            out.println("Good");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    int ans = 0;
    
    for(int i = 0; i < S.size() - 1; i++){
        if(S.at(i) != S.at(i + 1))
            ans++;
    }
    
    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
const ll MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    n = n % 10;
    if (n == 2 || n == 4 || n == 5|| n == 7 || n == 9)
        cout << "hon\n";
    else if (n == 3)
        cout << "bon\n";
    else
        cout << "pon\n";
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a, b;

int main() {
	cin >> n >> a >> b;
	
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
	
	return 0;
}


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

void Main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a, a + 3);
  
  cout << a[2] * 10 + a[1] + a[0] << endl;
}

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

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;

// typedef
typedef long long ll;

// container util
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(c) int((c).size())
#define EACH(i,c) for(auto (i)=(c).begin(); (i)!=(c).end(); ++(i))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

// repetition
#define FOR(i,m,n) for(ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for(ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)

// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl;

// constant
const double    EPS     = 1e-10;
const int       INFTY   = (1<<21);
const ll        MOD     = (ll) 1e9+7;

// clear memory
#define CLR(a) memset((a),0,sizeof(a))

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << " " << __FILE__ << endl;

string solve(int n) {
    vector<int> keys;
    string code;
    REP(i, n) {
        int e; cin >> e;
        keys.PB(e);
    }
    cin >> code;
    REP(i, code.length()) {
        int key = keys[i % n];
        int index = 0;
        if ('a'<= code[i] && code[i] <= 'z') {
            index = code[i] - 'a';
        } else if('A'<= code[i] && code[i] <= 'Z') {
            index = code[i] - 'A' + 26;
        }
        int new_index = (index - key + 52) % 52;
        if(new_index < 26) {
            code[i] = 'a' + new_index;
        } else {
            code[i] = 'A' + new_index - 26;
        }
    }
    return code;
}
int main() {
    while(true) {
        int n; cin >> n;
        if(n == 0) break;
        cout << solve(n) << endl;
    }
    return 0;
}



Measured memory_bytes: 3144
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	int n,A,B;
	cin>>A>>B;
	int powerSocket = 1;
	n = 0;
	while( powerSocket < B){
		powerSocket += A - 1;
		n++;
	}
	cout<<n<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
// #include <algorithm>
// #include <numeric>
// #include <set>
// #include <cmath>
// #include <string>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007

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

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}


int main(int argc, char const *argv[]) {
    int X, A, B;
    cin >> X >> A >> B;
    if (A >= B) {
        cout << "delicious" << endl;
    } else if (B - A <= X) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long mod=(long)1e9+7;
		int n = sc.nextInt(),m=sc.nextInt();
		char arr[][]=new char[n][m];
		for(int i=0;i<n;i++) arr[i]=sc.next().toCharArray();
		long [][]dp=new long [n][m];
		dp[0][0]=1L;
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]=='#')arr[i][j]=0;
				else {
					if(i==0&&j!=0)dp[i][j]=dp[i][j-1];
					else if(i!=0&&j==0)dp[i][j]=dp[i-1][j];
					else if(i==0&&j==0)continue;
					else dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
				}
			}
		}
		pw.println(dp[n-1][m-1]);
		pw.close();		
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}

	}
}


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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  //出力
  if(b - a >= k*2){
    for(int i = 0;i < k;i++){
      cout << a + i << endl;
    }
    for(int i = k - 1;i >= 0;i--){
      cout << b - i << endl;
    }
  }
  else{
    for(int i = 0;i <= b - a;i++){
      cout << a + i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC148
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }
        
        public static void a()
        {
            int ans = 6;
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            Console.WriteLine(ans - a - b);
        }
    }
}


Measured memory_bytes: 11092
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n

for i in range(1, n):
    res = float("inf")
    for j in range(1, min(i, k)+1):
        res = min(res, abs(h[i] - h[i-j]) + dp[i-j])
    dp[i] = res

print(dp[n-1])


Measured memory_bytes: 52448