akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any) = pw.print(s)
fun println(s: Any) = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val S = next()
    val Q = nextInt()
    var reversed = false
    val heads = mutableListOf<String>()
    val tails = mutableListOf<String>()
    repeat(Q) {
        val q = nextList()
        if (q[0] == "1") {
            reversed = !reversed
        } else {
            if ((!reversed && q[1] == "1") || (reversed && q[1] == "2")) {
                heads.add(q[2])
            } else {
                tails.add(q[2])
            }
        }
    }
    val ans = heads.reversed().joinToString("") + S + tails.joinToString("")
    println(if (reversed) ans.reversed() else ans)
}

Measured memory_bytes: 83504
def bubble_sort(arr):
    count = 0
    for j in range(len(arr)):
        for i in range(len(arr)-1, j, -1):
            if arr[i] < arr[i-1]:
                arr[i], arr[i-1] = arr[i-1], arr[i]
                count += 1
    return count, arr

nums = input()
# nums = 1
# arr = list(map(int, '100'.split()))
arr = list(map(int, input().split()))

count, arr = bubble_sort(arr)
arr = list(map(str, arr))
print(" ".join(arr))
print(count)





Measured memory_bytes: 5600
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<queue>

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

using namespace std;

int W, H;

int field[501][501];
const int INF=1<<28;

struct state {
	int x, y, d;
	state(int _x, int _y, int _d){
		x=_x;y=_y;d=_d;
	}
};

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

int solve() {
	int ans = INF;

	int gx = W-1, gy = H-1;

	queue<state> q;
	q.push(state(0, 0, 1));

	while (!q.empty()) {
		state s = q.front(); q.pop();

		if (s.d >= ans) continue;

		if (s.x == gx && s.y == gy) {
			ans = min(ans, s.d);
			continue;
		}

		for (int i=0; i<4; i++) {
			if (!(0 <= s.y + dy[i] && s.y + dy[i] < H && 0 <= s.x + dx[i] && s.x + dx[i] < W)) continue;

			if (field[s.y + dy[i]][s.x + dx[i]] == 0) {
				field[s.y + dy[i]][s.x + dx[i]] = -1;
				field[s.y + 2 * dy[i]][s.x + 2*dx[i]] = -1;
				q.push(state(s.x + 2*dx[i], s.y + 2*dy[i], s.d + 1));
			}
		}
	}

	if (ans == INF) ans = 0;
	return ans;
}

