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

using namespace std;
string temp = "01+-*()=";

int A(string&, int&);

int B(string&, int&);

int C(string&, int&);

int C(string& S, int& idx)
{
  int ret = 0;
  if(isdigit(S[idx])) {
    if(isdigit(S[idx + 1]) && S[idx] == '0') throw (0);
    while(isdigit(S[idx])) ret = ret * 2 + S[idx++] - '0';
  } else if(S[idx] == '(') {
    ret = A(S, ++idx);
    if(S[idx] != ')') throw (0);
    ++idx;
  } else if(S[idx] == '-') {
    ret = -C(S, ++idx);
  } else {
    throw (0);
  }
  return (ret);
}

int B(string& S, int& idx)
{
  int ret = C(S, idx);
  while(S[idx] == '*') {
    ret *= C(S, ++idx);
  }
  return (ret);
}

int A(string& S, int& idx)
{
  int ret = B(S, idx);
  while(S[idx] == '+' || S[idx] == '-') {
    if(S[idx] == '+') ret += B(S, ++idx);
    else ret -= B(S, ++idx);
  }
  return (ret);
}

int main()
{
  string S;
  int conv[32];
  memset(conv, -1, sizeof(conv));

  cin >> S;

  vector< char > num;
  for(char& c : S) {
    if(isalpha(c)) num.push_back(c);
  }
  sort(begin(num), end(num));
  num.erase(unique(begin(num), end(num)), end(num));
  for(int i = 0; i < S.size(); i++) {
    if(isalpha(S[i])) conv[i] = lower_bound(begin(num), end(num), S[i]) - begin(num);
  }

  if(num.size() > temp.size()) {
    cout << 0 << endl;
    return (0);
  }
  sort(begin(temp), end(temp));

  vector< string > ss;
  do {
    string T = S;
    for(int i = 0; i < S.size(); i++) {
      if(~conv[i]) T[i] = temp[conv[i]];
    }
    if(count(begin(T), end(T), '=') == 1 && T.front() != '=' && T.back() != '=') {
      ss.push_back(T);
    }
  } while(next_permutation(begin(temp), end(temp)));
  sort(begin(ss), end(ss));
  ss.erase(unique(begin(ss), end(ss)), end(ss));

  int ret = 0;
  for(string& al : ss) {
    string L = "", R = "";
    bool which = false;
    for(int i = 0; i < al.size(); i++) {
      if(al[i] == '=') {
        which = true;
        continue;
      }
      (which ? R : L) += al[i];
    }
    R += "$";
    L += "$";
    int idx;


    try {
      int ll = A(L, idx = 0);
      if(idx + 1 != L.size()) continue;
      int rr = A(R, idx = 0);
      if(idx + 1 != R.size()) continue;
      ret += ll == rr;
    } catch(int e) {}
  }
  cout << ret << endl;
}

Measured memory_bytes: 5912
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
const ll TARGET = (1LL << 32) - 1LL;

template <typename T>
T Max(T val1, T val2) {
    return val1 > val2 ? val1 : val2;
}

template <typename T, typename... Args>
T Max(T val, Args... arg) {
    T result = Max(arg...);
    return Max(val, result);
}

template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

const int MAXN = 500005;
int n, m, k;
int w, h;
struct Entry {
    ll v;
    int id;
    Entry(ll v, int id) : v(v), id(id) {}
    bool operator<(const Entry& other) const { return v < other.v; }
};

ll arr[MAXN];
bool vis[MAXN];
int lf[MAXN], rt[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    priority_queue<Entry> PQ;
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &arr[i]);
        lf[i] = i - 1;
        rt[i] = i + 1;
        PQ.push(Entry(arr[i], i));
    }
    arr[0] = -INF64;
    arr[n + 1] = -INF64;
    rt[0] = 1;
    lf[n + 1] = n;
    ll ans = 0;
    for (int i = 0; i < n / 2; i++) {
        while (!PQ.empty() && vis[PQ.top().id]) {
            PQ.pop();
        }
        auto cur = PQ.top();
        PQ.pop();
        ans += cur.v;
        vis[lf[cur.id]] = vis[rt[cur.id]] = true;
        arr[cur.id] = arr[lf[cur.id]] + arr[rt[cur.id]] - cur.v;
        cur.v = arr[cur.id];
        lf[cur.id] = lf[lf[cur.id]];
        rt[lf[cur.id]] = cur.id;
        rt[cur.id] = rt[rt[cur.id]];
        lf[rt[cur.id]] = cur.id;
        PQ.push(cur);
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 9372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i,n)for(ll (i)=0;(i)<(n);(i)++)
void cm(ll &a,ll b){if(a>b)a=b;}

