akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void C();

int main()
{
	C();
	fflush(stdout);
	return 0;
}

static void C()
{
	int X, N;
	getint(X, N);

	std::set<int> pi;
	for (int i = 0; i < N; i++) {
		int p;
		getint(p);
		pi.insert(p);
	}

	int ans1 = X, ans2 = X, ans = X;
	while (1) {
		if (pi.find(ans2) == pi.end()) {
			ans = ans2;
			break;
		}
		if (pi.find(ans1) == pi.end()) {
			ans = ans1;
			break;
		}
		ans2--;
		ans1++;

	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> l(n);
  for(int i=0;i<n;i++) cin >> l[i];
  vector<vector<int>> dp(n+1,vector<int> (k+1,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<k;j++){
      dp[i+1][j+1] = max(dp[i][j+1],dp[i][j]+l[i]);
    }
  }
  cout << dp[n][k] << endl;
}

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

using namespace std;

int main()
{
    int x1, x2, y1, y2, hoge, foo;
    cin >> x1 >> y1 >> x2 >> y2;
    hoge = x2 - x1;
    foo = y2 - y1;
    cout << x2 - foo << " " << y2 + hoge << " " << x1 - foo << " " << y1 + hoge << endl;
    return 0;
}


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

using namespace std;
const int MAXN = 100010;
int nowarn;

int n, a[MAXN];

int main() {
	nowarn = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		nowarn = scanf( "%d", a+i );
	int ans = 0;
	for( int i = 1; i <= n; ++i )
		if( i == a[i] )
			swap( a[i], a[i+1] ), ++ans;
	printf( "%d\n", ans );
	return 0;
}


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

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
    int A, B, C;
    IN(A);
    IN(B);
    IN(C);
    if(B + C <= A) OUT(0);
    else OUT(C - (A - B));
}

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

int a,b,c;
int main(){
  //Mind: if a-b or b-c = 0
  cin >> a >> b >> c;
  if (a == b & b == c){
    cout << "No";
  }
  else if(a-b == 0 || b-c == 0 || a-c == 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	string s, t;
	cin >> s >> t;
	int ls = s.size(), lt = t.size();
	int ans = lt;
	for(int i = 0; i + lt <= ls; ++i){
		int c = 0;
		for(int j = 0; j < lt; ++j){
			c += s[i + j] != t[j];
		}
		chmin(ans, c);
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3596
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

int main() {
    ll N,K,result=0,count=0;
    cin >> N >> K;

    vector<ll> x(N);
    for(ll i=0;i<N;i++){
        cin >> x[i];
    }

    for(ll i=0;i<N;i++){
        result += min(x[i]-0,abs(x[i]-K))*2;
    }

    cout << result << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n,z,w;
    cin >> n >> z >> w;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    if(n==1){
        cout << abs(w-a[0]) << endl;
        return 0;
    }
    if(abs(w-a[n-1]) > abs(a[n-1]-a[n-2])){
        cout << abs(w-a[n-1]) << endl;
    }else{
        cout << abs(a[n-1]-a[n-2]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	LL k, a, b;
	cin >> k >> a >> b;

	LL ans = k + 1;

	LL ans2 = 0;
	//1kai
	if (k >= a + 1) {
		k -= a + 1;
		ans2 += b;
	}
	if (ans2 >= a) {
		ans2 += (k / 2)*(b - a);
		k %= 2;
	}
	ans2 += k;

	cout << max(ans, ans2) << endl;
}

Measured memory_bytes: 256
s = input()

head = int(s[:2])
tail = int(s[2:])

lis = list(range(1, 13))

b_head = head in lis
b_tail = tail in lis

if b_head and b_tail:
  print("AMBIGUOUS")
elif b_head and not b_tail:
  print("MMYY")
elif not b_head and b_tail:
  print("YYMM")
else:
  print("NA")



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k,sum=0;
    cin>>n>>k;
    if(n%k==0) sum=n/k;
    else sum=n/k + 1;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC090
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] hoge = new string[3];
           for(int i = 0; i < 3; i++)
            {
                hoge[i] = Read();
            }

            Console.WriteLine(hoge[0][0].ToString() + hoge[1][1].ToString() + hoge[2][2].ToString());
        }

        public static string Read() { return Console.ReadLine(); }
    }
}


Measured memory_bytes: 13140
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    int a;
    cin >> a;
    cout << a*(1+a+a*a) << endl;
}


