akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

int main()
{
    IOS
    ll a,b;
    cin>>a>>b;
    if((a+b)%2==0)
        cout<<(a+b)/2;
    else
        cout<<"IMPOSSIBLE";
    return 0;
}


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

using namespace std;

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

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

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

  ll N, K;
  cin >> N >> K;

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

  ll c = LLONG_MAX;

  ll tmp = 0;
  for (ll i = 0; i < N - K + 1; i++) {
    ll l = x[i];
    ll r = x[i + K - 1];

    if (l < 0) {
      if (r <= 0) {
        tmp = abs(l);
        cerr << "1 tmp: " << tmp << " l: " << l << " r: " << r << endl;
      } else {
        if (abs(l) < abs(r)) {
          tmp = abs(l) * 2 + r;
          cerr << "2 tmp: " << tmp << " l: " << l << " r: " << r << endl;
        } else {
          tmp = abs(l) + r * 2;
          cerr << "2 tmp: " << tmp << " l: " << l << " r: " << r << endl;
        }
      }
    } else {
      tmp = r;
      cerr << "3 tmp: " << tmp << " l: " << l << " r: " << r << endl;
    }

    c = min(c, tmp);
  }

  cout << c << endl;
  return 0;
}


Measured memory_bytes: 1024
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
string s;
int ans[101010];

int main(){
    cin >> s;
    int n = (int)s.size();
    int renodd = 0, reneven = 1;
    for(int i = 1;i < n;i++){
        if(s[i] == 'R')(i % 2 ? renodd : reneven)++;
        else{
            ans[i] += (i % 2 ? renodd : reneven);
            ans[i - 1] += (i % 2 ? reneven : renodd);
            renodd = 0;
            reneven = 0;
        }
    }
    renodd = ((n - 1) % 2 ? 1 : 0);
    reneven = ((n - 1) % 2 ? 0 : 1);
    for(int i = n - 2;i >= 0;i--){
        if(s[i] == 'L')(i % 2 ? renodd : reneven)++;
        else{
            ans[i] += (i % 2 ? renodd : reneven);
            ans[i + 1] += (i % 2 ? reneven : renodd);
            renodd = 0;
            reneven = 0;
        }
    }
    REP(i, n){
        if(i)cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 1104
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll a, b, c, d;
    std::cin >> a >> b >> c >> d;
    ll ans = std::max(a * d, a * c);
    ans = std::max(ans, b * d);
    ans = std::max(ans, b * c);
    std::cout << ans << std::endl;
    return 0;
}


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

int main()
{
    char a, b;
    cin >> a >> b;
    bool at;
    if (a == 'H')
        at = true;
    if (a == 'D')
        at = false;
    if (at) {
        if (b == 'H')
            cout << "H";
        if (b == 'D')
            cout << "D";
    } else {
        if (b == 'H')
            cout << "D";
        if (b == 'D')
            cout << "H";
    }
}

Measured memory_bytes: 256
N, P = map(int,input().split())
A = list(map(int,input().split()))
even = 0
odd = 0

for i in A:
    if i % 2 == 0:
        even += 1
    else:
        odd += 1
#print(even,odd)

import math
def Perm(n, r):
    return math.factorial(n)//math.factorial(n-r)
def comb(n, r):
    return Perm(n, r)//math.factorial(r)

#print("0,0 = ", comb(0,0))

if P == 0:
    ans = 0
    for x in range(odd+1):
        #print(odd, x)
        if x % 2 == 0:
            ans += comb(odd,x)
    ans *= 2**even
    print(ans)
else:
    ans = 0
    for x in range(odd+1):
        if x % 2 == 1:
            if odd != 0:
                ans += comb(odd,x)
    ans *= 2**even
    print(ans)

Measured memory_bytes: 38384
#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];
    vector<int> check(200);
    for (int i = 1; i <= 200; i++) check[i] = i * i;
    int ans = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i + 1; j < n; j++) {
            vector<int> y = x[i];
            vector<int> z = x[j];
            int dis = 0;
            rep(i, d) {
                int k = abs(y[i] - z[i]);
                dis += k * k;
            }
            bool ok = false;
            for (int i = 1; i <= 200; i++) {
                if (check[i] == dis) ok = true;
            }
            if (ok) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

	int n;
	cin >> n;
	int a[n];
	int b[n];
	int maxv;
	int nextv = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b + n);
	maxv = b[n - 1];
	nextv = b[n - 2];
	for(int i = 0; i < n; i++) {
		if(a[i] == b[n - 1]) {
			cout << nextv << endl;
		}else {
			cout << maxv << endl;
		}
	}
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<cstring>

