akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL

using namespace std;
using llong = long long;

int main()
{
	IOS;
	int accnt = 0, wacnt = 0, tlecnt = 0, recnt = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		string s;
		cin >> s;
		if (s == "AC") accnt++;
		else if (s == "WA") wacnt++;
		else if (s == "TLE") tlecnt++;
		else recnt++;
	}
	cout << "AC x " << accnt << endl;
	cout << "WA x " <<  wacnt << endl;
	cout << "TLE x " << tlecnt << endl;
	cout << "RE x " <<recnt << endl;

	return 0;	
}



Measured memory_bytes: 3628
from bisect import bisect_left, bisect_right
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
neg_end = bisect_left(A, 0)
pos_start = bisect_right(A, 0)

pos_cnt = N - pos_start
neg_cnt = neg_end
zero_cnt = N - (pos_cnt + neg_cnt)

neg_pairs_cnt = pos_cnt * neg_cnt
zero_pairs_cnt = zero_cnt * (pos_cnt + neg_cnt) + (zero_cnt * (zero_cnt-1) // 2)

if K <= neg_pairs_cnt:
  # X以下のpairはK個以上あるか？
  ok, ng = 0, -10**18
  while abs(ok - ng) > 1:
    X = (ok+ng) // 2
    or_higher_cnt, r = 0, pos_start
    # それぞれのnegごとに尺取り法
    for l in range(neg_end):
      while r < N and A[l] * A[r] > X:
        r += 1
      # positive_integers - (max_point - positive_start_index)
      or_higher_cnt += pos_cnt - (r - pos_start)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X
  print(ok)

elif K <= neg_pairs_cnt + zero_pairs_cnt:
  print(0)

else:
  K -= (neg_pairs_cnt + zero_pairs_cnt)
  ok, ng = 10**18, 0
  while abs(ok - ng)> 1:
    X = (ok+ng) // 2
    or_higher_cnt = 0

    r = N - 1
    for l in range(pos_start, N):
      while r < N and A[l] * A[r] > X and l < r:
        r -= 1
      or_higher_cnt += max(0, r-l)

    l = 0
    for r in range(neg_end-1, -1, -1):
      while l < N and A[l] * A[r] > X and l < r:
        l += 1
      or_higher_cnt += max(0, r-l)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X

  print(ok)

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

int main () {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if (A >= K) { //AだけでOK
    cout << K;
  } else if (A + B >= K) { //A全部とB何枚かで足りる
    cout << A;
  } else { // A全部とB全部とC何枚か
    int count = A + B;
    int rest = K - count;
    cout << A - rest;
  }
}

Measured memory_bytes: 3624
package main
import (
        "bufio"
        "fmt"
        "os"
        "strings"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
	input := nextLine()
	rec := strings.Split(input, " ")
	var hoge []int

	for _, c := range rec{
		tmp, _ := strconv.Atoi(c)
		hoge = append(hoge, tmp)
	}

	fmt.Printf("%d %d\n",hoge[0]*hoge[1],2*(hoge[0]+hoge[1]))
}




Measured memory_bytes: 1092
//while_sample.cpp
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
int a,b,d,r;
double f;
cin >> a >> b;
r = a%b;
d = (a-r)/b;
f = (double)a/b;
cout << d << " " << r << " "; cout << fixed << setprecision(8) << f << endl;
}



Measured memory_bytes: 3280
import heapq
N , M = map(int,input().split())
X = list(map(int,input().split()))
X.sort(reverse=True)
diff = []
heapq.heapify(diff)
for i in range(len(X) - 1):
    heapq.heappush(diff , -1 * (X[i] - X[i + 1]))
for _ in range(N - 1):
    if not diff:
        print("0")
        exit()
    else:
        heapq.heappop(diff)

print(-1 * sum(diff))

Measured memory_bytes: 13960
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1e9+7;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int T[5];
int32_t main()
{
    speed
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")
            T[1]++;
        else if(s=="WA")
            T[2]++;
        else if(s=="TLE")
            T[3]++;
        else if(s=="RE")
            T[4]++;
    }
    cout<<"AC x "<<T[1]<<"\n";
    cout<<"WA x "<<T[2]<<"\n";
    cout<<"TLE x "<<T[3]<<"\n";
    cout<<"RE x "<<T[4];
    return 0;
}


Measured memory_bytes: 3656
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().parse::<usize>().unwrap();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut a: Vec<i32> = buf.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap())
        .collect();
    a.sort();
    println!("{}", a[n - 1] - a[0]);
}


Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        ArrayList<Goods> list = new ArrayList<Goods>();
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        for (int i = 0; i < N; i++) {
            list.add(new Goods(sc.nextInt(), sc.nextInt()));
        }
        new knapsackSolver(list, W);
    }
}