int main() {

	while (1) {
		cin >> W >> H;
		if (W == 0) break;
		W = 2*W - 1;
		H = 2*H - 1;

		fill_n((int *)field,sizeof(field)/sizeof(int),0);
		cin.ignore();

		string str;
		for (int i=0; i<H; i++) {
			getline(cin, str);

			int n = (int)str.size();
			for (int j=0; j<n; j++) {
				if (str[j] == '1') {
					field[i][j] = 1;
				}
			}
		}

		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 2204
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

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

	vector<int> p(N);
	int maxPrice = 0;
	int ans = 0;
	for (size_t i = 0; i < N; i++)
	{
		cin >> p[i];
		ans += p[i];
		maxPrice = max(maxPrice, p[i]);
	}

	ans -= maxPrice / 2;
	cout << ans << endl;
}



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

std::string s, words[4]{"dream", "dreamer", "erase", "eraser"};
int words_length[4]{5, 7, 5, 6};

bool solve(unsigned int);

int main()
{
	std::cin >> s;
	if (solve(0)) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}

bool solve(unsigned int index)
{
	if (index == s.size()) return true;
	for (int i = 0; i < 4; i++)
	{
		if (index + words_length[i] > s.size()) continue;
		if (s.substr(index, words_length[i]) != words[i]) continue;
		if (solve(index + words_length[i])) return true;
	}
	return false;
}

Measured memory_bytes: 2048
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        int rightCnt = 0;
        int leftCnt = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '(') {
                rightCnt++;
            }
            if (s.charAt(i) == ')') {
                if (rightCnt == 0) {
                    leftCnt++;
                } else {
                    rightCnt--;
                }
            }
        }

        String ans = "";
        for (int i = 0; i < leftCnt; i++) {
            ans += "(";
        }
        ans += s;

        for (int i = 0; i < rightCnt; i++) {
            ans += ")";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

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

int dp[110][20][1010];
signed main() {
    int n, s;
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    repq(i,1,100) {
        dp[i][0][0] = 1;
        repq(j,1,15) {
            repq(k,0,1000) {
                dp[i][j][k] = dp[i-1][j][k];
                if(k - i < 0) continue;
                dp[i][j][k] += dp[i-1][j-1][k-i];
            }
        }
    }
    while(cin >> n >> s, n || s) {
        cout << dp[100][n][s] + dp[100][n-1][s] << endl;
    }
    return 0;
}

Measured memory_bytes: 20436
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> vec(m, vector<int>(2));
    rep(i, m)
    {
        rep(j, 2)
        {
            cin >> vec[i][j];
        }
    }
    vector<int> ans(n);
    rep(k, n)
    {
        int count = 0;
        rep(i, m)
        {
            rep(j, 2)
            {
                if (vec[i][j] == k + 1)
                    count++;
            }
        }
        ans[k] = count;
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string t;
  cin >> t;
  rep(i, t.size()) {
    if(t[i] == '?')
      cout << 'D';
    else
      cout << t[i];
  }
  cout << endl;
}

Measured memory_bytes: 3732
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAXN 1000000

signed main() {
	vector<bool> isprime(MAXN, true);
	isprime[0] = isprime[1] = false;
	rep(i, MAXN) {
		if (isprime[i]) {
			int k = 2 * i;
			while (k < MAXN) {
				isprime[k] = false;
				k += i;
			}
		}
	}
	int x; cin >> x;
	for (int i = x; i < MAXN; i++) {
		if (isprime[i]) {
			cout << i << endl;
			break;
		}
	}
}

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

public class Main {

	void solve() {
		int n = in.nextInt();
		int sum = 0;
		int max = (2000 * 2000 + 63) / 64;
		long[] bs = new long[max + 40];
		long[] tmp = new long[bs.length];
		bs[0] = tmp[0] = 1;

		for (int i = 0; i < n; i++) {
			int val = in.nextInt();
			sum += val;

			int big = val / 64;
			int small = val % 64;
			for (int j = 0; j < max; j++) {
				tmp[j + big] |= bs[j] << small;
			}
			if (small != 0) {
				for (int j = 0; j < max; j++) {
					tmp[j + big + 1] |= bs[j] >>> (64 - small);
				}
			}
			System.arraycopy(tmp, 0, bs, 0, max);
		}
		for (int i = (sum + 1) / 2; i <= sum; i++) {
			if ((bs[i >> 6] & (1L << (i & 63))) != 0) {
				out.println(i);
				return;
			}
		}
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


Measured memory_bytes: 22500
#include<bits/stdc++.h>
using namespace std;
long long n,h[100010],dp[100010],k;

int main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&h[i]);
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i>j)
			{
				if(j==1)dp[i] = dp[i-j]+abs(h[i-j]-h[i]);
				else dp[i] = min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
			}
		}
	}
	printf("%lld\n",dp[n]);
	return 0;
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define req(i,f,N) for(int i = f; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    string S, T;
    cin >> S >> T;
    bool flag = true;
    if (S.size() + 1 != T.size()) flag = false;

    rep(i, S.size()) {
        if (S[i] != T[i]) flag = false;
    }

    flag ? y() : n();


}

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

vector<int> cal(int D, vector<vector<int>> s, vector<int> t, vector<int> c, vector<int> v) {
    vector<int> last(26);
    for(int i = 0; i < D; i++) {
        if(i == 0)
            v[i] = s[i][t[i]-1];
        else
            v[i] = v[i-1] + s[i][t[i]-1];
        
        last[t[i]-1] = i+1;
        rep(j,26) {
            v[i] -= c[j] * (i+1 - last[j]);
        }
    }
    
    return v;
}