Measured memory_bytes: 3612
A,B,C,D = list(map(int,input().split()))
L = [A,B]
M = [C,D]
out = []
if A<=0 and B>=0:
    L.append(0)
if C<=0 and D>=0:
    M.append(0)
for i in L:
    for j in M:
        out.append(i*j)
print(max(out))


Measured memory_bytes: 61760
import java.util.Scanner;

public class Main{
        public static void main(final String[] args){
            final Scanner sc = new Scanner(System.in);
            while(true){
                int height = sc.nextInt();
                int wideth = sc.nextInt();
                if(height + wideth == 0){
                    break;
                }
                for(int j = 0; j < wideth; j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
                for(int i = 0; i < height-2; i++){
                    System.out.printf("#");
                    for(int j = 0; j < wideth-2; j++){
                        System.out.printf(".");
                    }
                    System.out.printf("#");
                    System.out.printf("\n");
                }
                for(int j = 0; j < wideth; j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
                System.out.printf("\n");
            }
            sc.close();
        }
         

}


Measured memory_bytes: 59880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int[] nums = new int[10];

                for (int i = 0; i < 10; i++)
                {
                    nums[i] = int.Parse(input[i].ToString());
                }

                for (int i = 9; i > 0; i--)
                {
                    for (int j = 0; j < i; j++)
                    {
                        nums[j] = (nums[j] + nums[j + 1]) % 10;
                    }
                }
                Console.WriteLine(nums[0]);
            }
        }
    }
}

Measured memory_bytes: 9108
#include <iostream>
#include <cmath>

using namespace std;

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

    float sum = 0;
    for (int j = 0; j < N; ++j) {
        sum += a[j];
    }
    float ave = sum / N;


    int frame = 0;
    float min_distance = INT64_MAX;
    for (int k = 0; k < N; ++k) {
        if(fabs(a[k] - ave) < min_distance){
            min_distance = fabs(a[k] - ave);
            frame = k;
        }
    }

    cout << frame << endl;
}

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