class knapsackSolver {
    ArrayList<Goods> list = new ArrayList<Goods>();
    int W;

    knapsackSolver(ArrayList<Goods> list, int W) {
        this.list = list;
        this.W = W;
        list.sort(Comparator.comparing(Goods::getCostperformance).reversed());
        System.out.println(solve(new int[list.size()], 0L));
    }

    long solve(int[] fix, long tempAns) {
        long z = 0;
        long sumWeight = 0;

        for (int i = 0; i < list.size(); i++) {
            if (fix[i] == 1) {
                Goods goods = list.get(i);
                z += goods.value;
                sumWeight += goods.weight;
            }
        }
        if (sumWeight > W)// 実行不可能
            return tempAns;

        for (int i = 0; i < list.size(); i++) {
            if (fix[i] != 0)
                continue;
            Goods goods = list.get(i);
            if (sumWeight + goods.weight < W) {
                z += goods.value;
                sumWeight += goods.weight;
            } else if (sumWeight + goods.weight == W) {
                z += goods.value;
                sumWeight += goods.weight;
                if (z > tempAns) {
                    tempAns = z;
                    return tempAns;// 更新
                }
                return tempAns;// 終端
            } else {
                double check = z + (double) (W - sumWeight) / goods.weight * goods.value;
                sumWeight = W;
                if (check < tempAns) {
                    return tempAns;// 終端
                }
                int[] nex = fix.clone();
                nex[i] = 1;
                tempAns = solve(nex, tempAns);
                nex[i] = -1;
                tempAns = solve(nex, tempAns);
                return tempAns;// 分岐
            }
        }
        if (z > tempAns) {
            tempAns = z;
            return tempAns;// 更新
        }
        return tempAns;// 終端
    }
}

class Goods {
    final int weight;
    final int value;
    final double costperformance;

    Goods(int weight, int value) {
        this.weight = weight;
        this.value = value;
        this.costperformance = (double) value / weight;
    }

    public double getCostperformance() {
        return costperformance;
    }

    @Override
    public String toString() {
        return weight + ":" + value + ":" + costperformance;
    }
}

Measured memory_bytes: 339752
#include<iostream>
using namespace std;
int N,P;
int cnt[10101];
int T[2<<17];
string s;
main()
{
	cin>>N>>P>>s;
	long ans=0;
	if(P==2||P==5)
	{
		for(int i=0;i<N;i++)
		{
			if((s[i]-'0')%P==0)ans+=i+1;
		}
	}
	else
	{
		T[N-1]=1;
		for(int i=N-1;i--;)
		{
			T[i]=T[i+1]*10%P;
			///printf("%d ",T[i]);
		}
		int now=0;
		cnt[0]=1;
		for(int i=N-1;i>=0;i--)
		{
			now=(now+(s[i]-'0')*T[i])%P;
			ans+=cnt[now]++;
		}
	}
	///puts("");
	cout<<ans<<endl;
}


Measured memory_bytes: 1412
#include<iostream>
using namespace std;
 
int main(void) {
  string s, t, u;
  cin >> s >> t >> u;
  
  char c = s.at(0);
  char d = t.at(1);
  char e = u.at(2);
  
  cout << c << d << e << endl;
  //cout << s.at(0)+t.at(1)+u.at(2) << endl;
}

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

int main(void){
    int w, h, n;
    cin >> w >> h >> n;
    int sum[w][h];
    for (int i = 0; i < w;i++){
        for (int j = 0; j < h;j++){
            sum[i][j] = 1;
        }
    }
        for (int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            switch (c){
            case 1:
                for (int j = 0; j < h;j++){
                    for (int k = 0; k < a;k++){
                        sum[k][j] = 0;
                    }
                }
                break;
            case 2:
                for (int j = 0; j < h; j++){
                    for (int k = a; k < w; k++){
                        sum[k][j] = 0;
                    }
                }
                break;
            case 3:
                for (int j = 0; j < b; j++){
                    for (int k = 0; k < w; k++){
                        sum[k][j] = 0;
                    }
                }
                break;
            case 4:
                for (int j = b; j < h; j++){
                    for (int k = 0; k < w; k++){
                        sum[k][j] = 0;
                    }
                }
                break;
            }
        }
        int cnt = 0;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w;j++){
                if(sum[j][i]==1)
                    cnt++;
            }
        }

        cout << cnt << endl;
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<iomanip>
#include<math.h>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main() {
    long long N;
    static long a[300000] = { 0 }, b[300000] = { 0 };
    cin >> N;
    for (int x = 0; x < N - 1; x++) {
        cin >> a[x];
        b[a[x]-1]++;
    }
    for (int x = 0; x < N; x++)cout << b[x] << endl;
    return 0;
}

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

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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 F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