int main() {
    int D;
    cin >> D;
    
    vector<int> c(26);
    rep(i,26) {
        cin >> c[i];
    }
    
    vector<vector<int>> s(D, vector<int>(26));
    rep(i,D) {
        rep(j,26) {
            cin >> s[i][j];
        }
    }
    
    
    vector<int> t(D);
    rep(i,D) {
        t[i] = 1 + (int)(rand()*(26-1+1.0)/(1.0+RAND_MAX));
    }

    int m = 10;
    
    vector<int> d(m), q(m);
    rep(i,m) {
        d[i] = 1 + (int)(rand()*(D-1+1.0)/(1.0+RAND_MAX));
        q[i] = 1 + (int)(rand()*(26-1+1.0)/(1.0+RAND_MAX));
    }
    
    //計算開始
    vector<int> v(D);
    v = cal(D,s,t,c,v);
    
    rep(i,m) {
        int old = t[d[i]-1];
        t[d[i]-1] = q[i];
        vector<int> nv = cal(D,s,t,c,v);
        
        //cout << nv.back() << endl;
        if(v.back() > nv.back())
            t[d[i]-1] = old;
        else
            v = nv;
    }

    rep(i,D) {
        cout << t[i] << endl;
    }
    
    
    return 0;
}




Measured memory_bytes: 3728
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, long long L){
  ll mi = LINF;
  ll ans = 0;
  ll s = 0;
  rep(i,N ) s+=L+i;
  REP(i,0,N){
    ll b = 0;
    rep(j,N){
      if(i==j) continue;
      b += L+j;
    }
    if(chmin(mi,abs(s-b))){
      ans = b;
    }
  }
  cout << ans << endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long L;
  scanf("%lld",&L);
  solve(N, L);
  return 0;
}


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

void sort(int data[]) {
    for(int i = 0; i < 3; i++){
        for(int j = i + 1; j < 3; j++){
            if(data[j] < data[i]){
                int tmp = data[j];
                data[j] = data[i];
                data[i] = tmp;
            }
        }
    }
}

int main(void) {
    int i, n;
    cin >> n;
    for (i = 0; i < n; i++) {
        int l[3];
        cin >> l[0] >> l[1] >> l[2];
        sort(l);

        long aa = l[0] * l[0];
        long bb = l[1] * l[1];
        if(sqrt(aa + bb) == l[2]) {
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 2996
int main(void)
{
	int w,h;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(w == 0&&h == 0)break;
		int i,j;
		
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if((j+i)%2==0)
					printf("#");
				else
					printf(".");
			}
			printf("\n");
		}
		
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <map>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<intmax_t> A(N+1);
  for (auto& ai: A) scanf("%jd", &ai);
  std::vector<intmax_t> B(N);
  for (auto& bi: B) scanf("%jd", &bi);

  intmax_t res = 0;
  for (size_t i = 0; i < N; ++i) {
    intmax_t c = std::min(A[i], B[i]);
    A[i] -= c;
    B[i] -= c;
    res += c;

    intmax_t d = std::min(A[i+1], B[i]);
    A[i+1] -= d;
    B[i] -= d;
    res += d;
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;


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

  set<char> char_set;
  vector<map<char, int>> c_frq_maps(n);
  for (int i = 0; i < n; ++i) {

    //
    string s;
    cin >> s;
    for(char c: s){
      char_set.insert(c);

      if(c_frq_maps[i].count(c) == 0) c_frq_maps[i][c] = 1;
      else c_frq_maps[i][c] += 1;
    }
//    for(auto kv: c_frq_maps[i]) cout << kv.first << " " << kv.second << endl;
//    cout << "-- -- --" << endl;
  }

  //
  vector<char> chars;
  for(char c: char_set){
    int m = n+1;
    for(auto c_frq_map: c_frq_maps){
//      cout << c << " " << m << endl;
      m = min(m, c_frq_map[c]);
    }

    for (int i = 0; i < m; ++i) {
      chars.push_back(c);
    }
  }

  sort(chars.begin(), chars.end());
  for(char c: chars) cout << c;
  cout << endl;

}

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

  vector<vector<int>> table(n, vector<int>(26, 0));
  for (int i = 0; i < n; ++i) {

    //
    string s;
    cin >> s;
    for (char c: s) {
      table[i][c -'a']++;
    }
  }

  for (int i = 0; i < 26; ++i) {
    int m = 2500;
    for (int j = 0; j < n; ++j) {
      m = min(m, table[j][i]);
    }
    char c = 'a' + i;
    for (int j = 0; j < m; ++j) {
      cout << c;
    }
  }

  cout << endl;

  return 0;
}



Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N = int(input())
    h = list(map(int, input().split()))

    INF = 10**18
    dp = [INF] * N

    dp[0] = 0
    dp[1] = abs(h[1] - h[0])

    for i in range(2, N):
        a = dp[i - 1] + abs(h[i] - h[i - 1])
        b = dp[i - 2] + abs(h[i] - h[i - 2])
        dp[i] = min(a, b)

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 86424
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N; std::cin >> N;

  std::vector<int> p(N); for(int i=0; i<N; i++) std::cin >> p[i];

  int sums = std::accumulate(p.begin(), p.end(), 0);
  sums -= *std::max_element(p.begin(), p.end())/2;

  std::cout << sums << std::endl;

  return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

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

int main(int argc, char *argv[]) {
    ll a, b;
    cin >> a >> b;

    cout << a * b / gcd(a, b) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, const char * argv[]){
    int n;
    int b, f, r, v;
    int dorm[4][3][10] = {0};
    int i, j, k, x;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        dorm[b-1][f-1][r-1] += v;
    }
    
    for(i = 0; i < 4; i++) {
        for(j = 0; j < 3; j++) {
            for(k = 0; k < 10; k++) {
                printf(" %d", dorm[i][j][k]);
            }
            printf("\n");
        }
        if (i != 3) {
            for(x=0; x<20; x++){
                printf("#");
            }
            printf("\n");
        }
    }
    
    return (0);
}

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