bool find(const std::string &text, const std::string pattern){
	int text_i=0,pattern_i=0;
	while(text_i<text.size()&&pattern_i<pattern.size()){
		if(text[text_i]==pattern[pattern_i]) {
			text_i++;
			pattern_i++;
		}else{
			pattern_i=0;
			text_i=text_i-pattern_i+1;
		}
	}
	return (pattern_i==pattern.size()?true:false);
}


void decode( std::string &coded_data,int diff){
	for(int i=0;i<coded_data.size();i++){
		if(isalpha(coded_data[i])){
			coded_data[i]-=diff;
			if(!isalpha(coded_data[i])) coded_data[i]+=26;
		}
	}
}

int main(void){
	std::string coded_data;
	while(std::getline(std::cin,coded_data)){
		for(int i=0;i<26;i++){
			decode(coded_data,1);
			if(find(coded_data,"the") || find(coded_data,"this")||find(coded_data,"that"))
				std::cout<<coded_data<<std::endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3156
# 最低でもN-1本の辺があり, これらの辺は頂点間を結ぶ最短経路となっている
# つまり, 距離1の最短経路は少なくともN-1個ある
# また, 頂点のペアはNC2でN*(N-1)//2個ある
# よって, Kとしてあり得るのはK<=N*(N-1)//2-(N-1)=(N-1)*(N-2)//2である

# という風に上限が証明できるけど, グラフを書いてみると
# Kが最大となるのはスター型のときと分かる

# ここで詰んで終わった

# 任意のK組をどうやって作るか... と考えると難しい
# 上限が分かっているのでここから減らす方針で考える
# 真ん中の頂点以外は全てのペアが距離2となっているので
# このペアを辺で繋ぐことで(N-1)*(N-2)//2個から減らしていく

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    pair = (n-1)*(n-2)//2
    res = []
    if pair < k:
        print(-1)
    else:
        for i in range(1, n-1):
            if pair == k:
                break
            for j in range(i+1, n):
                if pair == k:
                    break
                pair -= 1
                res.append([i, j])
        print(n-1+len(res))
        for i in range(1, n):
            print(i, n)
        for a, b in res:
            print(a, b)


if __name__ == '__main__':
    main()

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

int main(){
    int n;
    while(cin >> n, n){
        bool t[2*n+1], h[2*n+1];
        int taro = n, hana = n;
        
        for(int i = 0; i <= 2*n; i++)
            t[i] = false;
        
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            t[x] = true;
        }
        for(int i = 1; i <= 2*n; i++)
            h[i] = !t[i];
        
        bool turn = true;
        int ba = 0;
        while(taro != 0 && hana != 0){
            if(turn){
                int next;
                for(next = ba+1; next <= 2*n; next++){
                    if(t[next]){
                        t[next] = false;
                        break;
                    }
                }
                if(next <= 2*n){
                    ba = next;
                    taro--;
                }else{
                    ba = 0;
                }
            }else{
                int next;
                for(next = ba+1; next <= 2*n; next++){
                    if(h[next]){
                        h[next] = false;
                        break;
                    }
                }
                if(next <= 2*n){
                    ba = next;
                    hana--;
                }else{
                    ba = 0;
                }
            }
            turn = !turn;
        }
        
        cout << hana << endl << taro << endl;
    }
    return 0;
}


Measured memory_bytes: 2996
//WrittenBiDP
//lcs

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define N 26

typedef vector <int> vi;
typedef vector <vi> vvi;

vvi ans;
vi s, t;
vvi pret;

vector <vector <pair <int, int> > > mat;

vvi init(vi s) {
	vvi a;

	a.resize(s.size() + 1);
	for (int i = 0; i <= s.size(); i++) {
		a[i].resize(N);
	}

	for (int i = 1; i <= s.size(); i++) {
		int k = s[s.size() - i];
		for (int j = 0; j < N; j++) {
			if (a[i - 1][j] != 0) a[i][j] = a[i - 1][j] + 1;
		}
		a[i][k] = 1;
	}

	return a;
}

int main() {
	ifstream In("input.txt");
	ofstream Out("output.txt");

	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		s.push_back(str[i] - 'a');
	}
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		t.push_back(str[i] - 'a');
	}
	
	int n = s.size();
	int m = t.size();

	pret = init(t);

	ans.resize(n + 2);
	for (int i = 0; i < n + 2; i++) {
		ans[i].resize(m + 2);
	}

	mat.resize(n + 2);
	for (int i = 0; i < n + 2; i++) {
		mat[i].resize(m + 2);
	}

	if (s[n - 1] == t[m - 1]) {
		ans[n][m] = 1;
		mat[n][m] = {0, 0};
	}
	else {
		mat[n][m] = { n + 1, m };
	}

	for (int i = n; i > 0; i--) {
		for (int j = m; j > 0; j--) {
			if (i == n && j == m) continue;
			//cout << "i=" << i << "  j=" << j << endl;
			//cout << ans[i + 1][j + pret[m - j + 1][s[i - 1]]] << endl;
			//cout << "	" << pret[m - j + 1][s[i - 1]] << endl;
			ans[i][j] = ans[i + 1][j];
			mat[i][j] = { i + 1, j };
			if (pret[m - j + 1][s[i - 1]] != 0) {
				if (1 + ans[i + 1][j + pret[m - j + 1][s[i - 1]]] > ans[i][j]) {
					ans[i][j] = 1 + ans[i + 1][j + pret[m - j + 1][s[i - 1]]];
					mat[i][j] = { i + 1, j + pret[m - j + 1][s[i - 1]] };
				}
			}
		}
	}
	/*
	for (int i = 1; i < m + 2; i++) {
		for (int j = 1; j < n + 2; j++) {
			cout << ans[j][i] << ' ';
		}
		cout << endl;
	}
	*/
	//cout << ans[1][1];

	pair <int, int> p;
	p = { 1, 1 };
	while (true) {
		if (p.first == n + 1 || p.second == m + 1 || p.first == 0 || p.second == 0) break;
		pair <int, int> l = { p.first + 1, p.second };
		pair <int, int> next = mat[p.first][p.second];
		pair <int, int> nul = { 0, 0 };
		if ((mat[p.first][p.second] != l) /*&& (mat[next.first][next.second] != nul)*/) cout << char(s[p.first - 1] + 'a');
		p = next;
	}
	//cin >> n;
	return 0;
	
}