double calc(double y,double r,int t){
	if(t==1){
		double ret=(1+y*r/100);
		return ret;
	}
	else{
		double ret=pow(1+r/100,y);
		return ret;
	}
}


void mainmain(){
	int n;
	while(cin>>n,n){
		int y;
		cin>>y;
		vector<pair<double,int>> v(n);
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			v[i]=mkp(calc(y,b,c),a);
		}
		sort(ALL(v));
		cout<<v.back().S<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3328
s = input()
plus_num = len(s) - 1
if plus_num == 0:
    print(s)
    exit(0)

f = '0%sb' % plus_num
plus_list = [format(i, f) for i in range(2 ** plus_num)]
result = 0

for plus in plus_list:
    ans = 0
    tmp = int(s[0])
    for i, v in enumerate(s[1:]):
        if plus[i] == '0':
            tmp = tmp * 10 + int(v)
        else:
            ans += tmp
            tmp = int(v)
    ans += tmp
    result += ans

print(result)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

  if((a+b)!=15 && (a*b)!=15){
    cout << 'x' << endl;
  }
  else if((a+b)== 15){
    cout << '+' << endl;
  }
  else{
    cout << '*' << endl;
  }
}

Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let a = Int(readLine()!)!
    let s = readLine()!
    
    if a >= 3200 {
        print(s)
    } else {
        print("red")
    }
}

main()


Measured memory_bytes: 7596
#include<bits/stdc++.h>
#define    ll          long long int
#define    sz          200010
#define    md          1000000007
#define    py          printf("YES\n")
#define    pn          printf("NO\n")
#define    sc1(a)      scanf("%lld",&a)
#define    sc2(a,b)    scanf("%lld %lld",&a,&b)
#define    pv(a)      printf("%lld\n",a)
using namespace std;




int main()
{


     ll a ,b;

     cin>>a>>b;

     if(b>=a)cout<<"unsafe"<<endl;
     else
        cout<<"safe"<<endl;


    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
long double pi = 3.14159265358979323;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int max(int b,int a){if(b>a)return b;else return a;}
int min(int b,int a){if(b<a)return b;else return a;}
int Abs(int b){return max(b,-b);}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){return a.second<b.second;}

int32_t main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)
 
int main(int argc, char **argv) {
	string s;
	cin >> s;
	cout << "ABC" << s << endl;
	return 0;
}

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

unsigned euclidean_gcd(unsigned, unsigned);
int main()
{
    int N, K, count=0, tmp;
    cin >> N >> K;
    tmp = N;
    while(1){
        if(tmp>=1){
            tmp /= K;
            count++;
        }
        else{
            break;
        }
    }

        cout << count << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);

	if(a%b == 0)return(b);

	else return(gcd(b, a%b));
}

vector<ll> fac(ll n){
    vector<ll> prime;
    ll sq = sqrt(n) + 1;

    for(int i = 2; i <= sq; ++i){
        sq = sqrt(n) + 1;
        if(n%i == 0){
            prime.push_back(i);
            while(n%i == 0)n /= i;
        }
    }

    if(n != 1)prime.push_back(n);

    return prime;
}

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

    ll a[n];
    rep(i, n)cin >> a[i];

    ll g = a[0];
    rep(i, n)g = gcd(g, a[i]);

    if(g != 1){
        cout << "not coprime\n";
        return 0;
    }

    map<ll, ll> mp;
    for(ll a_i : a){
        vector<ll> pr = fac(a_i);

        for(ll p : pr){
            if(mp.count(p) > 0){
                cout << "setwise coprime\n";
                return 0;
            }
            mp[p] = 1;
        }
    }

    cout << "pairwise coprime\n";
}

Measured memory_bytes: 11464
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )

#define INF 1000000000



//typedef long long ll;

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