class UnionFind {
public:
    vector<int> par;  // 各頂点の親
    vector<int> rank;  // 各頂点の深さ
    vector<int> sz;  // 各頂点の属する頂点の個数
    int sum_sz;  // 独立集合の個数

    // コンストラクタ
    UnionFind(int n) {
        for (int i = 0; i < n; ++i) {
            par.push_back(i);
            rank.push_back(0);
            sz.push_back(1);
        }
        sum_sz = n;
    }

    // 木の根を求める
    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        // 深さが小さいものから大きい方の根へ辺を張る
        if (rank[x] < rank[y]) par[x] = y;
        else if (rank[x] > rank[y]) par[y] = x;
        else {
            par[y] = x;
            ++rank[x];
        }
        --sum_sz;
        sz[x] = sz[y] = sz[x] + sz[y];
    }

    // x と y が同じ木に属するかの判定
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    // 頂点 x が属する集合の頂点数
    int size(int x) {
        return sz[find(x)];
    }

    // 独立した集合の個数(島の個数)
    int size() {
        return sum_sz;
    }
};

int main() {
    int N, Q;  cin >> N >> Q;
    UnionFind uf(N);
    for (int i = 0; i < Q; ++i) {
        int t, u, v;  cin >> t >> u >> v;
        if (t == 0) uf.unite(u, v);
        else cout << uf.is_same(u, v) << endl;
    }
}


Measured memory_bytes: 5384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int tmp;
        int town[] = {0, 0, 0, 0};
        for(int i = 0;i < 6;i++){
          tmp = sc.nextInt();
          town[tmp -1] += 1;
          if(town[tmp -1] == 3){
            System.out.println("NO");
            return;
          }
        }
		System.out.println("YES");
        
    }
}

Measured memory_bytes: 35728
import itertools

n=int(input())
p_list=list(map(int, input().split()))
q_list=list(map(int, input().split()))

seq=[i for i in range(1, n+1)]
permutation=list(map(list, itertools.permutations(seq)))
p_index=permutation.index(p_list)
q_index=permutation.index(q_list)

print(abs(p_index-q_index))


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

using namespace std;
using ll = long long;