Measured memory_bytes: 106496
open System

let N,M,C=stdin.ReadLine().Split()|>fun c -> int c.[0],int c.[1],int c.[2]
let B=stdin.ReadLine().Split()|>Array.map int
let A=[for i in [0..N-1] do yield (stdin.ReadLine().Split()|>Array.map int)]
[<EntryPoint>]
let main argv =
    let sum = [for i in [0..N-1] do yield ([0..M-1]|>Seq.sumBy(fun c -> (A.[i].[c]*B.[c])))]
    sum
    |>Seq.sumBy(fun s -> if (s+C)>0 then 1 else 0)
    |>printfn "%d"
    0

Measured memory_bytes: 14288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll S;
  cin >> S;
  if(S<=1LL*1e9){
    cout << 0 << " " << 0 << " " << 0 <<" " << S << " " << 1 << " " << 0 << endl;
  }
  else{
    ll a=1LL*1e9;
    ll b=a-S%a;
    if(S%a==0){
      cout << 0 << " " << 0 << " " << a <<" " << 0 << " " << b << " " << S/a << endl;
    }else{
      cout << 0 << " " << 0 << " " << a <<" " << 1 << " " << b << " " << S/a + 1 << endl;
    }
  }
  return 0;
    

}


Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] H = new int[N];
    for (int i = 0; i < N; i++) {
      H[i] = sc.nextInt(); 
    }
    Arrays.sort(H);
    long count = 0;
    for (int i = N-K-1; i >= 0; i--) {
       count += H[i];
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 89020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    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;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int MAXM = 200001;
ll A[MAXM];
ll B[MAXM];

int main(){
    ll N,M,K;cin >> N >> M >> K;
    A[0] = 0;
    Rep(i,N){
        cin >> A[i];
    }
    rep(i,N)A[i+1] += A[i];
    B[0] = 0;
    Rep(i,M)cin >> B[i];
    rep(i,M)B[i+1] += B[i];
    ll cursor = M;
    ll ans = 0;
    rep(i,N+1) {
        ll tmp = A[i] + B[cursor];
        while(tmp > K && cursor>0){
            cursor--;
            tmp = A[i] + B[cursor];
        }
        if(tmp > K)break;
        ll ma = i + cursor;
        ans = max(ma,ans);
    }


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

Measured memory_bytes: 6704
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
#include <chrono>
#include<unordered_map>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 2e5 + 10;

char s[MR];

int main()
{
	scanf("%s", s);
	int n = strlen(s);
	REP(i, n)
		if (s[i] == '?')
			s[i] = 'D';

	printf("%s\n", s);

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 3384
#include<cstdio>
#include<cstring>
#define retrun return
#define cpnst const
#include<set>
#include<cstdlib>
typedef long long ll;
int n;
ll d[111111];
struct pii
{ll x,len;int p,s;};
bool operator<(cpnst pii x,cpnst pii y)
{return x.x<y.x;}
void throwb()
{puts("-1"),exit(0);}
std::multiset<pii>s;
void push(ll x,ll l,int y,int z)
{s.insert(pii{x,l,y,z});}
void pop(ll x,ll l,int y,int z)
{s.erase(s.find(pii{x,l,y,z}));}
void push(pii g)
{s.insert(g);}
void pop(pii g)
{s.erase(s.find(g));}
int x[111111],y[111111];
void print()
{for(register int i=1;i<n;i++)printf("%d %d\n",x[i],y[i]);}
#include<vector>
std::vector<int>v[111111];
ll check(ll s,ll dis=0)
{
	ll ret=dis;
	for(auto t:v[s])
		ret+=check(t,dis+1);
	return ret;
}
int main()
{
	register int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lld",d+i),push(d[i],0,i,1);
	for(i=n-1;i;i--)
	{
		pii rem=*--s.end();
		ll tp=d[rem.p]+2*rem.s-n;
		pii reg=*s.lower_bound(pii{tp,0,0,0});
		if(reg.x^tp)throwb();
		pop(rem);
		if(s.find(reg)==s.end())throwb();
		pop(reg);
		x[i]=rem.p,y[i]=reg.p;
		v[y[i]].push_back(x[i]);
		reg.len+=rem.len+rem.s,reg.s+=rem.s;
		push(reg);
	}int rt=(*--s.end()).p;
	if(check(rt)!=(*--s.end()).x)throwb();
	print();
}
/*
Giving the world a better yourself is giving yourself a better world. 
*/

Measured memory_bytes: 14464
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		Console.WriteLine("A{0}C", s[8]);
	}

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <queue>
using namespace std;
using ll = long long;

ll max(ll x,ll y){
	if(x>y){
		return x;
	}else{
		return y;
	}
}
int main(){
	ll N,big_All=0,small_All=0;
	int array[300030]={};
	ll big_array[300030]={};
	ll small_array[300030]={};
	ll answer=-10000000000000000;
	priority_queue<int,vector<int>,greater<int>>big;//前半
	priority_queue<int>small;//後半
	
	cin >> N;
	for(ll i=1;i<=3*N;i++){
		cin >> array[i];
		if(i<=N){
			big_All+=array[i];
			big.push(array[i]);
		}else if(i>2*N){
			small_All+=array[i];
			small.push(array[i]);
		}
	}
	
	big_array[0]=big_All;
	small_array[N]=small_All;
	for(ll i=1;i<=N;i++){
		big.push(array[N+i]);
		big_All+=array[N+i];
		big_All-=big.top();
		big.pop();
		big_array[i]=big_All;
	}
	for(ll i=1;i<=N;i++){
		small.push(array[2*N-i+1]);
		small_All+=array[2*N-i+1];
		small_All-=small.top();
		small.pop();
		small_array[N-i]=small_All;
	}
	
	for(ll i=0;i<=N;i++){
		answer=max(answer,big_array[i]-small_array[i]);
	}
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 7288
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>

typedef long long ll;
using namespace std;

int main()
{
	int T;
	scanf("%d",&T);

	for(int t=0;t<T;t++){
		double pos[8];
		double eps = 10e-9;
		for(int i=0;i<8;i++){
			scanf("%lf",pos+i);
		}

		bool isok = (pos[0]-pos[2]) * (pos[1+4]-pos[3+4]) 
			== (pos[1]-pos[3]) * (pos[0+4]-pos[2+4]) ? true : false;

		printf("%s\n",isok ? "YES" : "NO");
	}
}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[2000000], ans, dp[2000000], a[2000000],b[2000000];
string str;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[1000000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> str;
	if (str[0] == 'a' || str[0] == 'i' || str[0] == 'e' || str[0] == 'u' || str[0] == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
	return 0;
}


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

int main(){
  int A[3],K; cin>>A[0]>>A[1]>>A[2]>>K;
  int X=1; rep(i,K) X*=3;
  rep(i,X){
    int bit=i;
    int B[3]; rep(i,3) B[i]=A[i];
    rep(j,K){
      B[bit%3]*=2;
      bit/=3;
    }
    if(B[0]<B[1]&&B[1]<B[2]){
      cout<<"Yes\n";
      return 0;
    }
  }
  cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3644
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n,k;
  cin >> n >> k;
  ll v[n];
  ll ans = 0;
  REP(i,n) cin >> v[i];
  for(int s = 0; s<=n; s++){
    for(int t = n-s; t>=0; t--){
      if(k<s+t) continue;
      //cout << s << " " << t << endl;
      vector<ll> vec;
      REP(i,s) vec.push_back(v[i]);
      REP(i,t) vec.push_back(v[n-1-i]);
      sort(vec.begin(),vec.end());
      ll sum = 0;
      REP(i,vec.size()){
        if(vec[i]<0&&i<k-s-t) continue;
        sum += vec[i];
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]){
    int x, y;
    while (1) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) break;
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=300+100;

void solve()
{
	int n;scd(n);
	ll ans=0;
	ll m=0;
	ll mark=0;
	rep1(i,n){
		int d;
		ll c;
		scanf("%d%lld",&d,&c);
		mark+=1ll*d*c;
		m+=c;
	}
	ans+=1ll*(m-1);
	while(mark/10ll){
		ans+=mark/10ll;
		mark=mark/10ll+mark%10ll;
	}
	ac;
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 256
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
const int mod = 1e9 + 7; 

//#define CI cpp_int
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define debug(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int n;
    cin >> n;
    int minn = INT64_MAX;
    for(int i = 1; i <= sqrt(n) + 1; i++) {
    	if(n % i == 0) {
    		int ans = (n / i) - 1 + (i - 1);
    		debug(ans);
    		minn = min(ans, minn);
    	}
    }
    cout << minn << endl;
}
  
int32_t main() {
 
    FAST;

   
    
    Panda();

    return 0; 
} 

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    bool ok = true;
    rep(i,n){
        if(a[i]%2==1) continue;
        if(a[i]%3!=0&&a[i]%5!=0) ok=false;
    }
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll x; cin >>x;
	// (2e9)^(1/5) < 200  && 200^5 <2^63
	auto f5=[](ll a){return a*a*a*a*a; };
	rep2(i, -200, 201) rep2(j, -200, 201){
		if(f5(i) - f5(j) == x){
			cout << i <<" "<< j <<"\n"; return 0;
		}
	}
	return 0;
}


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

int main(){
  string S;
  cin>>S;
  long long N,f,g,ans,u;
  N=S.size();
  f=0;
  vector<long long>a(13),b(13);
  for(int i=0;i<13;i++){
    a[i]=0;
    b[i]=0;
  }
  if(S[0]=='?'){
        for(int i=0;i<10;i++){
          a[i]=1;
        }
    u=10;
  }
  else{
    g=S[0]-'0';
    a[g]=1;
    u=1;
  }
  for(int i=1;i<N;i++){
    if(S[i]!='?'){
      g=S[i]-'0';
   b[(0+g)%13]=a[0];
      b[(1+g)%13]=a[4];
        b[(2+g)%13]=a[8];
        b[(3+g)%13]=a[12];
        b[(4+g)%13]=a[3];
        b[(5+g)%13]=a[7];
        b[(6+g)%13]=a[11];
        b[(7+g)%13]=a[2];
        b[(8+g)%13]=a[6];
        b[(9+g)%13]=a[10];
        b[(10+g)%13]=a[1];
        b[(11+g)%13]=a[5];
        b[(12+g)%13]=a[9];
    }
   else{
     b[9]=u-a[1]-a[5]-a[9];
     b[10]=u-a[5]-a[9]-a[0];
       b[11]=u-a[9]-a[0]-a[4];
       b[12]=u-a[0]-a[4]-a[8];
     b[0]=u-a[4]-a[8]-a[12];
       b[1]=u-a[8]-a[12]-a[3];
       b[2]=u-a[12]-a[3]-a[7];
     b[3]=u-a[3]-a[7]-a[11];
       b[4]=u-a[7]-a[11]-a[2];
       b[5]=u-a[11]-a[2]-a[6];
     b[6]=u-a[2]-a[6]-a[10];
       b[7]=u-a[6]-a[10]-a[1];
       b[8]=u-a[10]-a[1]-a[5];
   }
  u=0;
    for(int i=0;i<13;i++){
     a[i]=b[i]%1000000007;
      b[i]=0;
      u+=a[i];
    }
  }
    cout<<a[5]<<endl;
  }

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

string s,t;

signed main() {
    cin >> s >> t;
    cout << t << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int a[100100],n,pre[100100],suff[100100];


int main()
{
    cin >> n;
    for(int i = 0;i<n;i++)  cin >> a[i];
    pre[0] = a[0];
    suff[n - 1] = a[n - 1];
    for(int i = 1;i<n;i++)  pre[i] = __gcd(a[i] , pre[i - 1]);
    for(int i = n - 2;i>=0;i--)  suff[i] = __gcd(a[i] , suff[i + 1]);
    int Ans = 0;
    for(int i = 0;i<n;i++){
        if(i == 0)  Ans = max(Ans , suff[i + 1]);
        else if(i == n - 1)  Ans = max(Ans , pre[i - 1]);
        else Ans = max(Ans , __gcd(pre[i - 1] , suff[i + 1]));
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  vector<int> counter(26,0);
  char c;
  string w;
  cin>>w;
  REP(i,w.size()){
    counter[w[i]-'a']++;
  }
  REP(i,26){
    if(counter[i]%2==0){
      continue;
    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}



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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



void func(long long N, long long M, std::vector<long long> A){

    lli sum = 0;
    REP(i,0,M)sum+=A[i];

    cout<<max(-1LL,N-sum)<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

Vl A(45), B(45);

int main() {
    ll a, b; cin >> a >> b;
    b++;
    ll r = 2, l = 1;
    Rep(i, 0, 40){
        A[i]+=(a/r)*l;
        if(a%r > l) A[i]+=a%r-l;
        r*=2; l *= 2;
    }
    r = 2, l = 1;
    Rep(i, 0, 40){
        B[i]+=(b/r)*l;
        if(b%r > l) B[i]+=b%r-l;
        r*=2; l *= 2;
    }
    Rep(i, 0, 40){
        B[i]-=A[i];
        B[i]%=2;
    }
    ll u = 1;
    ll ans = 0;
    Rep(i, 0, 40){
        if(B[i]){
            ans += u;
        }
        u *= 2;
    }
    
    co(ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//約数列挙
template <class T>
vector<T> divisor(T x){
	vector<T> res;
	for(T i=1;i*i<=x;i++){
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i){
				res.push_back(x/i);
			}
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int ans=0;
	FOR(i,1,n+1){
		if(i%2){
			if(divisor(i).size()==8) ans++;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

void bubbleSort(string x[], int n);
void selectionSort(string x[], int n);
void stableOr(string x[],string y[], int n);

int main(void)
{
	int n;
	cin >> n;
	string a[36],b[36];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	bubbleSort(a, n);
	cout << "Stable" << endl;
	selectionSort(b, n);
	stableOr(a, b, n);

	return 0;
}

void bubbleSort(string x[], int n)
{
	//バブルソート
	for (int i = n-1; i > 0; --i)
	{
		for (int j = 0; j < i; ++j)
		{
			if(x[j][1] > x[j+1][1])
				x[j].swap(x[j+1]);
		}
	}
	for (int i = 0; i < n-1; ++i)
		cout << x[i] << " ";
	cout << x[n-1] << endl;
}
void selectionSort(string x[], int n)
{
	for (int i = 0; i < n-1; ++i)
	{
		string min_s = x[i];
		int min = i;
		for (int j = i+1; j < n; ++j)
		{
			if(min_s[1] > x[j][1])
			{
				min = j;
				min_s = x[j];
			}
		}
		if(min != i)
			x[i].swap(x[min]);
	}
	for (int i = 0; i < n-1; ++i)
		cout << x[i] << " ";
	cout << x[n-1] << endl;
}
void stableOr(string x[], string y[], int n)
{
	bool flag = true;
	for (int i = 0; i < n; ++i)
	{
		if(x[i] != y[i])
		{
			flag = false;
			break;
		}
	}
	if(flag)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
}


Measured memory_bytes: 3236
#include <cstdio>
#include <cstring>
char s[110000];
int main(){
	scanf("%s",s);
	int l=strlen(s),ans=0;
	for(int i=0;i<l-1;++i)
		if(s[i]!=s[i+1]) ++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
	
		long count = x / 11 * 2;
		
		if(x % 11 == 0) {
			System.out.println(count);
		} else if(x % 11 <= 6) {
			System.out.println(count + 1);
		} else {
			System.out.println(count + 2);
		}
	}
}


Measured memory_bytes: 23252
#pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse2")
 
    #include <bits/stdc++.h>
    #include <vector> 
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace std;
 
    #define int         long long
    #define ll          long long
    #define pb          push_back
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define mp          make_pair
    #define all(a)      (a).begin(),(a).end()
    #define FF           first
    #define SS           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define rep(i,a,b)  for(int i=a;i<b;i++)
     ll hell=1000000007;

     

    int solve(){    
      
int x,k,d;
cin>>x>>k>>d;
int ans=hell*hell;

if(x<=0)x=abs(x);

   int z=x/d;
   if(k<=z){
    x-=k*d;
    ans=x;
   }
   else 
    {
        x-=d*z;
        k-=z;
        if(k&1)
         ans=abs(x-d);
         else ans=x;
    }




cout<<ans<<endl;
      
   return 0;
    }  
 
 
    signed main()
    {    
    
       
  
 
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
 
    int t=1,k=1;                                                                                                                  
    //cin>>t;
   
 
    while(t--)
    {
     
     // cout<<"Case #"<<k++<<": ";
     solve();
     //cout<<endl;
    }
    return 0;
    } 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  string s;
  cin>>s;
  int c=0;
  rep(i,0,6) if(s[i]=='1') c++;
  co(c);
  return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

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

const int MX = 300005, mod = 998244353;
int n, a[MX], k, p[MX];
ll acu[MX];
int st[4 * MX], lz[4 * MX];

void push (int i, int j, int pos) {
	if (i < j) {
		lz[pos * 2] = lz[pos];
		lz[pos * 2 + 1] = lz[pos];
	}

	st[pos] = lz[pos] * (acu[j] - acu[i - 1]) % mod;
	lz[pos] = 0;
}

void update (int i, int j, int pos, int a, int b, int k) {
	if (lz[pos]) push(i, j, pos);

	if (j < a || b < i) return;
	if (a <= i && j <= b) {
		lz[pos] = k;
		push(i, j, pos);
		return;
	}

	int m = (i + j) / 2;
	update(i, m, pos * 2, a, b, k);
	update(m + 1, j, pos * 2 + 1, a, b, k);

	st[pos] = (st[pos * 2] + st[pos * 2 + 1]) % mod;
}

int query (int i, int j, int pos, int a, int b) {
	if (lz[pos]) push(i, j, pos);

	if (j < a || b < i) return 0;
	if (a <= i && j <= b) return st[pos];

	int m = (i + j) / 2;
	return query(i, m, pos * 2, a, b),
		 + query(m + 1, j, pos * 2 + 1, a, b);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> k;

	for (ll i = 1, x = 1; i <= n; i++, (x *= 10) %= mod)
		acu[i] = (x + acu[i - 1]) % mod;

	update(1, n, 1, 1, n, 1);

	while (k--) {
		int l, r, d;
		cin >> l >> r >> d;
		
		swap(l, r);
		l = n - l + 1;
		r = n - r + 1;

		update(1, n, 1, l, r, d);
		cout << MOD(st[1], mod) << endl;
	}

	return 0;
}


Measured memory_bytes: 9300
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<stack>
#include<climits>
#include<cmath>

using namespace std;

#define int long long
#define MOD (1000000007)
#define MINF (-1*(LLONG_MAX-10))
#define INF (LLONG_MAX-10)

signed main(){
    int N;
    int c[10][10]={0};

    cin>>N;
    for(int i=1;i<=N;i++){
        int tmpN=i;
        while(tmpN/10!=0){
            tmpN/=10;
        }
        c[i%10][tmpN%10]++;
    }

    int ans=0;
    for(int i=1;i<=9;i++){
        for(int j=0;j<=9;j++){
            for(int k=1;k<=9;k++){
                for(int l=1;l<=9;l++){
                    if(i==l&&j==k){
                        ans+=c[i][j]*c[k][l];
                    }
                }
            }
        }
    }

    cout<<ans<<endl;
}


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

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

#define INF (1e9)

int A, B;

int main() {
    cin >> A >> B;

    if (A % 2 == B % 2) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
S = gets.chomp
T = gets.chomp
Q = gets.to_i

counterSA = [0]
counterSB = [0]
counterTA = [0]
counterTB = [0]

S.each_char do |s|
  if s == 'A'
    counterSA << counterSA.last + 1
    counterSB << counterSB.last
  else
    counterSA << counterSA.last
    counterSB << counterSB.last + 1
  end
end

T.each_char do |t|
  if t == 'A'
    counterTA << counterTA.last + 1
    counterTB << counterTB.last
  else
    counterTA << counterTA.last
    counterTB << counterTB.last + 1
  end
end

queries = Q.times.map { gets.split.map(&:to_i) }

queries.each do |a, b, c, d|
  sa = counterSA[b] - counterSA[a - 1]
  sb = counterSB[b] - counterSB[a - 1]
  ta = counterTA[d] - counterTA[c - 1]
  tb = counterTB[d] - counterTB[c - 1]

  sumS = sa + 2 * sb
  sumT = ta + 2 * tb

  if (sumS - sumT).abs % 3 == 0
    puts 'YES'
  else
    puts 'NO'
  end
end


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

double rec(int i,int j,int k,int n,vector<vector<vector<double>>>& dp) {
    if (dp[i][j][k] > -1) return dp[i][j][k];
    int s = i+j+k;
    double ret = 0;
    if (k) ret += rec(i,j+1,k-1,n,dp)*k/s;
    if (j) ret += rec(i+1,j-1,k,n,dp)*j/s;
    if (i) ret += rec(i-1,j,k,n,dp)*i/s;
    ret += (double)n/s;
    return dp[i][j][k] = ret;
}

int main() {
    int n;
    vector<int> c(3,0);
    cin >> n;
    vector<vector<vector<double>>> dp(n+1,vector<vector<double>>(n+1,vector<double>(n+1,-1)));
    for (int i = 0;i < n;++i) {
        int a;
        cin >> a;
        c[a-1]++;
    }
    dp[0][0][0] = 0.0;
    cout << setprecision(12) << rec(c[0],c[1],c[2],n,dp) << endl;
    return 0;
}

Measured memory_bytes: 216960