int main(void){
  ll n,s,k,v;cin>>n;vl x(n),y(n),p(n),a(n+1,1LL<<60);vector<vl>X(n),Y(n);
  rep(i,n)cin>>x[i]>>y[i]>>p[i];
  rep(i,n){
    X[i]=vl(1<<n,abs(x[i])),Y[i]=vl(1<<n,abs(y[i]));
    rep(b,1<<n)rep(j,n)if(b&1<<j)cm(X[i][b],abs(x[i]-x[j])),cm(Y[i][b],abs(y[i]-y[j]));
  } 
  rep(b,1<<n){
    s=b;
    do{
      k=__builtin_popcountl(b),v=0;
	  rep(i,n)v+=p[i]*min(X[i][s],Y[i][b&~s]);
      cm(a[k],v),s=(s-1)&b;
    }while(s!=b);
  }
  rep(i,n+1)cout<<a[i]<<endl;return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int X, Y;
  cin >> X >> Y;

  cout << X + Y / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var x = BigInt(next());
  for(var a = 1n; a < 1000n; a++){
    var A = a*a*a*a*a;
    for(var b = -a; b < a; b++){
      var B = b*b*b*b*b;
      if(A-B === x)return a.toString() + " " + b.toString();
    }
  }
}

Measured memory_bytes: 33324
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