int main() {
    
    int n,r = 0;
    cin >> n >> r;

    if(n < 10){
        r = r + 100 * (10 - n);
    }
    cout << r << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

char s[10];

bool mon(int x) {
    return 1 <= x && x <= 12;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%s", s);
    int x = (s[0] - '0') * 10 + s[1] - '0';
    int y = (s[2] - '0') * 10 + s[3] - '0';
    if (mon(x) && mon(y)) {
        printf("AMBIGUOUS");
    } else if (mon(x)) {
        printf("MMYY");
    } else if (mon(y)) {
        printf("YYMM");
    } else {
        printf("NA");
    }
    return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<vector>
#include<algorithm>

int main(){

	int n, k;
	std::cin >> n >> k;

	std::vector<int> snukes( n, 0 );

	for( int i{}; i < k; ++i )
	{
		int d;
		std::cin >> d;

		for( int j{}; j < d; ++j )
		{
			int x;
			std::cin >> x;
			--x;
			snukes[x] += 1;
		}

	}


	const auto ans = std::count( std::begin( snukes ), std::end( snukes ), 0 );
	std::cout << ans << "\n";

	return 0;
}

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

using namespace std;
#define ll long long int
#define vv vector<int>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(a >= k){
      ans = k;
    }
    else{
      k = k-a;
      ans = a;
      if(b<k){
        k = k-b;
        ans = ans-k;
      }
    }
    cout<< ans;
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;

#define LL long long
#define INF 0x7fffffff
#define P 998244353

LL read(){
    LL x=0,f=1; char ch=getchar();
    while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
    while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

int N,M,S,T;
#define MAXN 200100
struct EdgeNode{
    int next,to,dis,from;
}edge[MAXN<<1];
int head[MAXN],cnt;

void AddEdge(int u,int v,int w) {cnt++; edge[cnt].next=head[u]; head[u]=cnt; edge[cnt].to=v; edge[cnt].from=u; edge[cnt].dis=w;}
void InsertEdge(int u,int v,int w) {AddEdge(u,v,w); AddEdge(v,u,w);}

int deep[MAXN];
void dfs(int now,int last){
	for (int i=head[now]; i; i=edge[i].next)
		if (edge[i].to!=last){
			deep[edge[i].to]=deep[now]+1;
			dfs(edge[i].to,now);
		}
}

int f[MAXN];
int main(){
	N=read();
	for (int i=1; i<=N-1; i++){
		int u=read(),v=read();
		InsertEdge(u,v,1);
	}
	dfs(1,0);
	int mx = 0,mxk;
	for(int i=1; i<=N; i++){
		if (deep[i]>mx) mx=deep[i],mxk=i;
	}
	for (int i=1; i<=N; i++) deep[i]=0;
	dfs(mxk,0);
	for (int i=1; i<=N; i++){
		if (deep[i]>mx) mx = deep[i];
	}
	// printf("%d\n",mx);
	int len = mx+1;
	f[1]=1; f[2]=0;
	for (int i=3; i<=len; i++){
		if (f[i-2] && f[i-1]) f[i]=0;
		else f[i]=1;
	}
	if (f[len]) puts("First");
	else puts("Second");
	return 0;
}

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

int main(){
  long long N,M;
  cin >> N >> M;

  if(N == 1 && M == 1) cout << 1 << endl;
  else if(N == 1){
    cout << N*M - 2 << endl;
  }
  else if(M == 1){
    cout << N*M - 2 << endl;
  }
  else{
    cout << N*M - (N*2 + M*2 -4) << endl;
  }
  return 0;
}

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

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	bool is_gositigo = false;

	if (A == B){
		if (2 == C - B && A + B + C == 17){ is_gositigo = true; }
	}
	else if (A == C){
		if (2 == B - A && A + B + C == 17){ is_gositigo = true; }
	}
	else{
		if (2 == A - B && A + B + C == 17){ is_gositigo = true; }
	}
	if (is_gositigo){ cout << "YES" << endl; }
	else{ cout << "NO" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int mod=1000000007;
int f[1010];
long long cal(int n)
{
	long long ans=1;
	int i,j,k;	
	
	for(i=2;i<=n;i++)
	{
		k=i;
		for(j=2;j<=k;j++)
			while(k%j==0)
			{
				f[j]++;
				k=k/j;
			}
	}
	if(k)
		f[k]++;
	for(i=2;i<=n;i++)
		if(f[i])
			ans=(ans*(f[i]+1)%mod)%mod;
	return ans;
}
int main()
{
	int n;
	while(cin>>n)
	{
		memset(f,0,sizeof(f));
		cout<<cal(n)<<endl;	
	}	
return 0;
}
//1 2 3 4 5 6 7 8 9 10
//3628800
//ans 1
//i2-n
//	k=i
//	j2-k
//	wh k%j0
//	fj++
//	k=k/j
//if k fk++
//i2-n
//	if fi
//	ans=ans*fi+1)m
//1 2 3 4 5 6
//720 30
//6+4+ 3+2+1+3+2+1+2+1+1+1
//2*x1+3*x2+5*x3
//x1+1)*(x2+1)
//1 2 3
//6 4
//3+1

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

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<int, int> pi;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

typedef tuple<string, int, int> T;

bool mycompare(const T &lhs, const T &rhs)
{
  if (get<0>(lhs) != get<0>(rhs))
    return get<0>(lhs) < get<0>(rhs);
  if (get<1>(lhs) != get<1>(rhs))
    return get<1>(lhs) > get<1>(rhs);
}

int main()
{
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> P(N);
  REP(i, N)
  cin >> S[i] >> P[i];
  vector<T> vc;
  REP(i, N)
  vc.push_back(make_tuple(S[i], P[i], i + 1));
  sort(ALL(vc), mycompare);
  REP(i, N)
  cout << get<2>(vc[i]) << endl;
  return 0;
}

Measured memory_bytes: 256
// ABC176E - Bomber
 
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ull;
typedef long long int ll;
 
int main() {
	int H, W, M;
	cin >> H >> W >> M;
 
	int h[M], w[M];
	map<int, int> row;
	for (int i = 0; i < M; i++) {
		cin >> h[i] >> w[i];
		row[h[i]]++;
	}
	ull r_max = 0;
	int max_row = 0;
	for (int i = 1; i <= H; i++) {
		if (r_max < row[i]) {
			max_row = i;
			r_max = row[i];
		}
	}
 
	map<int, int> col;
	for (int i = 0; i < M; i++) {
		if (h[i] != max_row) {
			col[w[i]]++;
		}
	}
	ull c_max = 0;
	for (int i = 1; i <= W; i++) {
		if (c_max < col[i]) {
			c_max = col[i];
		}
	}

	ull ans1 = r_max + c_max;

	map<int, int> col2;
	for (int i = 0; i < M; i++) {
		col2[w[i]]++;
	}
	ull c_max2 = 0;
	int max_col2 = 0;
	for (int i = 1; i <= H; i++) {
		if (c_max2 < col2[i]) {
			max_col2 = i;
			c_max2 = col2[i];
		}
	}
 
	map<int, int> row2;
	for (int i = 0; i < M; i++) {
		if (w[i] != max_col2) {
			row2[h[i]]++;
		}
	}
	ull r_max2 = 0;
	for (int i = 1; i <= W; i++) {
		if (r_max2 < row2[i]) {
			r_max2 = row2[i];
		}
	}

	ull ans2 = r_max2 + c_max2;

	cout << max(ans1, ans2) << endl;

	return 0;
}


Measured memory_bytes: 62196
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL A[300][300];
bool use[300][300];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) cin >> A[i][j];
	}
	memset(use, -1, sizeof(use));
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if (k == i || k == j) continue;
				if (A[i][j] > A[i][k] + A[k][j]) {
					cout << -1 << endl;
					return 0;
				}
				if (A[i][j] == A[i][k] + A[k][j]) use[i][j] = 0;
			}
		}
	}
	LL ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (use[i][j]) ans += A[i][j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;

const LL MOD = 1000000007;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, k = -1;		// equal or less than 100000
		cin >> n >> k;
		if (n < 0) return 0;
		vector<modll> cnt(k + 1, 0);
		modll ans = modll::modpow(k, n);
		for (int i = k; i >= 2; --i) {
			cnt[i] = modll::modpow(k / i, n);
			for (int j = i * 2; j <= k; j += i) {
				cnt[i] -= cnt[j];
			}
			modll x = i - 1;
			x *= cnt[i];
			ans += x;
		}
		cout << ans << endl;
	}
	return 0;
}


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