/*

int binary_search(int* a, int n,int key)
{
	int low, middle, high;

	low = 0, high = n - 1;

	while (low <= high)
	{
		middle = (low + high) / 2;

		if (key < a[middle])
			high = middle - 1;
		else if (key > a[middle])
			low = middle + 1;
		else
			return 1;
	}
	return 0;
}

void reverse(int a[], int b, int e)
{
	int i;

	for (i = 0; i <= (e-b-1) / 2; i++)
	{
		swap(&a[b+i], &a[e - 1 - i]);
	}
}

void CountingSort(int A[],int k,int n)
{
	int B[2000000] = { 0 };

	int i, C[20000] = { 0 };

	for (i = 0; i < n; i++)
		C[A[i]]++;

	for (i = 0; i < k; i++)
		C[i + 1] += C[i];

	for (i = n - 1; i >= 0; i--)
		B[--C[A[i]]] = A[i];

	for (i = 0; i < n; i++)
	{
		printf("%d", B[i]);
		if (i != n - 1)
			printf(" ");
	}
	printf("\n");
}
*/

int partion(int A[], int l, int r)
{
	int i, j, pivot, t;

	i = l - 1;
	j = r;
	pivot = A[r];

	for (;;)
	{
		while (A[++i] < pivot)
			;
		while (i < --j && pivot < A[j])
			;

		if (i >= j)
			break;
		swap(&A[i], &A[j]);
	}

	swap(&A[i], &A[r]);
	return i;
}

void quickSort2(int A[], int l, int r)
{
	int v;

	if (l >= r)
		return;

	v = partion(A, l, r);

	quickSort2(A, l, v-1);

	quickSort2(A, v+1, r);
}

void quickSort(int A[], int n)
{
	quickSort2(A, 0, n - 1);
}

int B[500000];
int count = 0;

void mergeSort(int A[], int low,int high)
{
	int mid, i, j, k;

	if (low >= high)
		return;

	mid = (low + high) / 2;

	mergeSort(A, low, mid);
	mergeSort(A, mid + 1, high);

	for (i = low; i <= mid; i++)
		B[i] = A[i];

	for (i = mid + 1, j = high; i <= high; i++, j--)
		B[i] = A[j];

	i = low, j = high;

	for (k = low; k <= high; k++)
	{
		count++;
		if (B[i] <= B[j])
			A[k] = B[i++];
		else
			A[k] = B[j--];
	}
}

void print(int A[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		printf("%d", A[i]);
		if (i != n - 1)
			printf(" ");
	}
	printf("\n");
}

int main()
{
	int i,n;
	int S[500000];

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		scanf("%d", &S[i]);

	mergeSort(S, 0, n - 1);

	print(S, n);

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


Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
    return 0;
}


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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    ll x;
    cin >> x;

    ll fh = x/500;
    x=x%500;
    ll h = x/5;

    cout << fh*1000+h*5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int a, b, c; scanf("%d %d %d", &a, &b, &c);
	printf("%d\n", max(10 * a + b + c, max(a + 10 * b + c, a + b + 10 * c)));
	return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Z, W = MAP()
a = LIST()

if N == 1:
	print(abs(a[0]-W))
else:
	print(max(abs(a[-1]-W), abs(a[-2]-a[-1])))


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