void check()
{
	ll ans = 0, f = 0, res = 0;
	string s;
	cin >> s;
	if(s[0]=='R' and s[1]=='R' and s[2]=='R') ans = 3;
	if(s[0]=='R' and s[1]=='S' and s[2]=='R') ans = 1;
	if(s[0]=='R' and s[1]=='R' and s[2]=='S') ans = 2;
	if(s[0]=='S' and s[1]=='R' and s[2]=='R') ans = 2;
	if(s[0]=='S' and s[1]=='R' and s[2]=='S') ans = 1;
	if(s[0]=='R' and s[1]=='S' and s[2]=='S') ans = 1;
	if(s[0]=='S' and s[1]=='S' and s[2]=='R') ans = 1;
	if(s[0]=='S' and s[1]=='S' and s[2]=='S') ans = 0;
	cout << ans << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    //cin >> t;
    while(t--)
        check();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

//マクロ
#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 INF 999999999

//debug
#define dump(x) cout << #x << " = " << (x) << endl;

//配列の要素を順番に出力
void trace(int A[], int N){
    int i;
    for (i = 0; i < N; i++){
        if (i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

/////////////////////////////////////////////////////////////////
//ALDS1_2_D
//Shell Sort

long long cnt;
int N;
int A[1000000];
vector<int> G;

//挿入ソート
void insertion_sort(int A[], int N, int g){
    int i, j, v;
    for (i = g; i < N; i++){
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shell_sort(int A[], int N){
    int h = 0;
    while (true){
        if (h > N) break;
        G.push_back(h);
        h = 3*h + 1;
    }
    for (int i = G.size()-1; i>=0; i--){
        insertion_sort(A, N, G[i]);
    }
}

int main(){
    scanf("%d", &N);
    REP(i, N) scanf("%d", &A[i]);
    cnt = 0;
    
    shell_sort(A, N);
    
    printf("%d\n", G.size());
    REPR(i, G.size()-1){
        printf("%d", G[i]);
        if ( i ) printf(" ");
    }
    printf("\n");
    cout << cnt << endl;
    REP(i, N) printf("%d\n", A[i]);
    
    return 0;    
}


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

int main(){
  std::locale l = std::locale::classic();
  int a, b;
  string n;
  cin >> a >> b >> n;
  n[b-1] = std::tolower(n[b-1], l);
  cout << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define CIN(s) int (s);cin>>(s);
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; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;
int main(){
    string s;
    cin>>s;
    VV dp(s.size()+1,V(4));
    dp[0][3]=1;
    rep(i,s.size()){
        rep(j,4){
            if(s[i]=='?')dp[i+1][j]+=dp[i][j]*3;
            else dp[i+1][j]+=dp[i][j];
        }
        if(s[i]=='A'){
            dp[i+1][0]+=dp[i][3];
        }
        if(s[i]=='B'){
            dp[i+1][1]+=dp[i][0];
        }
        if(s[i]=='C'){
            dp[i+1][2]+=dp[i][1];
        }
        if(s[i]=='?'){
            dp[i+1][0]+=dp[i][3];
            dp[i+1][1]+=dp[i][0];
            dp[i+1][2]+=dp[i][1];
        }
        rep(j,4){
            dp[i+1][j]%=MOD;
        }
    }
    cout<<dp[s.size()][2]<<endl;
}

Measured memory_bytes: 7424
/*input
0112




*/
/*
<!--> 		^_^  ^_^  ^_^
		   _____________
		  /				/
AUTHOR  :/ thesyncoder /
		/_____________/
			T_T   T_T
YOU yourself can be less noob than the one 
you are right now 
just with a little coffee.
<!-->
*/
#include <bits/stdc++.h>
using namespace std;

// ALL DEFFINES HERE
#define ll long long int
#define ii pair<int, int>
#define mp make_pair
#define N 100005
#define rep(i, n) for(int i=0; i < n; i++)
#define Rep(i, k, n) for(int i=k; i < n; i++)
#define pb push_back
#define vi vector<int>
#define vii vector< vector<int> >
#define vl vector<ll>
#define F first
#define S second

// ALL declarations here const ints etc
const  ll mod =1000000000+7; 

// IMPORTANT FUNCTION DECLARATIONS , 
//SORRY FOR THE BAD PRESENTATION
ll gcd(ll a, ll b)
{
	if ( b==0)
		return a;
	return gcd(b, a%b);
}
ll absl(ll a )
{
	return  a>= 0 ?a:-a;
}
ll maxl(ll a, ll b)
{
	return a >= b? a:b;
}
// --->>> main starts here
int primes[100000];
void seive()
{
	primes[0]=1;primes[1]=1;
	for ( int i=2; i*i <= 100000; i++)
	{
		for ( int j=i*2; j <= 100000; j+=i)
		if ( !primes[j])
		{
			primes[j] =1; 
		}
	}
}
int main()
{
	string s;
	cin >> s;
	int a = (s[0]-'0')*10 +(s[1]-'0');
	int b = (s[2] - '0')*10 + (s[3]-'0');
	bool mona =false;
	bool monb = false;
	if ( a <=12  && a >=1)
		mona =true;
	if ( b <=12  && b >=1)
		monb =true;
	if ( mona && monb)
	{
		cout << "AMBIGUOUS";
	}
	else if ( mona && !monb)
		cout << "MMYY";
	else if ( !mona && monb)
		cout << "YYMM";
	else
		cout << "NA";
 	
}

		








Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    if (N % K == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//<(") 
#define ll long long  
using namespace std;
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
 
const ll mod = 1e9 + 7;
const ll siz = 2e5 + 10;
const ll base = 32;
const ll MAXX = 1e9;

ll n, k, l;
vector<ll> hold;
vector<ll> nxt;

void compress() {
	sort(nxt.begin(), nxt.end());
	l = unique(nxt.begin(), nxt.end()) - nxt.begin();
	nxt.resize(l);
	for (ll i = 1; i <= n; i++) {
		hold[i] = lower_bound(nxt.begin(), nxt.end(), hold[i]) - nxt.begin() + 1;
	}
}

ll tree[siz];

void update(ll node, ll val) {
	for (ll i = node; i <= l; i += i & -i) {
		tree[i] += val;
	}
}

ll get(ll node) {
	ll ans = 0;
	for (ll i = node; i; i -= i & -i) {
		ans += tree[i];
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	cin >> n >> k;
	hold.resize(n + 1);
	nxt.push_back(0);
	for (ll i = 1; i <= n; i++) {
		cin >> hold[i];
		hold[i] -= k;
		hold[i] += hold[i - 1];
		//cerr << hold[i] << ' ';
		nxt.push_back(hold[i]);
	}
	//cerr << '\n';
	compress();
	for (ll i = 1; i <= n; i++) {
		cerr << hold[i] << ' ';
	}
	//cerr << '\n';
	update(lower_bound(nxt.begin(), nxt.end(), 0) - nxt.begin() + 1, 1);
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		ans += get(hold[i]);
		//cerr << get(hold[i]) << ' ';
		update(hold[i], 1);
	}	
	//cerr << '\n';
	cout << ans << '\n';
	return 0;
}  	 	   		  		 		 	  			  		

Measured memory_bytes: 8108
using static System.Console;

public class Hello
{
    const long p = 1000000007;
    static string l = ReadLine();
    static readonly long N = long.Parse(l.Split()[0]);
    static readonly long K = long.Parse(l.Split()[1]);

    public static void Main()
    {
        long[,] Comb = new long[N + 1, K + 1];//nCm = n-1Cm-1 + n-1Cm

        for (int i = 0; i < N + 1; i++)
        {
        for (int j = 0; j < K + 1; j++)
            {//Comb[i,j]を計算
                if (j == 0) Comb[i, j] = 1;
                else if (i == 0) Comb[i, j] = 0;
                else Comb[i, j] = (Comb[i - 1, j - 1] + Comb[i - 1, j])%p;
            }
        }

      for (long i = 0; i < K; i++)
        {
            WriteLine(Comb[N - K + 1, i + 1] * Comb[K - 1, i] % p);
        }
    }
}


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

using namespace std;

#define MAX 6001
#define INF 1e9

struct State{
  int dist,v,cap;
  State(int dist,int v,int cap) 
    : dist(dist),v(v),cap(cap) {}

  bool operator > (const State &s)const{
    return dist > s.dist;
  }
};

struct Edge{
  int to,dist;
  Edge(int to,int dist) : to(to),dist(dist) {}
};

int N,M,cap,src,dst,idx;
set<int> LPG;
vector<Edge> G[MAX];

void init(){
  idx = 1;
  LPG.clear();
  for(int i = 0 ; i < MAX ; i++){
    G[i].clear();
  }
}

int dijkstra(){
  vector<int> dist[idx];
  cap *= 10;
 
  for(int i = 0 ; i < idx ; i++){
    dist[i].resize(cap+1);
    for(int j = 0 ; j <= cap ; j++){
      dist[i][j] = INF;
    }
  }

  dist[src][cap] = 0;

  priority_queue<State,vector<State>,greater<State> > Q;
  Q.push(State(0,src,cap));

  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int v = s.v,c = s.cap;
    
    if(dist[v][c] < s.dist) continue;
    
    if(v == dst){
      return dist[v][c];
    }

    for(int i = 0 ; i < (int)G[v].size() ; i++){
      Edge e = G[v][i];
      int nc = (LPG.find(v) != LPG.end()) ? cap : c;
      if(e.dist <= nc){
        nc -= e.dist;
        if(dist[v][c] + e.dist < dist[e.to][nc]){
          dist[e.to][nc] = dist[v][c] + e.dist;
          Q.push(State(dist[e.to][nc],e.to,nc));
        }                           
      }
    }
  }
  return -1;
}

int main(){
  int d;
  string a,b;
  
  while(cin >> N >> M >> cap, N){
    init();
    map<string,int> mp; 
    cin >> a; mp[a] = src = idx++; 
    cin >> a; mp[a] = dst = idx++; 
    for(int i = 0 ; i < N ; i++){
      cin >> a >> b >> d;
      if(mp.find(a) == mp.end()){
        mp[a] = idx++;
      }
      if(mp.find(b) == mp.end()){
        mp[b] = idx++;
      }
      G[mp[a]].push_back(Edge(mp[b],d));
      G[mp[b]].push_back(Edge(mp[a],d));
    }
    for(int i = 0 ; i < M ; i++){
      cin >> a;
      LPG.insert(mp[a]);
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 100000 + 5;

int vis[N];

vector<int> pri;

void sieve()
{
    rep(i , 2 , 2300)
    {
        if(!vis[i])
            pri.push_back(i);
        for(int x : pri)
        {
            if(i * x > 2300) break ;
            vis[i * x] = 1;
            if(i % x == 0) break ;
        }
    }
}

int n ; LL A[N] , Ans;

LL L[N] , R[N];

map<LL , int> G;

int check(LL x)
{
    LL v = sqrt(x);
    return v * v == x;
}

int main()
{
    read(n) , sieve();
    rep(i , 1 , n) read(A[i]);
    rep(i , 1 , n)
    {
        LL x = A[i];
        for(int d : pri)
        {
            LL v = 1ll * d * d * d;
            if(v > x) break ;
            while(x % v == 0) x /= v;
        }
        G[x]++ , L[i] = x;
        LL y = 1;
        for(int d : pri)
        {
            if(1ll * d * d * d > x) break ;
            if(x % d == 0)
            {
                y *= (x % (1ll * d * d) == 0 ? d : 1ll * d * d);
                while(x % d == 0) x /= d;
            }
        }
        y *= check(x) ? sqrt(x) : x * x;
        R[i] = y;
    }
    if(G[1])
        Ans += 1 , G[1] = 0;
    rep(i , 1 , n)
        Ans += max(G[L[i]] , G[R[i]]) , G[L[i]] = G[R[i]] = 0;
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 12928
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

K = int(input())


if K < 10 ** 15:
    a, b = K // 2 + 1, K // 2 + 1

    if K % 2 == 1:
        a += 2
        b -= 1

    print(2)
    print(a, b)
else:
    N = 50
    A = [i for i in range(50)]
    A = list(map(lambda x: x + K // 50, A))
    r = K % 50
    for i in range(50):
        if i < r:
            A[i] += N
            A[i] -= r - 1
        else:
            A[i] -= r

    print(N)
    print(*A)

Measured memory_bytes: 3572
#!/usr/bin/env python3

"""
Lの文字列N個(s1-sN)
N個の文字列を辞書順にしたあと，くっつけて出力する
"""


def main():
    n, l = map(int, input().split())
    input_list = []

    for i in range(n):
        input_list.append(input())

    result_list = sorted(input_list)
    print("".join(result_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-15;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
struct Point{double x,y;};
double dis(Point a,Point b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
Point tri(Point a, Point b, Point c){
  double a1,a2,b1,b2,c1,c2;
  a1=2*(b.x-a.x);
  b1=2*(b.y-a.y);
  c1=a.x*a.x-b.x*b.x+a.y*a.y-b.y*b.y;
  a2=2*(c.x-a.x);
  b2=2*(c.y-a.y);
  c2=a.x*a.x-c.x*c.x+a.y*a.y-c.y*c.y;
  Point p;
  p.x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
  p.y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
  return p;
}
int main(){
  startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,k,l,N;
  cin>>N;
  double ans=inf,fir;
  vector<Point> v(N);
  Point x;
  rep(i,N)cin>>v[i].x>>v[i].y;
  //sort(all(v),[](auto a,auto b){if(a.x!=b.x){return a.x<b.x;}else{return a.y<b.y;}});
  rep(i,N)For(j,i+1,N){
    double res=dis(v[i],v[j])*0.5;
    fir=res;
    x.x=(v[i].x+v[j].x)/2;
    x.y=(v[i].y+v[j].y)/2;
    rep(k,N){
      if(i==k||j==k)continue;
      if(dis(x,v[k])>fir+eps){
        res=inf;
        break;
      }
    }
    chmin(ans,res);
  }
  rep(i,N)For(j,i+1,N)For(k,j+1,N){
    if((v[i].x-v[k].x)*(v[j].y-v[k].y)!=(v[i].y-v[k].y)*(v[j].x-v[k].x)){
      x=tri(v[i],v[j],v[k]);
      fir=dis(x,v[i]);
      rep(l,N){
        if(dis(x,v[l])>fir+eps){
        fir=inf;
        break;
        }
      }
      chmin(ans,fir);
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a + b + c == 17)
    {
        if (a == 5 && b == 5)
        {
            puts("YES");
            return (0);
        }
        if (b == 5 && c == 5)
        {
            puts("YES");
            return (0);
        }
        if (c == 5 && a == 5)
        {
            puts("YES");
            return (0);
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 128
from itertools import groupby
S = input()
if S[0] == ">":
    S = "<"+S
if S[-1] == "<":
    S += ">"

ans = 0
pair = [(s, len(list(l))) for s, l in groupby(S)]
for p, q in zip(pair[:-1:2], pair[1::2]):
    a, b = min(p[1], q[1]), max(p[1], q[1])
    ans += (a-1)*a//2
    ans += (b+1)*b//2

print(ans)


Measured memory_bytes: 24100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
 	ll n;
 	cin>>n;
 	ll a[n][3];
	for(ll i=0;i<n;i++)
 	cin>>a[i][0]>>a[i][1]>>a[i][2];
 	ll dp[n+1][3];
 	dp[0][0]=0;
 	dp[0][1]=0;
 	dp[0][2]=0;
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=max(a[i-1][1]+dp[i-1][1],a[i-1][2]+dp[i-1][2]);
		dp[i][1]=max(a[i-1][0]+dp[i-1][0],a[i-1][2]+dp[i-1][2]);
		dp[i][2]=max(a[i-1][1]+dp[i-1][1],a[i-1][0]+dp[i-1][0]);
	}
	cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
}



Measured memory_bytes: 4992
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val Q = sc.nextInt
    val S = sc.next
    val lr = Array.fill(Q)(sc.nextInt, sc.nextInt)

    val L = ArrayBuffer.fill(N + 2)(0)
    var n = 0
    for (i <- S.indices if i < S.length - 1) {
      if (S(i) == 'A' && S(i + 1) == 'C') {
        n += 1
      }
      L(i + 1) = n
    }
    L(S.length + 1) = n

    val R = ArrayBuffer.fill(N + 2)(0)
    n = 0
    for (i <- S.indices.reverse if i > 0) {
      if (S(i - 1) == 'A' && S(i) == 'C') {
        n += 1
      }
      R(i + 1) = n
    }
    R(S.length + 1) = 0
    R(1) = R(2)
    R(0) = R(1)
    val all = n

    //    println(L.map(_.toString).mkString(" "))
    //    println(R.map(_.toString).mkString(" "))

    lr.map { case (l, r) =>
      (all - L(l - 1) - R(r + 1)).toString
    }.mkString("\n")
  }
}


Measured memory_bytes: 78028
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
//find_by_order() ->  iterator to the k-th largest element (counting from zero)
//order_of_key() ->    the number  items in a set that are strictly smaller than our item aka index in set
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
	cin>>n;
	int ans=power(10,n)-(2*power(9,n))%mod+power(8,n)+mod;
	ans%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
int main()
{
    cin >> n;
    if (n == 1)
    {
        cout << "Hello World" << endl;
    }
    else
    {
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readIntBS = fst . fromJust . BS.readInt

main = do
  [q,h,s,d] <- map (fromIntegral . readIntBS) . BS.words <$> BS.getLine :: IO [Integer]
  n <- readLn :: IO Integer

  print $ (n`div`2) * (minimum [q*8,h*4,s*2,d]) + (n`mod`2) * (minimum [q*4,h*2,s])


Measured memory_bytes: 508
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
#整数nを入力し、深さnの再帰呼び出しによって作成されるコッホ曲線の頂点の座標を出力するプログラムを作成してください

# 入力 一つの整数nが与えられます
# 1など

# 出力 コッホ曲線の各頂点の座標(x,y)を出力してください
# 一行に一点の座標を出力してください
# 端点の一つ

def koch(n,a,b)
  if n == 0
    return
  end
  s = [(2*a[0]+1*b[0])/3.to_f,(2*a[1]+1*b[1])/3.to_f]
  t = [(1*a[0]+2*b[0])/3.to_f,(1*a[1]+2*b[1])/3.to_f]
  #点の移動(x,y)=>(x',y')は、(xcosθ-ysinθ, xsinθ+ycosθ)で出せる
  #シータはラジアンのみ可
  rag = Math::PI * 60 / 180 .to_f
  u = [((t[0]-s[0])*Math.cos(rag) - (t[1]-s[1])*Math.sin(rag) + s[0]).to_f,
       ((t[0]-s[0])*Math.sin(rag) + (t[1]-s[1])*Math.cos(rag) + s[1]).to_f]
  koch(n-1, a,s)
  print(s[0])
  print(" ")
  print(s[1])
  puts("\n")
  koch(n-1, s,u)
  print(u[0])
  print(" ")
  print(u[1])
  print("\n")
  koch(n-1, u,t)
  print(t[0])
  print(" ")
  print(t[1])
  print("\n")
  koch(n-1, t,b)
end


n = gets.chomp.to_i

start_point = [0,0]
end_point = [100,0]

print(start_point[0])
print(" ")
print(start_point[1])
print("\n")
koch(n,start_point,end_point)
print(end_point[0])
print(" ")
print(end_point[1])
print("\n")



Measured memory_bytes: 6924
#include<iostream>
#include<algorithm>

using namespace std;
int main()
{
	int su, n[5];
	int i;
	int d, s;
	int ke,cnt;
	int f;
	while (cin >> su, su != 0)
	{
		cnt = 0;
		f = 1;
		while (su != 6174)
		{
			//cout << cnt << endl;
			cnt++;
			ke = 1000;
			for (i = 0; i < 4; i++)
			{
				n[i] = su / ke;
				su -= su / ke * ke;
				ke = ke / 10;
			}
			if (n[0] == n[1] && n[2] == n[3] && n[1] == n[2])
			{
				cout << "NA" << endl;
				f = 0;
				break;
			}
			sort(n, n + 4);
			d = s = 0;
			ke = 1000;
			for (i = 0; i < 4; i++)
			{
				s += n[i] * ke;
				ke = ke / 10;
			}
			ke = 1000;
			for (i = 3; i >= 0; i--)
			{
				d += n[i] * ke;
				ke = ke / 10;
			}
			su = d - s;
		}
		if(f) cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int c[10][1005];

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = 1e8;
    rep(div, 1<<(h-1)) {
        int g = 0;
        vector<int> id(h);
        rep(i, h) {
            id[i] = g;
            if ( div>>i&1) ++g;
        }
        ++g;
        rep(i,g) rep(j,w) c[i][j] = 0;
        rep(i,h) rep(j,w) c[id[i]][j] += (s[i][j]-'0');

        int num = g - 1;
        vector<int> now(g);
        auto add = [&](int j) {
            rep(i, g) now[i] += c[i][j];
            rep(i, g) if ( now[i] > k) return false;
            return true;
        };
        rep(j, w) {
            if ( !add(j) ) {
                ++num;
                now = vector<int>(g);
                if ( !add(j)) {
                    num = 1e8;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i;
  int a[1000],c,n,m,y;
  for(;;){
    scanf("%d%d",&n,&m);
    if(n==0&&m==0)
      break;
    c=0;
    y=n;
    for(i=0;i<n;i++)
      a[i]=(i+1)%n;
    for(;n>1;n--){
      for(i=0;i<m-1;i++)
	c=a[c];
      a[c]=a[a[c]];
    }
    if(c)
      printf("%d\n",c);
    else
      printf("%d\n",y);
  }
  return 0;
}

Measured memory_bytes: 0
#coding:utf-8
ls_len = [1]
ls_p = [1]
for i in range(50):
    ls_len.append(2*ls_len[-1]+3)
    ls_p.append(1+2*ls_p[-1])
n,x = map(int,input().split())

def calc_p(level,x):
    if level == 0:
        return 1
    elif x == ls_len[level]-1:
        return ls_p[level]
    elif x == 0:
        return 0
    elif x == (ls_len[level]-1)/2:
        return ls_p[level-1]+1
    elif x < (ls_len[level]-1)/2:
        return calc_p(level-1,x-1)
    else:
        return calc_p(level-1,x-2-ls_len[level-1])+ls_p[level-1]+1
print (calc_p(n,x-1))

Measured memory_bytes: 3064
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    double a,b,x; cin>>a>>b>>x;
    double maxyouryo = a*a*b, hanbunyouryo = maxyouryo/2,theta = 0.0, i;
    if(x<=hanbunyouryo){ // 半分より少ないとき、
        i = x * 2.0 / (a*b);
        theta = atan(b/i);
    }else{
        i = (maxyouryo - x)/(a*a/2.0);
        theta = atan(i/a);
    }
    double ans = theta * 180.0 / M_PI;
    printf("%.7lf",ans);
    return 0;
}


Measured memory_bytes: 256
<?php

const TABLE_WIDTH = 3;
const TABLE_HEIGHT = 2;

$input_line = [];
for ($i = 0; $i < TABLE_HEIGHT; $i++)
{
	$input_line[$i] = trim(fgets(STDIN));
}

$is_same = true;
for ($i = 0; $i < strlen($input_line[0]); $i++)
{
	if ($input_line[0][$i] !== $input_line[1][TABLE_WIDTH - $i - 1])
	{
		$is_same = false;
		break;
	}
}

echo ($is_same)? 'YES' : 'NO';


Measured memory_bytes: 3956
# 2019-11-21 01:26:03(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r, insort_left as in_l
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 

def is_palindrome_in(s):
    s = s.replace('x', '')
    if list(s) == list(reversed(s)):
        return True
    return False

def main():
    s = sys.stdin.readline().rstrip()
    
    if not is_palindrome_in(s):
        print(-1)
        sys.exit()
    
    s = collections.deque(s)
    
    count = 0
    while len(s) > 1:
        if s[0] == 'x':
            if s[-1] == 'x':
                s.popleft(); s.pop()
            else:
                s.popleft()
                count += 1
        else:
            if s[-1] != 'x':
                s.popleft(); s.pop()
            else:
                s.pop()
                count += 1

    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5108
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
  class Program
  {
    public static void Main(string[] args)
    {
      foreach (var p in Read())
      {
        if (!Intersect(p[0], p[2], p[1], p[3]) || !Intersect(p[1], p[3], p[0], p[2]))
          Console.WriteLine("NO");
        else
          Console.WriteLine("YES");
      }
    }

    public static IEnumerable<Point[]> Read()
    {
      string line;
      while (!string.IsNullOrEmpty(line = Console.ReadLine()))
        yield return line.Split(',').Select(s => double.Parse(s))
                                    .Slice(2)
                                    .Select(pair => new Point(pair[0], pair[1]))
                                    .ToArray();
    }

    public static bool Intersect(Point a, Point b, Point p, Point q)
    {
      // http://www5d.biglobe.ne.jp/~tomoya03/shtml/algorithm/Intersection.htm
      // a(xa, ya), b(xb, yb)
      // y = x * (ya-yb)/(xa-xb)+ya - xa * (ya-yb)/(xa-xb)
      // y * (xa - xb) = x * (ya-yb) + ya*(xa-xb) - xa * (ya-yb)
      // y*(xa-xb) - x*(ya-yb) - ya*(xa-xb) + xa*(ya-yb) = 0
      // (y - ya)(xa - xb) + (xa - x)(ya - yb) = 0
      
      return ((a.X - b.X) * (p.Y - a.Y) + (a.Y - b.Y) * (a.X - p.X)) // let p
        * ((a.X - b.X) * (q.Y - a.Y) + (a.Y - b.Y) * (a.X - q.X))    // let q
        < 0;
    }
  }

  static class EnumerableEx
  {
    public static IEnumerable<T[]> Slice<T>(this IEnumerable<T> source, int count)
    {
      return Slice<T, T[]>(source, count, x => x.ToArray());
    }

    public static IEnumerable<TResult> Slice<TSource, TResult>(this IEnumerable<TSource> source, int count, Func<IEnumerable<TSource>, TResult> selector)
    {
      var result = new List<TSource>(count);
      foreach (var v in source)
      {
        result.Add(v);
        if (result.Count == count)
        {
          yield return selector(result);
          result.Clear();
        }
      }
      if (result.Any())
        yield return selector(result);
    }
  }

  class Point
  {
    public double X { get; set; }
    public double Y { get; set; }
    public Point(double x, double y)
    {
      X = x;
      Y = y;
    }

    public static Point operator-(Point a, Point b)
    {
      return new Point(a.X - b.X, a.Y - b.Y);
    }

    public override string ToString()
    {
      return "Point(" + X + ", " + Y + ")";
    }
  }
}

Measured memory_bytes: 6172
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: k,a,b,i
    
    read*, k
    read*, a,b
    do i=1,1000
        if (i*k >= a .and. i*k <= b) then
            print'(a)', 'OK'
            stop
        end if
    end do

    print'(a)', 'NG'
end program name

Measured memory_bytes: 2924
package main

import "fmt"

func main() {
	var X, Y int
	fmt.Scan(&X, &Y)
	n := map[int]int{
		0: 0,
		1: 300000,
		2: 200000,
		3: 100000,
	}
	ans := n[X] + n[Y]
	if X == 1 && Y == 1 {
		ans += 400000
	}
	fmt.Println(ans)
}


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

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//class Timer {
//    clock_t start;
//    string name;
//public:
//    Timer() {name = "";start = clock();}
//    Timer(string s){name = s;start = clock();}
//    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
//};

//#define isValid(a, b) ((a) >= 0 && (a) < (b))
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define um unordered_map
#define us unordered_set
#define endl '\n'
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl

const double EPS = 1e-9;
const double PI = acos(-1.0);

template<typename T> inline T sq(T a){return a*a;}
template<typename T1, typename T2> inline pair<T1, T2> mp(T1 a, T2 b){return make_pair(a, b);}
template<typename T1, typename T2> inline T1 safeMod(T1 a, T2 m){return (a%m + m)%m;}/*handling negative sign of remainder*/
template<typename T1, typename T2> inline bool isEq(T1 a, T2 b){return abs(a - b) < EPS;}
template<typename T1, typename T2, typename T3> inline bool isEq(T1 a, T2 b, T3 eps){return abs(a - b) < eps;}
template<typename T> inline bool isKthBitOn(T n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;return bool((n & (ONE<<k)));}
template<typename T> inline void setKthBit(T& n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;n = (n|(ONE<<k));}
//mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
//template<typename T> inline T nextRand(T lo, T hi){return uniform_int_distribution<T>(lo, hi)(rng);}

#define toRad(deg) ((deg)*PI/180.0)
#define toDeg(rad) ((rad)*180.0/PI)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;

int main()
{
    //assert(freopen("in.txt", "r", stdin));
    //assert(freopen("out.txt", "w", stdout));
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << fixed << setprecision(precision);
    ll n;
    cin >> n;
    ll mn = LLONG_MAX;
    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0){
            mn = min(mn, i + n/i);
        }
    }
    cout << mn-2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    string s;
    cin >>s;
    int t=0;
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='B'){
            ans+=s.length()-1-i-t;
            t++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
	fast

	int t;
	cin>>t;

	int x = 0,y = 0;
	vi v(t);
	forn(idx,0,t)
	{

		cin>>v[idx];
		
		if(v[idx] > x)
		{
			y = x;
			x = v[idx];
		}
		else if(v[idx] > y)
		{
			y = v[idx];
		}
	}


	forn(i,0,t)
	{
		if(v[i] != x)
		{
			cout<<x;
		}
		else
		{
			cout<<y;
		}
		cout<<endl;
	}


	return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void fun(char *);
void fun(char *s)
{
    int n=strlen(s);
    printf("%c%d%c\n",s[0],n-2,s[n-1]);
}
int main()
{
    char a[101];
    scanf("%s",a);
    fun(a);
    return 0;
}

Measured memory_bytes: 128
/*
 * Q:自然数Nは何通りの連続する自然数の和で表せるか
 * A:Nの奇数の約数の個数-1
 * */
#include <iostream>
using namespace std;

bool solve(){
	int n;
	cin >> n;
	if(!n)	return false;
	int odd = 0;
	for(int i = 1; i < n; i++){
		if(n % i == 0){
			if((n / i) % 2 != 0)	odd++;
		}
	}
	cout << odd << endl;
	return true;
}

int main(void){
	while(solve());
  return 0;
}

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

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

  int c, t;
  int ans = INT_MAX;
  for(int i = 0;i < n;i++){
    cin >> c >> t;
    if(T >= t){
      ans = min(ans, c);
    }
  }

  if(ans < INT_MAX){
    cout << ans << endl;
  }else{
    cout << "TLE" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (100010)
int ans[N];
char a[N];

int main(){
	scanf("%s",a+1); int n=strlen(a+1);
	int l=1;
	while (l<=n){
		int r1=l;
		while (a[r1+1]=='R') ++r1;
		int r2=r1+1;
		while (a[r2+1]=='L') ++r2;
		for (int i=l;i<=r1;i++){
			if ((r1-i)&1) ++ans[r1+1];
			else ++ans[r1];
		}
		for (int i=r1+1;i<=r2;i++){
			if ((i-r1)&1) ++ans[r1+1];
			else ++ans[r1];
		}
		l=r2+1;
	}
	for (int i=1;i<=n;i++) printf("%d ",ans[i]);
}


Measured memory_bytes: 896
import java.util.Scanner;
public class Main {
	public static int buf(char a){
		int b=0;
		if(a=='a')
			b=1;
		if(a=='b')
			b=2;
		if(a=='c')
			b=3;
		if(a=='d')
			b=4;
		if(a=='e')
			b=5;
		if(a=='f')
			b=6;
		if(a=='g')
			b=7;
		if(a=='h')
			b=8;
		if(a=='i')
			b=9;
		if(a=='j')
			b=10;
		if(a=='k')
			b=11;
		if(a=='l')
			b=12;
		if(a=='m')
			b=13;
		if(a=='n')
			b=14;
		if(a=='o')
			b=15;
		if(a=='p')
			b=16;
		if(a=='q')
			b=17;
		if(a=='r')
			b=18;
		if(a=='s')
			b=19;
		if(a=='t')
			b=20;
		if(a=='u')
			b=21;
		if(a=='v')
			b=22;
		if(a=='w')
			b=23;
		if(a=='x')
			b=24;
		if(a=='y')
			b=25;
		if(a=='z')
			b=26;
		return b;
	}
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		String S=stdIn.next();
		char a[]=new char[N];
		int b[]=new int[27];
		int z=0,y=1,x=0,X=0,Y=N-1,cun=0,max=0;
		while(z<N){
			a[z]=S.charAt(z);
			
			z++;
		}z=0;
		while(X<N-1){
			while(z<=X){
				if(b[buf(a[z])]==0){
					while(y<=Y){
						if(a[z]==a[y]){
							cun++;
							break;
						}
						y++;
					}y=X+1;
					b[buf(a[z])]++;
				}
				z++;
			}z=1;
			while(z<27){
				b[z]=0;
				z++;
			}z=0;
			if(max<cun)
				max=cun;
			cun=0;
			X++;
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 22612
#include <iostream>
using namespace std;
int main(void){
    int lng, ans, itchi;
    string s;
    bool bl = false;
    cin >> s;
    lng = s.size();
    ans = (lng - 1) / 2;
    while (bl == false) {
        itchi = 0;
        for (int i = 0; i < ans; i++) {
            if (s[i] == s[i + ans]) itchi++;
        }
        if (itchi == ans) bl = true;
        else ans--;
    }
    cout << ans * 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int K;
	cin >> K;

	int ans[50];
	REP(i, 50) {
		ans[i] = i;
		ans[i] += K / 50;
	}
	K %= 50;
	REP(i, K) {
		ans[i] += 50;
		REP(j, 50) {
			if (i != j)ans[j]--;
		}
	}
	cout << 50 << endl;
	REP(i, 50) {
		cout << ans[i];
		cout << ((i != 49) ? " " : "\n") ;
	}
	return 0;
}



Measured memory_bytes: 256
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(int(input()))
    b.append(a[i])
b.sort()
m0=b[-1]
m1=b[-2]

for i in range(n):
    if a[i]!=m0:
        print(m0)
    else:
        print(m1)


Measured memory_bytes: 14120
#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 1
#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; }

#define MAX (5000*5000+5000)

lli dp[5000*5000+5000];
vector<lli> a,b;

lli func(vector<lli> &buy,vector<lli> &sell,lli m){

    REP(i,0,MAX)dp[i]=0;

    REP(i,0,3){
        REP(j,0,m+1){
            chmax(dp[j+buy[i]],dp[j]+sell[i]);
        }
    }
    lli res=m;
    REP(i,0,m+1)chmax(res,dp[i]+m-i);
    return res;
}

int main(){
    // cout << fixed << setprecision(5);
    a.resize(3),b.resize(3);

    lli n;
    cin>>n;
    REP(i,0,3)cin>>a[i];
    REP(j,0,3)cin>>b[j];

    n = func(a,b,n);
    //LOG(n);
    n = func(b,a,n);
    cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 195712
import Foundation
 
let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")
 
let N = Int(split[0])!
let R = Int(split[1])!

if (N <= 10){
    print(R+100*(10-N))
}else{
    print(R)
}

Measured memory_bytes: 14180