#define ll long long int
#define ld long double
#define pb push_back

ll mod = 1000000007;

using namespace std;

int main()
{
	
	 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	 int n,p;
	 cin>>n>>p;
	 p += n*3;
	 cout<<p/2<<"\n";

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, bool>>> shougen(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        for (int j = 0; j < a.at(i); j++) {
            int x;
            bool y;
            cin >> x >> y;
            shougen.at(i).push_back(make_pair(x, y));
        }
    }

    int cnt_max = 0;
    for (int i = 0; i < (1 << n); i++) {
        bitset<15> s(i);
        bool flag = true;
        for (int j = 0; j < n; j++) {
            if (s.test(j)) {
                for (int k = 0; k < a.at(j); k++) {
                    if (s.test(shougen.at(j).at(k).first - 1) !=
                        shougen.at(j).at(k).second) {
                        flag = false;
                        break;
                    }
                }
                if (flag == false) {
                    break;
                }
            }
        }
        if (flag == true) {
            cnt_max = (cnt_max > (int)s.count()) ? cnt_max : (int)s.count();
        }
    }
    cout << cnt_max << endl;
    return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <cassert>


using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	int ans = 0;
	int cur = 1;
	for (int i = 0; i < n; i++) {
		if (v[i] == cur)
			cur++;
		else
			ans++;
	}
	if (cur == 1) {
		cout << -1;
	}
	else {
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define N 200009
#define INF 1000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%lld%lld",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) prllf("%d",x);
#define pf2(x,y) prllf("%d %d\n",x,y);
#define pf3(x,y,z) prllf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;
ll input[N];
ll tree[4*N+9];
ll a[N],b[N];

void update(ll low,ll high,ll pos,ll up,ll index){
	if(low==high){
	        tree[pos] = up;
			return;
	}
	ll mid=(low+high)/2;
	if(index<=mid){
	update(low,mid,2*pos+1,up,index);	
	}
	else{
	update(mid+1,high,2*pos+2,up,index);
	}	
	tree[pos]=max(tree[2*pos+1],tree[2*pos+2]);
}
ll query(ll low,ll high,ll pos,ll l,ll r){
	if(low>r || high<l){
		return 0;
	}
	if(low>=l && high<=r){
		return tree[pos];
	}
	ll mid=(low+high)/2;
	ll p1=query(low,mid,2*pos+1,l,r);
	ll p2=query(mid+1,high,2*pos+2,l,r);
	return max(p1,p2);
}

int main(){
    ll i,j,n,m,t,k,x,y;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    for(i=0; i<n; i++){
        cin >> b[i];
    }
    ll ans=b[0],temp;
    update(0,n,0,b[0],a[0]);
    for(i=1; i<n; i++){
        temp=query(0,n,0,0,a[i]-1);
        temp+=b[i];
        // tr3(i,a[i],temp);
        ans=max(ans,temp);
        update(0,n,0,temp,a[i]);
        
        
        // temp=query(0,n,0,0,a[i]-1);
        // tr3(i,a[i],temp);
        // cout << endl;
        
    }
    tr(ans);
}

Measured memory_bytes: 8576
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

//int main() {
//	long long a, b, x;
//	cin >> a >> b >> x;
//	long long ans = 0;
//	long long d = 10;
//
//	for (int i = 0;i < 10;i++) {
//		if (x < a * (long long)pow(10, i) + b * ((long long)i + (long long)1)) {
//			d = i;
//			break;
//		}
//	}
//
//	if (d == 0) {
//		cout << 0 << endl;
//		return 0;
//	}
//
//	x -= b * d;
//	ans = x - b*d / a;
//	if (ans > 1000000000) {
//		ans = 1000000000;
//	}
//
//	cout << ans << endl;
//
//	return 0;
//}

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

	for (int i = 1;i <= 9;i++) {
		for (int j = 1;j <= 9;j++) {
			if (n == i * j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; ll k; cin >> n >> k;
	vi pl, mi;
	rep(i, n){
		int a; cin >> a;
		if(a < 0) mi.pb(-a);
		else pl.pb(a);
	}
	sort(all(pl)); sort(all(mi));
	
	auto calc = [&](const vi &a, const vi &b, ll lim){
		ll res = 0;
		for(int i : a){
			if(i) res += upper_bound(all(b), (int)min(inf + 1ll, lim / i)) - b.begin();
			else res += b.size();
		}
		return res;
	};
	
	ll lo = -1.1e18, hi = 1.1e18, mid;
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		ll cnt = 0;
		if(mid >= 0){
			ll cntp = calc(pl, pl, mid);
			ll cntm = calc(mi, mi, mid);
			for(int i : pl) if((ll)i * i <= mid) cntp--;
			for(int i : mi) if((ll)i * i <= mid) cntm--;
			cnt += (ll)pl.size() * mi.size();
			cnt += (cntp + cntm) / 2;
		}
		else{
			cnt += (ll)pl.size() * mi.size() - calc(pl, mi, -mid - 1);
		}
		if(cnt >= k) hi = mid;
		else lo = mid;
	}
	cout << hi << endl;
	return 0;
}

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

typedef long long ll;									//XD
#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
//#define kill(x) {cout<<x; return;}
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);         
#endif
}

const int mod = 1e9+7;
const int maxn = 2e3+5;
int h[maxn]={};
void solve(){
	int a; cin>>a;
	int res = a + a*a + a*a*a;
	cout<<res;
}
signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);// io();
    //cout<<setprecision(100);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }

    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif

    return 0;
}