int main(){
  string s;
  int n,ans,p=1,m,c,x,i;
  cin>>n;
  for(int l=0;l<n;l++){
    ans=0;
    m=c=x=i=0;
    for(int j=0;j<2;j++){
      cin>>s;
      for(int k=0;k<s.size();k++){
	if('2'<=s[k] && s[k]<='9'){
	  p=atoi(&s[k]);
	  continue;
	}
	if(s[k]=='m'){
	  ans+=1000*p;
	  p=1;
	  continue;
	}
	if(s[k]=='c'){
	  ans+=100*p;
	  p=1;
	  continue;
	}

	if(s[k]=='x'){
	  ans+=10*p;
	  p=1;
	  continue;
	}

	if(s[k]=='i'){
	  ans+=p;
	  p=1;
	  continue;
	}
      }
    }
    i=ans%10;
    ans-=i;
    x=(ans%100)/10;
    ans-=x*10;
    c=(ans%1000)/100;
    ans-=c*100;
    m=ans/1000;
    if(m!=0 && m!=1) cout<<m;
    if(m!=0) cout<<'m';
    if(c!=0 && c!=1) cout<<c;
    if(c!=0) cout<<'c';
    if(x!=0 && x!=1) cout<<x;
    if(x!=0) cout<<'x';
    if(i!=0 && i!=1) cout<<i;
    if(i!=0) cout<<'i';
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3200
#include <iostream>

using namespace std;
int main (){
    int N;
    cin >> N ;
    int count=0;
    int M=N;
    while(M>0){
        count+=M%10;
        M/=10;
    }
    bool jud=false;
    if(N%count==0) jud=true;
    if(jud) cout << "Yes" <<"\n";
    else cout << "No" <<"\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 200100;
int a[maxn];
int main(){
  int n;
  scanf("%d", &n);
  for(int e = 0; e < n; e++) scanf("%d", a + e);
  sort(a, a + n);
  set<pair<int, int> > b;
  for(int e = 0; e < n; e++) b.insert({a[e], e});
  int ans = 0;
  for(int e = n - 1; e >= 0; e--){
    auto me = b.lower_bound({a[e], e});
    if(me != b.end() && me->first == a[e] && me->second == e){
      long long lg = 1;
      while(a[e] >= lg) lg *= 2;
      int diff = (int)(lg - a[e]);
      auto nme = b.lower_bound({diff, -1});
      if(nme != b.end() && nme->first == diff && nme->second != e){
        b.erase(b.lower_bound({a[e], e}));
        b.erase(b.lower_bound({diff, -1}));
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N (1<<18)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define SI 1001
using namespace std;
typedef long long ll;
typedef pair<int,bool> P;
typedef pair<P,P> PP;

int n, l;
string s[100];

int main(){
    cin >> n >> l;
    rep(i,n) cin >> s[i];
    sort(s,s+n);
    rep(i,n) cout << s[i];
    cout << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end(), greater<int>());
	long long x[2] = { 0,0 };
	int j = 0;
	for (int i = 0; i < N - 1; i++) {
		if (A[i] == A[i + 1]) {
			x[j] = A[i];
			i++;
			j++;
		}
		if (j == 2) break;
	}
	cout << x[0] * x[1] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(a+b==15)
	{
		cout<<"+"; 
	}
	else if(a*b==15)
		{
			cout<<"*"; 
		}
		else
		{
			cout<<"x";
		}
}
	

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

int main()
{
  int n; cin >> n;
  int m; cin >> m;
  for (int i=m/n; i>=1; i--) {
    if ((m-i)%i == 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  
  if(A + B == 3) {
    cout << 3; 
  } else if (A + B == 4) {
    cout << 2;
  } else if (A + B == 5) {
    cout << 1;
  }
  
  return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
graph = []
for i in range(H+2):
    if i == 0 or i == H+1 :
        graph.append(["." for i in range(W+2)])
    else:
        a = ["."] + list(input()) + ["."]
        graph.append(a)

"""
##となっていれば良い　反対に#が独立して存在する場合にはNo
"""
for i in range(1,H+1):
    for j in range(1,W+1):
        if graph[i][j] == "#":
            if "#" in [graph[i][j+1],graph[i][j-1],graph[i+1][j],graph[i-1][j]] :
                pass
            else : 
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;
 
int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n & 1) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}
 
int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return (ans + mod) % mod;
}
 
int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}
 
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
 
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
 
bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int n;
string ans;
signed main() {
	cin >> n;
	while(n != 0) {
		if((n & 1)) {
			n--;
			ans += "1";
		}
		else {
			ans += "0";
		}
		n /= -2;
	}
	if(ans.empty()) ans = "0";
	reverse(all(ans));
	cout << ans << endl;
}


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

int main() {
   long long int n;cin>>n;
   long long int sum=0;
    for(long long int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;
    
	return 0;
}

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

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

     string s;

     cin>>s;

     int xx=0;

     for(int i=0 ; i< n ; i++){
         if(s[i]=='W')
           xx++;

     }

     int ans=0;

     for(int j=n-1 , i=1; i<=xx ; i++,j--  ){
        if(s[j]=='R')
            ans++;
     }

     cout<<ans<<endl;







}


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

using namespace std;

long long C[26][26];
void pre(){
    memset(C, 0, sizeof C);
    C[0][0] = 1;
    for (int i = 1; i < 26; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            C[i][j] = C[i-1][j] + C[i-1][j-1];
        }
    }
}

void solve() {
    int n; cin >> n;
    vector<int> prime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
    vector<int> cnt(100, 0);
    auto decomp = [&](int x){
        for (int p: prime) {
            int e = 0;
            while (x % p == 0) {
                e++;
                x/=p;
            }
            cnt[p] += e;
            if (x == 1) break;
        }
    };
    for (int i = 1; i <= n; i++) {
        decomp(i);
    }
    int c3 = 0, c5 = 0, c15 = 0, c25 = 0, c75 = 0;
    for (int p: prime) {
        if (cnt[p] >= 2) c3++;
        if (cnt[p] >= 4) c5++;
        if (cnt[p] >= 14) c15++;
        if (cnt[p] >= 24) c25++;
        if (cnt[p] >= 74) c75++;
    }
    pre();
    int res = C[c5][2]*max(c3-2, 0) + c15*max(c5-1, 0) + c25*max(c3-1, 0) + c75;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main() {
	// your code goes here
	long long int n;
	cin >> n;
	vector<long long> a(n + 1), b(n);
	for(int i = 0; i <= n; i++){
		cin >> a.at(i);
	}
	for(int i = 0; i < n; i++){
		cin >> b.at(i);
	}
	long long int sum = 0;
	for(int i = 0; i < n; i++){
		//cout << sum << endl;
		if(a.at(i) > b.at(i)){
			sum += b.at(i);
			a.at(i) -= b.at(i);
			continue;
		}else{
			sum += a.at(i);
			b.at(i) -= a.at(i);
			a.at(i) = 0;
			if(a.at(i + 1) > b.at(i)){
				sum += b.at(i);
				a.at(i + 1) -= b.at(i);
			}else{
				sum += a.at(i + 1);
				a.at(i + 1) = 0;
				b.at(i) -= a.at(i + 1);
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cctype>
#include<cstring>
const int maxn=25010,maxm=410,mod=1000000007;
int n,k,m,tt;
int a[maxn];
int ar[maxn],nm,mx;
int fc[maxn];
int f[maxn][maxm],g[maxn][maxm],fl[maxn],fr[maxn];
int In() {
	register char c;
	for(;c=getchar(),c!='-'&&!isdigit(c););
	register bool f=c=='-';
	register int s=f?0:c-'0';
	for(;c=getchar(),isdigit(c);)s=s*10+c-'0';
	return f?-s:s;
}
int pw(register int x,register int y=mod-2) {
	register int s=1;
	for(;y;x=1ll*x*x%mod,y>>=1)y&1?s=1ll*s*x%mod:0;
	return s;
}
int main() {
	fc[0]=1;
	for(register int i=1;i<=25000;++i)fc[i]=1ll*fc[i-1]*i%mod;
	n=In(),k=In(),m=In();
	for(register int i=1;i<=m;++i)a[i]=In();
	tt=1ll*(n-m+1)*pw(k,n-m)%mod;
	for(register int i=1;i<=m;++i) {
		if(i>k) --ar[a[i-k]]==0?--nm:0;
		++ar[a[i]]==1?++nm:0;
		ar[a[i]]>mx?mx=ar[a[i]]:0;
		if(nm==k) return printf("%d\n",tt),0;
	}
	if(mx>1) {
		register int pf=0,sf=0;
		memset(ar,0,sizeof ar);
		for(register int i=1;i<=m;++i)if(++ar[a[i]]==2) {
			pf=i-1;
			break;
		}
		memset(ar,0,sizeof ar);
		for(register int i=m;i;--i)if(++ar[a[i]]==2) {
			sf=m-i;
			break;
		}
		f[0][pf]=1,fl[0]=1;
		for(register int i=1;i<=n;++i) {
			for(register int j=1;j<k;++j)f[i][j]=1ll*f[i-1][j-1]*(k-j+1)%mod;
			register int s=0;
			for(register int j=k;--j;)f[i][j]=(f[i][j]+(s=(s+f[i-1][j])%mod))%mod;
			fl[i-1]=s;
		}
		g[0][sf]=1,fr[0]=1;
		for(register int i=1;i<=n;++i) {
			for(register int j=1;j<k;++j)g[i][j]=1ll*g[i-1][j-1]*(k-j+1)%mod;
			register int s=0;
			for(register int j=k;--j;)g[i][j]=(g[i][j]+(s=(s+g[i-1][j])%mod))%mod;
			fr[i-1]=s;
		}
		register int s=0;
		for(register int i=0;i<=n-m;++i)s=(s+1ll*fl[i]*fr[n-m-i])%mod;
		return printf("%d\n",(tt-s+mod)%mod),0;
	}
	f[0][0]=1;
	for(register int i=1;i<=n;++i) {
		for(register int j=1;j<k;++j)f[i][j]=1ll*f[i-1][j-1]*(k-j+1)%mod,g[i][j]=1ll*g[i-1][j-1]*(k-j+1)%mod;
		register int s=0,t=0;
		for(register int j=k;--j;)f[i][j]=(f[i][j]+(s=(s+f[i-1][j])%mod))%mod,g[i][j]=(g[i][j]+(t=(t+g[i-1][j])%mod))%mod;
		for(register int j=k;--j>=m;)g[i][j]=(g[i][j]+f[i][j])%mod;
	}
	register int s=0;
	for(register int i=k;--i;)s=(s+g[n][i])%mod;
	s=1ll*s*fc[k-m]%mod*pw(fc[k])%mod;
	return printf("%d\n",(tt-s+mod)%mod),0;
}

Measured memory_bytes: 80768
Point = Struct.new(:x, :y)
LOOPS = 60

def distance(x, y, ps)
  #点群との最大の距離を返す
  max = 0
  ps.each do |p|
    ds = Math.sqrt((p.x - x) ** 2 + (p.y - y) ** 2)
    max = ds if max < ds
  end

  return max
end

def ternary_search_y(x, ps)
  #x, yについて三分探索する
  bottom = 0.0
  top = 1000.0

  LOOPS.times do
    onethree = (top - bottom) / 3
    first = bottom + onethree
    second = bottom + onethree * 2
    ds1 = distance(x, first, ps)
    ds2 = distance(x, second, ps)

    if ds1 > ds2
      bottom = first
    else
      top = second
    end
  end

  #距離を返す
  return distance(x, bottom, ps)
end

def ternary_search(ps)
  #xについて三分探索する
  left = 0.0
  right = 1000.0

  ds1 = 0

  LOOPS.times do 
    onethree = (right - left ) / 3
    first = left + onethree
    second = left + onethree * 2
    ds1 = ternary_search_y(first, ps)
    ds2 = ternary_search_y(second, ps)

    if ds1 > ds2
      left = first
    else
      right = second
    end
  end

  return ds1
end

def main
  n = gets.chomp.to_i
  points = []
  n.times do |i|
    input = gets.chomp.split.map(&:to_i)
    points.push(Point.new(x=input[0], y=input[1]))
  end

  puts ternary_search(points)
end

main

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-9; // ?¨±?????????^2
#define LE(n,m) ((n) < (m) + EPS)
#define EQ(n,m) (abs((n)-(m)) < EPS)

namespace std {
  bool operator<(const Point a, const Point b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

// ???p?????????a????????\????????\???
VP tangentPoints(Point a, double ar, Point p) {
  VP ps;
  double sin = ar / abs(p-a);
  if (!LE(sin, 1)) assert(false);  // ????????§NaN???????????????
  double t = M_PI_2 - asin(min(sin, 1.0));
  ps.push_back(a + (p-a)*polar(sin, t));
  assert(!EQ(sin, 1));
  ps.push_back(a + (p-a)*polar(sin, -t));
  return ps;
}

int main(void){
    double px,py,cx,cy,r;
    cin>>px>>py>>cx>>cy>>r;
    VP ps = tangentPoints(Point(cx,cy),r,Point(px,py));
    sort(all(ps));
    rep(k,2)printf("%.9f %.9f\n", ps[k].X,ps[k].Y);
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

ll mod = 1000000007;

int main(){

    int N, M;
    cin >> N >> M;

    vector<ll> ans(N+1);
    for(int i = 0; i < M; i++){
        int d;
        cin >> d;
        ans[d] = -1;
    }

    ans[0] = 1;
    if(ans[1] != -1) ans[1] = 1;
    for(int i = 2; i <= N; i++){
        if(ans[i] == -1) continue;
        ll step1, step2;
        if(ans[i-1] == -1) step1 = 0;
        else step1 = ans[i-1];
        if(ans[i-2] == -1) step2 = 0;
        else step2 = ans[i-2];
        ans[i] = (step1 + step2) % mod;
    }

    cout << ans[N] << endl;

    
}

Measured memory_bytes: 1152
#include <stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == b) {
		if (b == c) {
			printf("1\n");
		}
		else { printf("2\n"); }
	}
	else if (a == c) {
		printf("2\n");
	}
	else if (b == c) {
		printf("2\n");
	}
	else { printf("3\n"); }

	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, l;
	cin >> n >> l;
	vector<string> s(n);

	for (int i = 0; i < n;i++) {
		cin >> s.at(i);
	}

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

	string ans = "";
	for (int i = 0; i < n; i++) {
		ans += s.at(i);
	}

	cout << ans << endl;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a, n;
	cin >> a >> n;
	if (a < n) {
		cout << "0\n";
	}
	else {
		cout << "10\n";
	}
}


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


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

int main() {
    string s;
    cin >> s;
    int n;
    n = s.length();
    int l1, l2, l4;
    l1 = (n - 1) / 2;
    l2 = (n + 3) / 2;
    l4 = n / 2;
    if (n == 3) {
        if (s[0] == s[2]) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, l4) {
        if ((s[i] != s[l1 - i - 1]) || (s[l2 + i - 1] != s[n - i - 1])) {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, n) {
        if (s[i] != s[n - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
ps = sorted(list(map(int, input().split())))
if x not in ps:
    print(x)
else:
    not_ps = [i for i in range(ps[0]-1, ps[-1]+2) if i not in ps]
    ans_min = 1000
    for not_p in not_ps:
        if abs(not_p-x) < ans_min:
            ans = not_p
            ans_min = abs(not_p-x)
    print(ans)

Measured memory_bytes: 9204
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL MOD = 1000000007LL;
using namespace std;

int main() {
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
}

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

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

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

    for (int i = n - 1; i > 0; i--) {
        cout << a[i] << " ";
    }
    cout << a[0] << endl;

    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=21,M=(1<<21)+5;
int trans[M][2],n,aim,len,best;
char st[M];
vi f[N];

void dfs(int k,int now){
	if(k>len){
		int sum=0;
		for(int i=1;i<f[k].size();i++)
			sum+=f[k][i];
		if(sum>=aim)
			len=k,best=now;
	}
	if(k==n)return;
	REP(t,2){
		fill(f[k+1].begin(),f[k+1].end(),0);
		REP(i,f[k].size())
			if(f[k][i])f[k+1][trans[i][t]]+=f[k][i];
		dfs(k+1,(now<<1)|t);
	}
}

int main(){
	read(n),read(aim);
	rep(k,0,n){
		f[k].resize(1<<(n-k+1));
	}
	REP(i,1<<(n+1)){
		int s=i,k=n+1;
		while(k&&!(s>>k&1))k--;
		for(k--;k>=0;k--){
			if(!trans[i][(s>>k)&1])
				trans[i][(s>>k)&1]=(s&((1<<k)-1))|(1<<k);
		}
	}
	rep(k,0,n){
		scanf("%s",st);
		REP(i,1<<k)
			if(st[i]=='1')
				f[0][i|(1<<k)]=1;
	}
	dfs(0,1);
	per(i,len-1,0)
		putchar('0'+(best>>i&1));
	return puts(""),0;
}

Measured memory_bytes: 34176
#include <iostream>
using namespace std;
int main(){
    char suit[4]={'S','H','C','D'};
    int room[4][3][10];
    int num;
    int b,f,r,v;
    cin >> num;
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                room[i][j][k]=0;
            }
        }
    }

    for(int i=0;i<num;i++){ 
        cin>>b>>f>>r>>v;
        room[b-1][f-1][r-1] += v;   
    }

    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout<<" "<<room[i][j][k];
            }
            cout<<endl;
        }
        if(i!=3){
            cout<<"####################"<<endl;
        }
    }
    return 0;

}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

vector<int> path[110000];
bool used[110000];

void check(vector<int>& v1, int pos){
	used[pos]=true;
	v1.push_back(pos+1);
	for(auto to:path[pos]){
		if(used[to])continue;
		check(v1,to);
		return;
	}
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	vector<int> v1,v2;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	check(v1,0);
	check(v2,0);
	reverse(v2.begin(),v2.end());
	v2.pop_back();
	v2.insert(v2.end(),v1.begin(),v1.end());
	cout<<v2.size()<<endl;
	array_show(v2);
}

Measured memory_bytes: 11768
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.NoSuchElementException;

public class Main {

    private static void solve() {
        int n = ni();
        int k = ni();
        char[] s = ns();
        
        s[k - 1] = (char)(s[k - 1] - 'A' + 'a');
        System.out.println(s);
    }

    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            @Override
            public void run() {
                long start = System.currentTimeMillis();
                String debug = args.length > 0 ? args[0] : null;
                if (debug != null) {
                    try {
                        is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
                reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
                solve();
                out.flush();
                tr((System.currentTimeMillis() - start) + "ms");
            }
        }, "", 64000000).start();
    }

    private static java.io.InputStream is = System.in;
    private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
    private static java.util.StringTokenizer tokenizer = null;
    private static java.io.BufferedReader reader;

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

    private static double nd() {
        return Double.parseDouble(next());
    }

    private static long nl() {
        return Long.parseLong(next());
    }

    private static int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = ni();
        return a;
    }

    private static char[] ns() {
        return next().toCharArray();
    }

    private static long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nl();
        return a;
    }

    private static int[][] ntable(int n, int m) {
        int[][] table = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                table[i][j] = ni();
            }
        }
        return table;
    }

    private static int[][] nlist(int n, int m) {
        int[][] table = new int[m][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                table[j][i] = ni();
            }
        }
        return table;
    }

    private static int ni() {
        return Integer.parseInt(next());
    }

    private static void tr(Object... o) {
        if (is != System.in)
            System.out.println(java.util.Arrays.deepToString(o));
    }
}

Measured memory_bytes: 20820