int main()
{
  int x, n;
  std::cin >> x >> n;
  std::unordered_set<int> ng;
  for (int i = 0; i < n; ++i)
  {
    int temp;
    std::cin >> temp;
    ng.emplace(temp);
  }
  int ans = 0;
  int offset = 0;
  while(true)
  {
    if (ng.find(x - offset) == ng.end())
    {
      ans = x - offset;
      break;
    }
    else if (ng.find(x + offset) == ng.end())
    {
      ans = x + offset;
      break;
    }
    else
    {
      offset++;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
	int N;
	unsigned int num = 0;

	cin >> N;

	for (int i = 0; i < N; i++){
		int temp;
		cin >> temp;
		while(temp % 2 == 0){
			temp /= 2;
			num++;
		}
	}

	cout << num << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
//cout << std::fixed << std::setprecision(15) << y << endl;

int main(){
    string S;
    cin >> S;
    ll ans=0;
  	ll tmp=0;
    rep(i,0,S.size()){
        if(S[i] == 'R') tmp++;
        else tmp = 0;
      	ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
n=list(input())
k=len(n)-1

x=0
for i in range(2**k):
    v=[""]*k
    for j in range(k):
        if ((i>>j)&1):
            v[j]="+"
    ans=""
    for a,b in zip(n,v+[""]):
        ans+=(a+b)
    x+=eval(ans)
print(x)

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

int main(){
    int a =0,b=0;
    cin >> a >> b;
    if(a<b){
        cout << "a < b" << endl;
    }
    if(a==b){
        cout << "a == b" << endl;
    }
    if(a>b){
        cout << "a > b" << endl;
    }
    return 0;
}


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

int main(){
        int i;
        int j;
        j = 0;
        while(1){
                cin >> i;
                if (i == 0) break;
                j++;
                if (j > 10000) break;
                cout << "Case" << " " << j << ":" << " " << i << endl;
        }
        return 0;
}

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

int main()
{
    /* ------- 宣言と入力 ------- */

    int N;

    cin >> N;

    int X[N];

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

    /* ------- 計算 ------- */

    sort(X, X + N);

    int d[100] = {0};
    int min = 10000 * 100;

    for (int P = 1; P <= 100; P++)
    {
        for (int i = 0; i < N; i++)
        {
            d[P] += pow(X[i] - P, 2);
        }
        if (d[P] < min)
        {
            min = d[P];
        }
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
// りゅうせいの解答1 
// void hikaku(int *h, int *a, int N)
// {
// 	int count = 0;
// 	for (int i = N-1; i > 0; --i)
// 	{
// 		if (h[i] <= h[i-1])
// 		{
// 			count++;
// 			if ((i == 1) && (*a < count))
// 			{
// 				*a = count;
// 			}
// 		}

// 		else
// 		{
// 			if (*a < count)
// 			{
// 				*a = count;
// 			}

// 			count = 0;
// 		}

// 	}
// }

// int main(int argc, char const *argv[])
// {
// 	int N;
// 	scanf("%d", &N);
// 	int H[N];

// 	for (int i = 0; i < N; ++i)
// 	{
// 		scanf("%d", &H[i]);
// 	}

// 	int ans = 0;

// 	hikaku(H, &ans, N);

// 	printf("%d\n", ans);

int main(int argc, char const *argv[])
{
	int N;
	scanf("%d", &N);
	int H[N];

	for (int i = 0; i < N; ++i)
	{
		scanf("%d", &H[i]);
	}

	int ans = 0;

	int count = 0;
	for (int i = N-1; i > 0; --i)
	{
		if (H[i] <= H[i-1])
		{
			count++;
			if ((i == 1) && (ans < count))
			{
				ans = count;
			}
		}

		else
		{
			if (ans < count)
			{
				ans = count;
			}

			count = 0;
		}

	}

	printf("%d\n", ans);

// 別解
// int main(void) 
// {
//     int n, count = 0, max = 0;
//     scanf("%d", &n);
//     int h[n];
//     for(int i = 0; i < n; i++) {
//         scanf("%d", &h[i]);
//         if(i > 0) {
//             if(h[i-1] >= h[i]) {
//                 count++;
//             } else {
//                 if(max < count) {
//                     max = count;
//                 }
//                 count = 0;
//             }
//         }
//     }
//     if(max < count) max = count;
//     printf("%d\n", max);
//     return 0;
// }


	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	rep(i, N) cin >> H[i];

	bool ok = true;
	int H_MAX = 0;
	rep(i, N-1){
		H_MAX = max(H_MAX, H[i]);
		if(H_MAX - H[i+1] > 1) ok = false;
	}

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



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
map<int,char>S;
string s;
int Q,i,j,d=1,q,f;
char c;
main(){
	cin>>s>>Q;
    for(auto c:s)S[j++]=c;
	while(Q--){
		cin>>q;
		if(q==1)d=!d;
		else{
			cin>>f>>c;
			S[d+f==2?--i:j++]=c;
		}
	}
	while(i<j)cout<<S[d?i++:--j];
}

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


int main(void){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
    	cin >> vec.at(i);
    }
    int sum = 0;
    for(int i_a = 0; i_a < N - 1; i_a++){
    	for(int i_b = i_a + 1; i_b < N; i_b++){
        	sum += vec.at(i_a) * vec.at(i_b);
            //cout << i_a << "," << i_b << "," << sum << endl;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

int main(){
  ll H, N, sum=0;
  ll A[100000];

  scanf("%lld%lld", &H, &N);

  for (int i = 0; i < N; i++)
  {
      scanf("%lld", A+i);
      sum += A[i];
  }
  
  sortdown(A, N);

  if (sum >= H)
  {
    printf("Yes\n");
  }
  else
  {
      printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
//vector<vector<int>> data(3, vector<int>(4));

int main() {
	string N;cin >> N;
	for (ll i = 0;i <= N.size()/2;i++) {
		if (N[i] != N[N.size() - i - 1]) {
			cout << "No" << endl;
			break;
		}
		if (i == N.size()/2 )cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  for(int i=1;i<=1000;i *= 2){
    if(i <= n) continue;
    cout << i/2 << endl;
    break;
  }
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int w,n,index = 1;
	
	while(1){
		int ans_v = 0,ans_w = 0;
		VI value,weight;

		cin >> w;
		if(w == 0) break;
		cin >> n;

		VII dp(n + 1,VI (w + 1,-1));
		dp[0][0] = 0;

		rep(i,n){
			int a,b;
			char ch;
			cin >> a >> ch >> b;
			value.pb(a);
			weight.pb(b);
		}

		rep(i,n){
			rep(j,w + 1){
				if(dp[i][j] == -1) continue;
				dp[i + 1][j] = max(dp[i + 1][j],dp[i][j]); //valle[i]テ」ツつ津ィツカツウテ」ツ?陛」ツ?ェテ」ツ??・ツ?エテ・ツ青?
				if(j + weight[i] <= w){ //value[i]テ」ツつ津ィツカツウテ」ツ?凖・ツ?エテ・ツ青?
					dp[i + 1][j + weight[i]] = max(dp[i + 1][j + weight[i]],value[i] + dp[i][j]);
					
				}
			}
		}

		rep(i,dp[n].size()){
			if(dp[n][i] > ans_v){
				ans_v = dp[n][i];
				ans_w = i;
			}
		}		

		cout << "Case " << index++ << ':' << endl;
		cout << ans_v << endl << ans_w << endl;
	}

	return 0;
}

Measured memory_bytes: 5180
#include <stdio.h>
double mean(double n)
{
	double sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=i;
	}
	return sum/n;
}
int main()
{
	double n,k;
	scanf("%lf %lf",&n,&k);
	double arr[200005];
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&arr[i]);
	}
	int l=1;
	int r=k;
	double sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=mean(arr[i]);
	}
	double max=sum;
	while(r!=n)
	{
		r++;
		sum=sum-mean(arr[l])+mean(arr[r]);
		l++;
		if(sum>max)
		max=sum;
	}
	printf("%lf",max);
	return 0;
}

Measured memory_bytes: 1664
h,w = map(int, input().split())
if h%2==0:
  print(int(h*w/2))
elif h==1 or w==1:
  print(1)
else:
  if w%2==0:
    print(int(h*w/2))
  else:
    hh = int((h+1)/2)
    x = int((w-1)/2)
    print(int(h*x+hh))


Measured memory_bytes: 3060
//    .------------------------------------------------------------.
//    |   _  __   ___    ___    ___   _  _    ___     _     _  _   |
//    |  | |/ /  / _ \  |   \  |_ _| | \| |  / __|   /_\   | \| |  |
//    |  | ' <  | (_) | | |) |  | |  | .` | | (_ |  / _ \  | .` |  |
//    |  |_|\_\  \___/  |___/  |___| |_|\_|  \___| /_/ \_\ |_|\_|  |
//    |             ___    ___     _     _  _    ___               |
//    |            / _ \  | _ \   /_\   | \| |  / __|              |
//    |           | (_) | |   /  / _ \  | .` | | (_ |              |
//    |            \___/  |_|_\ /_/ \_\ |_|\_|  \___|              |
//    |                 ___   ___    ___    ___                    |
//    |                | _ ) | __|  / __|  / _ \                   |
//    |                | _ \ | _|  | (_ | | (_) |                  |
//    |                |___/ |___|  \___|  \___/                   |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2019-10-08 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("tune=native")

#define vec vector
#define prq priority_queue
#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

//    .-----------------------------------------.
//    |        ___   _   _    ___   ___         | 
//    |       | _ ) | | | |  / __| / __|        | 
//    |       | _ \ | |_| | | (_ | \__ \        | 
//    |       |___/  \___/   \___| |___/        | 
//    |  ___   ___    ___    ___    _  _   ___  | 
//    | | _ ) | __|  / __|  / _ \  | \| | | __| |
//    | | _ \ | _|  | (_ | | (_) | | .` | | _|  | 
//    | |___/ |___|  \___|  \___/  |_|\_| |___| |
//    |                                         | 
//    '-----------------------------------------'

int n;
vec<vec<vec<ld>>> dp;

ld solve(int s1,int s2,int s3)
{
    int sum=s1+s2+s3;
    if(!sum)
        return 0;
    if(dp[s1][s2][s3]>=0)
        return dp[s1][s2][s3];
    ld res=(ld)n/sum;
    if(s1)
        res+=(ld)s1/sum*solve(s1-1,s2,s3);
    if(s2)
        res+=(ld)s2/sum*solve(s1+1,s2-1,s3);
    if(s3)
        res+=(ld)s3/sum*solve(s1,s2+1,s3-1);
    return dp[s1][s2][s3]=res;
}

int main()
{
    scanf("%d",&n);
    dp.assign(n+1,vec<vec<ld>>(n+1,vec<ld>(n+1,-1)));
    vec<int> s(3);
    for(int i=0;i<n;++i)
    {
        int a;
        scanf("%d",&a);
        ++s[a-1];
    }
    printf("%.12Lf\n",solve(s[0],s[1],s[2]));
}



Measured memory_bytes: 431488
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N,L;
	cin >> N >> L;
	string s;
	vector<string> S;

	int t;
	for (t = 0; t < N; t++) {
		cin >> s;
		S.push_back(s);
	}
	sort(S.begin(), S.end());
	for (t = 0; t < N; t++) {
		cout << S.at(t);
		
	}



	
}


Measured memory_bytes: 256
import java.util.Scanner;
     
    public class Main {
        public static void main(String args[]) {
            char[] ch = "abcdefghijklmnopqrstuvwxyz".toCharArray();
     
            Scanner scan = new Scanner(System.in);
     
            long n = scan.nextLong();
     
            StringBuilder sb = new StringBuilder();
            int t;
            for (; n > 0; n = (n - 1) / 26) {
                t = (int) ((n - 1) % 26);
                sb.append(ch[t]);
            }
     
            System.out.println(sb.reverse().toString());
        }
    }



Measured memory_bytes: 35612
#include<iostream>
using namespace std;
int main(){
	long long maxn=1000000001;
	string a,b;
	cin>>a>>b;
	for(long long i=0;i<=a.size()-b.size();i++){
		long long sum=0;
		for(long long j=i;j<i+b.size();j++){
			if(a[j]!=b[j-i]){
				sum++;
			}
		}
		maxn=min(maxn,sum);
	}
	cout<<maxn<<endl;
	return 0;
}

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




int answer(int64_t n){
  if (n==1){
    return 1;
  }
  else {
    return (n*answer(n-1))%(1000000007);
  }
}
  

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


  cout<<answer(N);
  
  
}










Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<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 chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
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,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1)cout<<1<<endl;
    else if(h%2==0||w%2==0)cout<<h*w/2<<endl;
    else cout<<h*w/2+1<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int N,i,j,manzoku=0;
scanf("%d",&N);
int A[N+1],B[N+1],C[N+1];
C[N]=0;
for(i=0;i<N;i++){scanf("%d",&A[i]);}
for(i=0;i<N;i++){scanf("%d",&B[i]);}
for(i=0;i<N-1;i++){scanf("%d",&C[i]);}

for(j=0;j<N;j++){
manzoku+=B[A[j]-1];
if((0<j<N) && ((A[j-1]+1)==A[j])){
manzoku+=C[A[j-1]-1];
}
}
printf("%d",manzoku);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	cout << a[n/2]-a[n/2-1];
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    double n;cin>>n;
    vector<vector<vector<double> > >dp(910,vector<vector<double> >(310,vector<double>(310)));
    dp[0][0][0]=1.0;
    ll x=0,y=0,z=0;
    rep(i,n){
        ll a;cin>>a;
        if(a==1)x++;
        if(a==2)y++;
        if(a==3)z++;
    }
    double ans=0.0;
    rep(i,x+y*2+z*3){
        ll cnt=0.0;
        rep(j,310){
            rep(k,310){
                if(dp[i][j][k]==0.0)continue;
                cnt+=dp[i][j][k];
                double l=i-j-k;
                //cout<<i<<' '<<j<<' '<<k<<':'<<dp[i][j][k];
                if(l<0)continue;
                double f3=z-j;
                double f2=y+j-k;
                double f1=x+k-l;
                double f0=l;
                dp[i+1][j+1][k]+=dp[i][j][k]*(f3/(n-f0));
                dp[i+1][j][k+1]+=dp[i][j][k]*(f2/(n-f0));
                dp[i+1][j][k]+=dp[i][j][k]*(f1/(n-f0));
            }
        }
        //cout<<endl;
        rep(j,310){
            rep(k,310){
                if(dp[i][j][k]==0.0)continue;
                double l=i-j-k;
                if(l<0)continue;
                double f3=z-j;
                double f2=y+j-k;
                double f1=x+k-l;
                double f0=l;
                double b=f1+f2+f3;
                if(b==0)continue;
                ans+=dp[i][j][k]*n/b;
            }
        }
    }
    cout<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 695296
#include <bits/stdc++.h>
using namespace std;
int  n;
int main() {
  cin>>n;
  double y=n,x;
  if(n % 2==0){  x=y/2/y;
    cout<<fixed<<setprecision(9)<<x; return 0;
     } else 
     if(n==1)
     cout<<fixed<<setprecision(9)<<1;
     else if (n%2==1) 
     cout<<fixed<<setprecision(9)<<((y-1)/2+1)/y;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b, c;
int main() {
    cin >> a >> b >> c;
    int m1 = a, m2 = b;
    if (c < a) swap(a, c);
    if (c < b) swap(b, c);
    cout << a * b / 2 << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;

int n, m;
vector <int> v[100001];
int dp[100001] = {0}, vis[100001] = {0};
int ans = 0;

void dfs(int node)
{
	vis[node] = 1;
	int len = 0;
	int i;
	fr(i,0,v[node].size())
	{
		if(vis[v[node][i]] == 0) dfs(v[node][i]);
		dp[node] = max(dp[node], dp[v[node][i]] + 1);
		ans = max(dp[node], ans);
	}
}
signed main()
{
	//FILEIO
 	start_routine
	
	cin>>n>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
	}

	int i;
	fr(i,1,n + 1)
	{
		if(!vis[i]) dfs(i);
	}
	cout<<ans;
 	end_routine
}

Measured memory_bytes: 9344
N = int(input())
A = [0] + [int(s) for s in input().split(' ')]

B = [0] * (N + 1)
count = 0
ret = []
for i in range(N, 0, -1):
    ai = A[i]
    ii = i
    total = 0
    while ii <= N:
        total += B[ii]
        ii += i
    
    if total % 2 == ai:
        continue
    else:
        B[i] = 1
        count += 1
        ret.append(i)

print(count)
print(' '.join(str(i) for i in ret))


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x, y, z;

    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << "\n";

    return 0;
}

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

int main() {
	int A, B;
	while (cin >> A >> B, A && B) cout << (B - A) % 1000 % 500 / 100 << ' ' << (B - A) % 1000 / 500 << ' ' << (B - A) / 1000 << endl;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (bit & (1LL << i))
#define BIT_COUNT(bit) (__builtin_popcount(bit))

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> using VVVV = std::vector<std::vector<std::vector<std::vector<T>>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline void print_2vec(const std::vector<std::vector<T>> &v) { for (int i = 0; i < v.size(); ++i) { for (int j = 0; j < v[0].size(); ++j) { if (j != 0) { std::cout << " "; } std::cout << std::setw(13) << std::left << v[i][j]; } std::cout << "\n";}}
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template<class T> inline std::vector<T> unique(std::vector<T> v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); return v; }
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) { return n * (2 * s + (n - 1) * d) / 2; }

const int INF = 1 << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


LL solve(LL K, LL A, LL B) {
    if (A >= B) {
        return K + 1;
    }

    LL ans = K + 1;
    FOR(i, 0, K + 1) {
        LL b = 1;
        b += i;

        if (b < A) {
            continue;
        }

        LL rest = K - i;
        LL num = rest / 2;

        ans = max(ans, b + (B - A) * num);
    }

    return ans;

}

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

	LL K, A, B;
	cin >> K >> A >> B;
	print(solve(K, A, B));

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 36
typedef struct{
  char mark,num;
}card;
int main()
{
  int n,i,j,l,k=1,mini;
  card A1[N],A2[N],a;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf(" %c%c",&A1[i].mark,&A1[i].num);
  }
  for(i=0;i<n;i++)
  {
    A2[i]=A1[i];
  }

  for(i=0;i<=n-1;i++)
  {
    mini = i;
    for(j=i;j<=n-1;j++)
    {
      if(A2[j].num < A2[mini].num)
        {
          mini = j;
        }
    }
      a = A2[i];
      A2[i] = A2[mini];
      A2[mini] = a;
  }
  for(i=0;i<n;i++)
  {
    for(j=n-1;j>=i;j--)
    {
      if(A1[j].num < A1[j-1].num)
      {
        a=A1[j];
        A1[j]=A1[j-1];
        A1[j-1]=a;
      }
    }
  }
  for(l=0;l<n;l++)
  {
    if(l)
      printf(" ");
    printf("%c%c",A1[l].mark,A1[l].num);
  }
  printf("\nStable\n");
  for(i=0;i<n;i++)
  {
    printf("%c%c",A2[i].mark,A2[i].num);
    if(i!=n-1)
      printf(" ");
  }
  for(i=0;i<n;i++)
  {
    if(A1[i].mark!=A2[i].mark)
      k=0;
  }
  if(k!=0)
    printf("\nStable\n");
  else
    printf("\nNot stable\n");
  return 0;
}



Measured memory_bytes: 2052
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int  n, x, min, max;
    scanf("%d", &n);
    scanf("%d", &x);
    min  = x;
    max = -999999999;

    for (int i = 0; i < n-1; i++){
        scanf("%d", &x);
        max = (x-min > max) ? x-min : max;
        min = (x > min) ? min : x;
    }
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,0,-1,1,-1,-1,1,2,0,-2,0};
const int dy[]={0,1,-1,0,1,1,-1,-1,0,2,0,-2};
const int INF = 1<<30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
struct node{
	int id;
	int dist;
	int v;
	node(){}
	node(int _id,int _dist,int _v){
		id = _id;
		dist = _dist;
		v = _v;
	}
};
struct data{
	int id;
	int prev;
	double t;
	int v;
	data(){}
	data(int _id,int _prev,double _t,int _v){
		id = _id;
		t = _t;
		prev = _prev;
		v = _v;
	}
	bool operator<(const data &a)const{
		if(t == a.t)return v > a.v;
		return t > a.t;
	}
};
vector <node> Graph[32];
int main(){
	int n,m;
	while(scanf("%d%d",&n,&m),(n|m)){
		rep(i,32){
			Graph[i].clear();
		}
		int s,g;
		scanf("%d%d",&s,&g);
		--s;--g;
		rep(i,m){
			int x,y,d,c;
			scanf("%d%d%d%d",&x,&y,&d,&c);
			--x;--y;
			Graph[x].PB(node(y,d,c));
			Graph[y].PB(node(x,d,c));
		}

		priority_queue <data> Q;
		double memo[32][32][32];
		rep(i,32){
			rep(j,32){
				rep(k,32){
					memo[i][j][k] = 99999999.9;
				}
			}
		}
		Q.push(data(s,s,0.0,0));
		while(!Q.empty()){
			data d = Q.top();Q.pop();
			//cout <<"# " << d.id << " " << d.t << " " << d.v << "\n";
			if(memo[d.id][d.prev][d.v] < 99999999.9)continue;
			memo[d.id][d.prev][d.v] = (double)d.t;
			rep(i,Graph[d.id].size()){
				if(Graph[d.id][i].id == d.prev)continue;
				reps(k,-1,2){
					if(d.v+k <= 0)continue;
					if(Graph[d.id][i].v >= d.v+k){
						Q.push(data(Graph[d.id][i].id,d.id,(double)d.t+(double)Graph[d.id][i].dist/(double)(d.v+k),d.v+k));
					}
				}
			}
		}
		double ans = 99999999.9;
		rep(i,n){
			ans = min(ans,memo[g][i][1]);
		}
		if(ans == 99999999.9){
			puts("unreachable");
		}
		else cout << fixed << setprecision(5) << ans << "\n";
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _ % MOD
#define __ %= MOD

#define each(it, s) for (auto it = s.begin(); it != s.end(); ++it)
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.begin(), v.end(), greater<auto>())
#define fill(a) memset(a, 0, sizeof(a))

#define swap(a, b) \
	{              \
		a = a + b; \
		b = a - b; \
		a = a - b; \
	}
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repA(i, a, n) for (ll i = a; i <= (n); ++i)
#define repD(i, a, n) for (ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) << endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)                                 \
	{                                         \
		rep(i, a.size()) cout << a[i] << " "; \
		cout << endl;                         \
	}
#define mark(v) cout << "Here--" << v << endl;

const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1)
			res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
} // modular exponent

int main()
{
	ios_base::sync_with_stdio(false); // don't use printf and scanf
	cin.tie(NULL);					  // cout<<fixed<<setprecision
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = INF;
	repA(i, -100, 100)
	{
		ll sum = 0;
		rep(j, n) sum += power(a[j] - i, 2);
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

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

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

	long double a[n], dp[n+1][n+1];

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

    //dp[0][0]=1;

    for (int i = 0; i <= n; ++i)
	for(int j=0;j<=n;j++)
		 dp[i][j]=1;
         
	for (int i = 1; i <=n; ++i)
	{   	 
		  	dp[i][0]=dp[i-1][0]*(1-a[i-1]);
            dp[0][i]=dp[0][i-1]*(a[i-1]);
		  
	}

	for (int i = 1; i <= n; ++i)
	{
		for(int j=1;j<=n;j++)
		{   dp[i][j]=0;
			if((i+j)<=n)
            dp[i][j]=dp[i-1][j]*(1-a[i+j-1])  + dp[i][j-1]*a[i+j-1];
		}
	}
    
    long double ans=0;

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

			//cout<<setprecision(19)<<dp[i][j]<<"  ";
            if(i+j==n  && j>i)
            	ans+=dp[i][j];
		}
		//cout<<endl;

    }		

    cout<<setprecision(15)<<ans;



	return 0;
}

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

int main(){
	int n,d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	rep(i,n)rep(j,d) cin >> x[i][j];
	int ans = 0;
	rep(i,n)rep(j,i){
		int sq = 0;
		rep(k,d){
			int s = x[i][k] - x[j][k];
			sq +=s*s;
		}
		int s = sqrt(sq)+0.5;
		if(s*s == sq) ans++;
	}
	cout << ans << endl;
}


// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3728
#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 ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << 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 = 200005;

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

int main(){
    ii3(x, y, z);
    swap(x, y); swap(x, z);
    outs(x); outs(y); outs(z); out("");
}

Measured memory_bytes: 256