Measured memory_bytes: 3640
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> H;
  ll level = 0;
  
  while (H > 0) {
    H /= 2;
    level++;
  }


  return (1LL << level) - 1;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
string chk[N+100];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k,r,s,p,ans = 0;
	string t;
	cin >> n >> k;
	cin >> r >> s >> p;
	cin >> t;
	int sz = t.size();
	for(int i=0;i<sz;i++){
		chk[i%k] += t[i];
	}
	for(int i=0;i<k;i++){
		int ins = chk[i].size();
		for(int j=0;j<ins;)
		{
			int l;
			for(l=j+1;l<ins&&chk[i][l]==chk[i][j];l++);
			int cnt = (l-j+1)/2;
			if(chk[i][j]=='r'){
				ans += (cnt*p);
			}
			else if(chk[i][j]=='s'){
				ans += (cnt*r);
			}
			else{
				ans += (cnt*s);
			}
			j = l;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 5328
// template.cpp {{{
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
struct pre_{pre_(){cin.tie(0);ios::sync_with_stdio(0);}} pre__;
// }}}

const int INF = 1e9 + 9;

signed main() {
  int n;
  cin >> n;
  vector<int> t(n);
  rep(i, n) cin >> t[i];

  int num = -INF, den = INF;
  int a, b;


  rep(i, n) rep(j, n) {
    if (i == j) continue;
    if (t[i] - t[j] > 0 && t[i] - t[j] < den) {
      a = t[i];
      b = t[j];
      den = t[i] - t[j];
    }
  }

  rep(i, n) rep(j, n) {
    if (i == j) continue;
    if (t[i] == a || t[i] == b || t[j] == a || t[j] == b) continue;
    if (t[i] + t[j] > num) {
      num = t[i] + t[j];
    }
  }

  double res = (double)num / (double)den;

  num = -INF;
  den = INF;
  rep(i, n) rep(j, n) {
    if (i == j) continue;
    if (t[i] + t[j] > num) {
      a = t[i];
      b = t[j];
      num = t[i] + t[j];
    }
  }

  rep(i, n) rep(j, n) {
    if (i == j) continue;
    if (t[i] == a || t[i] == b || t[j] == a || t[j] == b) continue;
    if (t[i] - t[j] > 0 && t[i] - t[j] < den) {
      den = t[i] - t[j];
    }
  }
  cout << fixed << setprecision(10) << max(res, (double)num / (double)den) << endl;
}

Measured memory_bytes: 3276
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int n, m;
int row, column;
vector<vector<int>> s;

void input() {
	cin >> n;
}

bool exist() {
	m = n * 2;
	row = (int)ceil(sqrt((double)m));
	column = row - 1;
	return row * column == m;
}

void crossing() {
	int finished = 0;
	int filled = 0;
	for (int i = 0; i < row; i++) {
		vector<int> t;
		s.push_back(t);
	}
	while (finished < n) {
		int finished_base = finished;
		for (int i = 1; s.at(filled).size() < column; i++, finished++) {
			s.at(filled).push_back(finished_base + i);
			s.at(filled + i).push_back(finished_base + i);
		}
		filled++;
	}
}

void output() {
	cout << row << "\n";
	for (int ri = 0; ri < row; ri++) {
		cout << column << " ";
		for (int ci = 0; ci < column; ci++) {
			cout << s.at(ri).at(ci);
			if (ci < column - 1) {
				cout << " ";
			}
			else {
				cout << "\n";
			}
		}
	}
}

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

	input();
	if (exist()) {
		cout << "Yes" << "\n";
		crossing();
		output();
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}

Measured memory_bytes: 2304
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let a = input[0]
let b = input[1]
if (a...b)~=0 {
  print("Zero")
} else if a<0 && (a...min(b,-1)).count%2>0 {
  print("Negative")
} else {
  print("Positive")
}

Measured memory_bytes: 768