akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

const int DIM = 2e5 + 7;

#define int long long

int v[DIM];

int segments;

main()
{
	IOS
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	
	int l = 1;
	int r = 1;
	
	int sum = v[1];
	
	while(r < n)
	{
		if((sum ^ v[r + 1]) == sum + v[r + 1])
		{
			r++;
			sum += v[r];
		}
		else
		{
			sum -= v[l];
			segments += (r - l + 1);
			l++;
			
			if(l > r)
			{
				r = l;
				sum = v[l];
			}
		}
	}
	
	while(l <= r)
	{
		segments += (r - l + 1);
		l++;
	}
	
	cout << segments;
	
}

Measured memory_bytes: 1792
#include<stdio.h>

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

   if(a <= b){
      for(int i = 0; i < b; i++){
         printf("%d", a);
      }
   }else{
      for(int i = 0; i < a; i++){
         printf("%d", b);
      }
   }
   printf("\n");
   return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
long long n,k[100010];
int main(){
  cin>>n;
  for(int i=0;i<n;++i){cin>>k[i];}
  long long ans=1,mon=0;
  for(int i=0;i<n-1;++i){
    if(mon==0){
      if(k[i]<k[i+1])
        mon=1;
      else if(k[i]>k[i+1])
        mon=-1;
    }
    else if(mon>0){
      if(k[i]>k[i+1]){
        ++ans;
        mon=0;
      }
    }
    else if(mon<0){
      if(k[i]<k[i+1]){
        ++ans;
        mon=0;
      }
    }
  } 
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

const long long bases[] = {10007,10009/*,10037*/};

template<long long mod = 1000000007>
struct RollingHashSimple{
	using ll = long long;
	vector<ll> hashes[2],powers[2];
	RollingHashSimple(const string &s){
		int n = s.length();
		for(int i = 0;i < 2;i++){
			hashes[i].resize(n + 1,0);
			powers[i].resize(n + 1,1);
			for(int j = 0;j < n;j++){
				powers[i][j + 1] = powers[i][j] * bases[i] % mod;
				hashes[i][j + 1] = (hashes[i][j] * bases[i] + s[j]) % mod;
			}
		}
	}
	inline ll hash(int l,int r,int b) const{
		return (hashes[b][r] - hashes[b][l] * powers[b][r - l] % mod + mod) % mod;
	}
	ll hash(int l = 0,int r = -1) const{
		if(r == -1) r = hashes[0].size() - 1;
		return hash(l,r,0) * mod + hash(l,r,1);
	}
	inline bool isSame(int a,int b,int c,int d) const{
		return hash(a,b) == hash(c,d);
	}
};

signed main(){
	string s,t;
	cin >> s >> t;
	RollingHashSimple<> rhs(s),rht(t);
	vector<int> st;
	for(int i = 0;i < t.length();i++){
		for(int j = 'A';j <= 'z';j++){
			if(!isalpha(j) || j == t[i]) continue;
			int hash[2];
			for(int k = 0;k < 2;k++){
				hash[k] = (rht.hash(0,t.length(),k) + (j - t[i] + MOD) * rht.powers[k][t.length() - i - 1]) % MOD;
			}
			st.push_back(hash[0] * MOD + hash[1]);
		}
	}
	sort(all(st));
	int ans = 0;
	for(int i = 0;i < s.length() - t.length() + 1;i++){
		int x = rhs.hash(i,i + t.length());
		int ind = lower_bound(all(st),x) - st.begin();
		if(ind < st.size() && st[ind] == x) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 83468
#include <stdio.h>
#include <iostream>
#include <cmath>
using namespace std;

int main(void)
{		
	int a, b;
	char op;
	
	while (1) {
		cin >> a >> op >> b;
		if (op == '?') break;
		
		int ans;
		if (op == '+') {
			ans = a + b;
		} else if (op == '-') {
			ans = a - b;
		} else if (op == '*') {
			ans = a * b;
		} else {
			ans = a / b;
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3124
import java.io.*
import java.lang.*


fun solve() {
    val N = rd.readInt()
    val A = rd.readListIntCol(N)
    
    val ans = if(A.none { it % 2 == 1 }) {
        "second"
    } else {
        "first"
    }
    println(ans)
}


//val rd = debug.Reader("etc", "caddi2018", "d", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 49556
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll MOD = 1e9 + 7;
	int n; cin >> n;
	string s; cin >> s;
	vector<ll> v(26, 0);
	for (char x : s)++v[x - 'a'];
	ll res = 1;
	rep(i, 26)
	{
		res *= v[i] + 1;
		res %= MOD;
	}
	cout << res - 1 << endl;
}

Measured memory_bytes: 512
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

fun floorSum(n: Long, m: Long, a0: Long, b0: Long): Long {
    var ans = 0L
    var a = a0
    var b = b0
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2
        a %= m
    }
    if (b >= m) {
        ans += n * (b / m)
        b %= m
    }

    val yMax = (a * n + b) / m
    val xMax = yMax * m - b
    if (yMax == 0L) return ans
    ans += (n - (xMax + a - 1) / a) * yMax
    ans += floorSum(yMax, a, m, (a - xMax % a) % a)
    return ans
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val T = sc.next().toInt()
        repeat(T) {
            val N = sc.next().toLong()
            val M = sc.next().toLong()
            val A = sc.next().toLong()
            val B = sc.next().toLong()
            pw.println(floorSum(N, M, A, B))
        }
    }
}


Measured memory_bytes: 59628
N = int(input())
list = map(int,input().split(" "))
cards = sorted(list,reverse=True)

if len(cards) % 2 == 0:
    alice = 0
    for i in range(int(N/2)):
        alice = alice + cards[2 * i]
    bob = 0
    for j in range(int(N/2)):
        bob = bob + cards[2 * j + 1]
else:
    alice = 0
    for i in range(int(N/2) + 1):
        alice = alice + cards[2 * i]
    bob = 0
    for j in range(int(N/2)):
        bob = bob + cards[2 * j + 1]
        
print(alice - bob)

Measured memory_bytes: 38416
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
bool is_pal(string& s)
{
    string rev = s;
    reverse(all(rev));
    return rev == s;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int l;
    cin >> l;
    cout << fixed << setprecision(20) << l * l * l / (ld)27 << endl;
    GAME_OVER;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

vector<vector<ll>> G;
vector<ll> bip;
void dfs(ll V, ll P)
{
  //cerr << V << endl;
  if (bip.at(V) != -1)
  {
    if (bip.at(V) != 1 - P)
      FINALANS(-1);
    return;
  }
  bip.at(V) = 1 - P;

  for (auto nv : G.at(V))
  {
    dfs(nv, bip.at(V));
  }
}

int main()
{
  ll N;
  cin >> N;
  G = vector<vector<ll>>(N);
  vector<string> S(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> S.at(i);
    for (ll j = 0; j < N; j++)
    {
      if (S.at(i).at(j) == '1')
      {
        G.at(i).push_back(j);
      }
    }
  }
  /*
  for (ll i = 0; i < N; i++)
  {
    cerr << i << "  ";
    for (auto v : G.at(i))
    {
      cerr << v << " ";
    }
    cerr << endl;
  }
  */

  bip = vector<ll>(N, -1);
  dfs(0, 1);

  vector<vector<ll>> dist(N, vector<ll>(N, INF));
  for (ll i = 0; i < N; i++)
  {
    for (ll j = 0; j < N; j++)
    {
      if (i == j)
        dist.at(i).at(j) = 0;
      else if (S.at(i).at(j) == '1')
        dist.at(i).at(j) = 1;
    }
  }

  for (ll k = 0; k < N; k++)
  {
    for (ll i = 0; i < N; i++)
    {
      for (ll j = 0; j < N; j++)
      {
        chmin(dist.at(i).at(j), dist.at(i).at(k) + dist.at(k).at(j));
      }
    }
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++)
  {
    for (ll j = 0; j < N; j++)
    {
      //cerr << dist.at(i).at(j) << " ";
      chmax(ans, dist.at(i).at(j));
    }
    //cerr << endl;
  }

  cout << 1 + ans << endl;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n"; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug() << imie(x) imie(y)
//debugging ends
typedef long long ll;

int solve(){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(k < x/d){
      cout<<abs(x-d*k);
      return 0;
    }
    k-=x/d;
    x%=d;
 
    if(k%2==0){
        cout<<x%d;
      }else{
        cout<<d-x;
      } 
    
    return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cerr<<fixed<<setprecision(10);
  auto start = chrono::high_resolution_clock::now();
  int t=1;
  //cin>>t;
  while(t--)
    solve(),cout<<"\n";

  auto stop = chrono::high_resolution_clock::now(); 
  auto duration = chrono::duration_cast<chrono::nanoseconds>(stop - start); 
  cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s \n";      
  
  return 0;
}


Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

signed main() {
	int n, d;
	cin >> n >> d;
	if (n % (2 * d + 1) == 0) {
		cout << n / (2 * d + 1) << endl;
	}
	else {
		cout << n / (2 * d + 1) + 1 << endl;
	}
}

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

int main() {
    int n;
    cin >> n;
    rep(i,n)rep(j,n) g[i][j] = -1;
    rep(i,n) {
      int m;
      cin>>m;
      rep(j,m) {
        int a, x;
        cin >> a >> x;
        --a;
        g[i][a] = x;
      }
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n) if(i>>j&1) d[j] = 1;
        bool ok = true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(g[j][k]==-1) continue;
                    if(g[j][k]!=d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define R register int
#define G if(++ip==ie)if(fread(ip=buf,1,SZ,stdin))
using namespace std;
const int SZ=1<<19,N=1e5+9,M=2*N;
char buf[SZ],*ie=buf+SZ,*ip=ie-1;
inline int in(){
    G;while(*ip<'-')G;
    R x=*ip&15;G;
    while(*ip>'-'){x*=10;x+=*ip&15;G;}
    return x;
}
int he[N],ne[M],to[M],f[N],a[N],b[N];
int Getf(R x){
    return x==f[x]?x:f[x]=Getf(f[x]);
}
void Dfs(R x,R op){
    a[x]=op;
    for(R y,i=he[x];i;i=ne[i])
        if((y=to[i])!=f[x])
            f[y]=x,Dfs(y,-op),a[x]+=a[y];
}
int main(){
    R n=in(),m=in(),rt=1,re=1,p=0,ans=0;
    for(R i=1;i<=n;++i)f[i]=i;
    for(R p=0,i=1;i<=m;++i){
        R x=in(),y=in();
        if(Getf(x)!=Getf(y))f[f[x]]=f[y];
        else{rt=x,re=y;continue;}
        ne[++p]=he[x];to[he[x]=p]=y;
        ne[++p]=he[y];to[he[y]=p]=x;
    }
    f[rt]=0;Dfs(rt,1);
    if(n==m){
        for(R x=re;x;x=f[x])b[++p]=a[x];
        if(p&1){
            if(a[rt]&1)return puts("-1"),0;
            for(R x=re;x;x=f[x])a[x]-=a[rt]/2;
        }
        else{
            if(a[rt])return puts("-1"),0;
            sort(b+1,b+p+1);
            for(R x=re;x;x=f[x])a[x]-=b[p/2];
        }
    }
    else if(a[rt])return puts("-1"),0;
    for(R i=1;i<=n;++i)ans+=abs(a[i]);
    return cout<<ans<<endl,0;
}

Measured memory_bytes: 14888
import sys


def main():
    N, K = map(int, sys.stdin.readline().rstrip().split())
    L = [0] * 10
    R = [0] * 10
    for i in range(K):
        l, r = map(int, sys.stdin.readline().rstrip().split())
        L[i], R[i] = l, r

    dp = [0] * (N + 1)
    up = [0] * (N + 1)
    up[0] = 1
    up[1] = -1
    for i in range(1, N + 1):
        dp[i] = dp[i - 1] + up[i - 1]
        for j in range(K):
            if i + (L[j] - 1) < N + 1:
                up[i + (L[j] - 1)] += dp[i]
            if i + R[j] < N + 1:
                up[i + R[j]] -= dp[i]
        dp[i] %= 998244353

    print(dp[N])


main()


Measured memory_bytes: 29984
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll d = c-a-b;
    if (d <= 0) {
        cout << "No" << endl;
        return 0;
    }
    if (4*a*b >= d*d) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int s = 1, e;

int q(int x){
    printf("%d\n", x); fflush(stdout);
    char buf[10]; scanf("%s", buf);
    if(buf[0] == 'V') return -1;
    if(buf[0] == 'M') return 0;
    return 1;
}

int main(){
    scanf("%d", &e); e--;
    int x = q(0);
    if(x < 0) return 0;
    while(true){
        int m = (s + e) / 2;
        int t = q(m);
        if(t < 0) return 0;
        if(x ^ t ^ (m & 1)) e = m - 1;
        else s = m + 1;
    }
}

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

struct card{
	int  number;
	char mark;
};

void BubbleSort(vector<card> &A)
{
	bool flag = true;
	while(flag){
		flag = false;
		for(int j = A.size() - 1; j >= 1; j--){
			if(A[j].number < A[j-1].number){
				swap(A[j], A[j-1]);
				flag = true;
			}
		}
	}
}

void SelectionSort(vector<card> &A)
{
	for(int i = 0; i < A.size(); i++){
		int minj = i;
		for(int j = i; j < A.size(); j++){
			if(A[j].number < A[minj].number){
				minj = j;
			}
		}
		if(minj != i){
			swap(A[i], A[minj]);
		}
	}
}

void Output(vector<card> A)
{
	int n = A.size() - 1;
	for(int i = 0; i < n; i++){
		cout << A[i].mark << A[i].number << ' ';
	}
	cout << A[n].mark << A[n].number << endl;
}

vector<card> Input()
{
	int N;
	cin >> N;
	vector<card> A;
	A.resize(N);
	for(int i = 0; i < N; i++){
		cin >> A[i].mark >> A[i].number;
	}
	return A;
}

bool Judge(vector<card> A, vector<card> B){
	for(int i = 0; i < A.size(); i++){
		if(A[i].mark != B[i].mark){
			return false;
		}
	}
	return true;
}

int main()
{
	vector<card> A = Input();
	vector<card> B = A;
	
	BubbleSort(A);
	Output(A);
	cout << "Stable" << endl;
	SelectionSort(B);
	Output(B);
	if(Judge(A, B)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" <<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    bool f1[n];
    bool f2[n];
    m0(f1);
    m0(f2);
    rep(i,m){
        intl a,b;
        cin >> a >> b;
        if(a == 1)f1[b - 1] = true;
        if(b == n)f2[a - 1] = true;
    }
    bool f = false;
    rep(i,n){
        if(f1[i]&&f2[i]){
            f = true;
            break;
        }
    }
    fp(f,"POSSIBLE","IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define I64 "%I64d"
#define RAN(v)v.begin(),v.end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
template<class T>
inline void upd1(T&a,T b){a>b?a=b:0;}
template<class T>
inline void upd2(T&a,T b){a<b?a=b:0;}
struct ano{
	operator ll(){
		ll x=0,y=0,c=getchar();
		while(c<48)
			y=c==45,c=getchar();
		while(c>47)
			x=x*10+c-48,c=getchar();
		return y?-x:x;
	}
}buf;
char s[100];
int main(){
	scanf("%s",s);
	s[strlen(s)-8]=0;
	puts(s);
}

Measured memory_bytes: 256
import bisect
A, B, Q = map(int, input().split())

S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

bLeft = bisect.bisect_left

for x in X:
    si = bLeft(S, x)
    sleft = float('inf')
    sright = float('inf')
    if si != 0:
        sleft = x-S[si-1]
    if si != A:
        sright = S[si]-x

    ti = bLeft(T, x)
    tleft = float('inf')
    tright = float('inf')
    if ti != 0:
        tleft = x-T[ti-1]
    if ti != B:
        tright = T[ti]-x

    ans1 = max(sleft, tleft)
    ans2 = max(sright, tright)
    ans3 = min(min(sleft, sright), min(tleft, tright)) + min(sleft, sright) + min(tleft, tright)
    print(min(ans1, ans2, ans3))


Measured memory_bytes: 16144
#include <bits/stdc++.h>
 
using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line
 
vector<int> G[100100];
 
const ll mod = 1e9+7;
int main()
{
	int n, k;
	cin >> n >> k;
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		--a, --b; // 0 -indexedにしておく。
		G[a].push_back(b);
		G[b].push_back(a);
	}
	queue<int> que;
	que.push(0);
	ll ans = 1;
	vector<bool> seen(n+1,false);
	ans *= k;
	seen[0] = true;
	while(que.size()){
		int p = que.front(); 
		que.pop();
		int now = k-1; // 頂点pは既に色を塗っているので、使える色が一色減る
		for(int i = 0; i < G[p].size(); i++){ // 頂点pに隣接する頂点で色が塗られている分だけ使える色が減る
			int x = G[p][i]; 
			if(seen[x]){
				now--;
			}
		}
		for(int i = 0; i < G[p].size(); i++){
			int x = G[p][i]; // 頂点 x を塗る
			if(seen[x]) continue;
			seen[x] = true;
			ans *= now;
			ans %= mod;
			now--;
			que.push(x);
		}
	}
	cout << ans << endl;
}


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char buf[11111];

void MAIN() {
    scanf("%d", &N);

    int ans = 0;
    int ba = 0, bx = 0, xa = 0, xx = 0;
    REP (i, N) {
	scanf("%s", buf);
	int len = strlen(buf);
	REP (j, len-1) if (buf[j] == 'A' && buf[j+1] == 'B') ans++;
	if (buf[0] == 'B') {
	    if (buf[len-1] == 'A') ba++;
	    else bx++;
	} else {
	    if (buf[len-1] == 'A') xa++;
	    else xx++;
	}
    }

    if (ba) {
	ans += ba - 1;
	ba = 1;
    }
    if ((xa || bx) && ba) {
	ans++;
	ba = 0;
    }
    int g = min(xa, bx);
    ans += g;
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long X; cin >> X; 
	long long tmp = 100; 
	for(int i = 1; i <= 114514; i++){
		tmp += tmp / 100; 
		if(tmp >= X){
			cout << i << endl; return 0; 
		}
	}
}

Measured memory_bytes: 3644
main = do
  s <- getContents
  let ss = init . lines $ s
  mapM_ (putStrLn . toString . comp . map read . words) ss
  
toString :: [Integer] -> String
toString [x,y] = show x ++ " " ++ show y

comp :: [Integer] -> [Integer]
comp [x,y] 
  | x > y  = [y,x]
  | x <= y = [x,y]

Measured memory_bytes: 4468
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

int n,L;
int a[100000];
vector<int> ans;
int sum = 0;

int main(){
  cin>>n>>L;
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n-1){
    if(a[i]+a[i+1]>=L){
      cout<<"Possible"<<endl;
      for(int j = 0; j < i; j++) cout<<j+1<<endl;
      for(int j = n-1; j > i; j--) cout<<j<<endl;
      return 0;
    }
  }
  cout<<"Impossible"<<endl;
  return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

// i個目までの品物について考慮したとき
// 重さjで得られる価値の最大値
// オーバーフローに注意
LL dp[110][100010];

int main(){
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(j+w[i] <= W){
                // ナップサックに入れる
                dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j]+v[i]);
            }
            // 入れない
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int num[200];

int main(){
	int n, k; cin >> n >> k;
	rep(i, k){
		int d; cin >> d;
		rep(j, d){
			int p; cin >> p;
			p--;
			num[p]++;
		}
	}
	int ans = 0;
	rep(i, n){
		if(num[i]==0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
//_Krenil_Bhikadiya_

#include<bits/stdc++.h>
#define MAX_SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define max(a,b) (a<b?b:a) 
#define min(a,b) (a>b?b:a) 
#define ll long long
#define ld long double
#define llu unsigned long long int
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define umap unordered_map
#define uset unordered_set
#define rep(i,a,n) for(int i=(int)a;i<(int)n;i++)
#define rev(i,n,a) for(int i=(int)n;i>=(int)a;i--)
#define pb push_back
#define ff first
#define ss second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
const int INF  = 1e9;
const llu INFM = 1e18;
const int mod  = INF+7;
using namespace std;


int gcd(int A,int B)
{
	if(A==0) return B;

	return gcd(B%A,A);
}

int lcm(int A,int B)
{
	return ( A*B / gcd(A,B) );
}

ll mod_pwr(ll A,ll B,ll P)
{
	ll RES = 1; A %= P;

	while(B>0)
	{
		if(B&1) RES = RES * A % P;
		A = A * A % P;
		B >>= 1;
	}

	return RES;
}

llu pwr(llu A,llu B)
{
	llu RES=1;

	while(B>0)
	{
		if(B&1) RES*=A;
		A=A*A;
		B>>=1;
	}

	return RES;
}

ll modInv(ll A,ll M)
{
	return mod_pwr(A,M-2,M);
}

bool isPrime(int N)
{
	if(N==1) return false;

	for(int i=2;i*i<=N;i++)
	{
		if(N%i==0) return false;
	}

	return true;
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	MAX_SPEED
	
	int test=1; //cin>>test;
	while(test--)
	{
		int n,k; cin>>n>>k;

		int a[n];

		vi dp(n,INT_MAX);

		rep(i,0,n) cin>>a[i]; dp[0]=0;

		rep(i,1,n)
		{
			rep(j,1,k+1)
			if((i-j)>=0)dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}

		cout<<dp[n-1]<<endl;
	}
}



Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n)-1;i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

string s;

int main(){
    cin>>s;
    int l=s.size();
    int n=l-7;
    bool flag=false;
    if(n==0) flag=true;
    else{
        string sf=s.substr(0,l-n);
        string se=s.substr(n,l-n);
        if(sf=="keyence") flag=true;
        else if(se=="keyence") flag=true;
        else{
            rep(i,0,l-n){
                string sss=s.substr(0,i)+s.substr(i+n,7-i);
                if(sss=="keyence") flag=true;
            }
        }
    }
    if(flag) cout<<"YES"<<"\n";
    else cout<<"NO"<<"\n";
    return 0;
}

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

using namespace std;

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;

  for (auto& c : s) {
    if (c != s[k-1]) {
      cout << "*";
    } else {
      cout << c;
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "string"
using namespace std;

int main()
{
    int a,b,c,d,e;
    cin >>a>>b>>c>>d>>e;
    if (a==0){
        cout<<"1";
    }
    else if (b==0){
        cout<<"2";
    }
     else if (c==0){
        cout<<"3";
    }
     else if (d==0){
        cout<<"4";
    }
     else if (e==0){
        cout<<"5";
    }
}



Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    string x;
    cin >> x;
    int n[4];
    for(int i=0; i<4; i++) {
        n[i] = (int)(x[i] - '0');
    }
    int a = n[0]*10 + n[1];
    int b = n[2]*10 + n[3];
    if(a <= 12 && b <= 12 && a != 0 && b != 0){
        cout << "AMBIGUOUS" << endl;
        return 0;
    } else if(a == 0 && b <= 12 && b != 0){
        cout << "YYMM" << endl;
        return 0;
    } else if(a > 12 && b <= 12 && b != 0){
        cout << "YYMM" << endl;
        return 0;
    } else if(a <= 12 && b == 0 && a != 0){
        cout << "MMYY" << endl;
        return 0;
    } else if(a <= 12 && b > 12 && a != 0){
        cout << "MMYY" << endl;
        return 0;
    } else
        cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll A, B, C;
	cin >> A >> B >> C;
	for (int it = 0; it < 1000000; ++it) {
		if ((A & 1) || (B & 1) || (C & 1)) {
			printf("%d\n", it);
			return 0;
		}
		ll a = A / 2;
		ll b = B / 2;
		ll c = C / 2;
		A += b + c;
		B += a + c;
		C += a + b;
	}
	puts("-1");
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N, ans=0;
	string S;

	cin >> S;
	char cur = S[0];
	for(auto c: S){
		if( cur != c ) ans++;
		cur = c;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  vector<ll> v(n);
  for(ll i=0; i<n; ++i){
    cin>>v[i];
  }
  ll x=0;
  for(ll i=0; i<n-1; ++i){
    ll c=v[i+1]-v[i];
    ll d=c*a;
    x+=min(d,b);
  }
  cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
# import resource

sys.setrecursionlimit(10 ** 9)
# resource.setrlimit(resource.RLIMIT_STACK, ((2 ** 7) * 1000 * 1000, -1))

k = int(input())

ary = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def ans(j, nums):
    nums[j] += 1
    pre = nums[j]
    for i in range(j + 1, len(nums)):
        if pre > 0:
            nums[i] = pre - 1
            pre = nums[i]
        else:
            nums[i] = pre
    return int(''.join(map(str, nums)))

def lunlun(n):
    if n <= 9:
        return ary[n - 1]
    l = lunlun(n - 1)
    nums = list(map(int, list(str(l))))
    first = len(nums) - 1
    last = 0
    for i in range(len(nums)):
        j = len(nums) - i - 1
        c = nums[j] + 1
        # 桁数が変わらないとき
        if j == first:
            # 1桁目
            if nums[j] < 9 and abs(nums[j - 1] - c) <= 1:
                nums[j] += 1
                return int(''.join(map(str, nums)))
        elif j == last:
            # 最終桁
            if nums[j] < 9 and abs(nums[j + 1] - c) <= 1:
                return ans(j, nums)
        elif j != first and j != last:
            # 間の桁
            if nums[j] < 9 and abs(nums[j - 1] - c) <= 1 and abs(nums[j + 1] - c) <= 1:
                return ans(j, nums)

    # 桁が繰り上がるとき
    return int('1' + ''.join(['0'] * len(nums)))

print(lunlun(k))


Measured memory_bytes: 90484
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

x,y,z = m()

print(z,x,y)





Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int N;
    cin >> N;
    int H[N+10];
    REP(i,N){
        cin >> H[i];
    }
    int res = 1;
    FOR(i,1,N){
        bool great = false;
        REP(j,i){
            if(H[i]<H[j]){
                great = true;
                break;
            }
        }
        if(great == false) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define show(x) std::cerr << #x << "=" << x << std::endl
using namespace std;
typedef long long ll;
const double eps=1e-8;
const int maxn = 2e5+5;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
int t;
int n,m;
int main()
{
    int x[10];
    bool bo[10];
     memset(bo,0,sizeof bo);
    for(int i=1;i<=5;++i) {
        cin>>x[i];
        bo[x[i]] = 1;
    }
    for(int i=1;i<=5;++i)
    {
        if(!bo[i]) {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3756
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long int base = 1e9 + 7;
    vector<pair<int, int>> input(n, make_pair(0, 0));
    for (int i = 0; i < input.size(); ++i) {
        cin >> input[i].first;
        input[i].second = i;
    }
    sort(input.begin(), input.end());
    vector<pair<int, int>> segments;
    for (int i = 0; i < input.size() - 1; ++i) {
        if (input[i].first == input[i + 1].first &&
            input[i + 1].second - input[i].second > 1) {
            segments.push_back(make_pair(input[i].second, input[i + 1].second));
        }
    }
    sort(segments.begin(), segments.end());
    vector<long long int> dp(segments.size());
    for (int i = segments.size() - 1; i >= 0; --i) {
        int key = segments[i].second;
        auto it =
            lower_bound(segments.begin(), segments.end(), make_pair(key, 0));
        long long int cur = 1;
        if (it != segments.end())
            cur = (cur + dp[it - segments.begin()]) % base;
        if (i < segments.size() - 1) cur = (cur + dp[i + 1]) % base;
        dp[i] = cur;
    }
    // for (int i = 0; i < segments.size(); ++i) {
    //     cout << segments[i].first << "," << segments[i].second << " " <<
    //     dp[i]
    //          << endl;
    // }
    long int ans = 1;
    if (dp.size() > 0) ans = (ans + dp[0]) % base;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5104
parseInt(x) = parse(Int, x)

function main()
	n,m = map(parseInt, split(readline()))
	if n == 1&& m == 1
		print(1)
	elseif n == 1 || m == 1
		print(max(n,m)-2)
	else
		print((n-2)*(m-2))
	end
end

main()

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

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

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

    if (a > c) {
        cout << b + c << endl;
        return 0;
    }

    int sum = 0;
    sum = a;
    c -= a;

    if (b >= c) {
        sum += b + c;
    }
    else
        sum += (b *2 + 1);

    cout << sum << endl;
}

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

int main() {

    string s;
    cin >> s; 

    ll cnt = 0;
    ll ans = 0;

    // 後ろから見る
    for(int i = s.size()-1; i >= 0; --i){
        if(i > 0 && s[i] == 'C' && s[i-1] == 'B'){
            // BCを連結して見る
            cnt++;
            i--;
        }
        else if(s[i] == 'A'){
            // BCの数だけAが転倒できる
            ans += cnt;
        } 
        else{
            // 途切れたらAは転倒する場所がなくなる
            cnt = 0;
        }
    }
    cout << ans << endl;

}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

vector<int> primes;
bool isPrime[N];
int cnt[N];

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

	int n;
	cin>>n;
	int arr[n];
	int gcd = 0;
	for(int i=0;i<n;i++) {
		cin>>arr[i];
		gcd = __gcd(gcd, arr[i]);
	}	

	for(int i=2;i<N;i++) {
		if(!isPrime[i]) {
			primes.pb(i);
			for(int j=i*i;j<N;j+=i)
				isPrime[j]=1;
		}
	}
	bool f= 1;
	for(int i=0;i<n;i++) {
		for(int k: primes) {
			if(k*k>arr[i])
				break;
			if(isPrime[k])
				break;
			if(arr[i]%k==0) {
				cnt[k]++;
				if(cnt[k]>1) {
					if(gcd ==1) {
						cout<<"setwise coprime";
					}
					else {
						cout<<"not coprime";
					}
					return 0;
				}
				while(arr[i]%k==0)
					arr[i]/=k;
			}
		}
		if(arr[i]>1) {
			cnt[arr[i]]++;
			if(cnt[arr[i]]>1) {
				if(gcd ==1) {
					cout<<"setwise coprime";
				}
				else {
					cout<<"not coprime";
				}
				return 0;
			}
		}
	}
	for(int i=2;i<N;i++) {
		if(cnt[i]>1) {
			f=0;
			break;
		}
	}
	if(gcd!=1) {
		cout<<"not coprime";
		return 0;
	}
	if(f) {
		cout<<"pairwise coprime";
	}
	else if(gcd ==1) {
		cout<<"setwise coprime";
	}
	else {
		cout<<"not coprime";
	}

	return 0;
}

Measured memory_bytes: 13408
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


ll dp[3010][3010];
ll dp2[3010][3010];

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    dp[1][1] = 1;
    dp2[1][1] = 1;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(s[i-2]=='<'){
                dp[i][j] += (dp2[i-1][j-1]);
                dp[i][j] %= mod;
            }else{
                dp[i][j] += (mod+dp2[i-1][i-1]-dp2[i-1][j-1])%mod;
                dp[i][j] %= mod;
            }
        }
        for(int j=1;j<=n;j++){
            //cerr << dp[i][j] << " " ;
            dp2[i][j] += dp[i][j]+dp2[i][j-1];
            dp2[i][j] %= mod;
        }
        //cerr << endl;
    }
    cout << dp2[n][n] << endl;
    return 0;
}

Measured memory_bytes: 141568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i, n) for(int i=0;i<(n);i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;

ll f(vector<P> list) {
  int n = list.size();
  rep(i, n) list[i].first = min(list[i].first, n);
  vector<vector<int> > ps(n+1);
  for (int i = 0; i < n; i++) {
    ps[list[i].first].push_back(list[i].second);
  }
  
  // 後ろから見ていく
  priority_queue<int> que;
  ll sum = 0;
  for (int i = n; i >= 1; i--) {
    for (int j : ps[i]) {
      que.push(j);
    }
    if (!que.empty()) {
      sum += que.top();
      que.pop();
    }
  }
  return sum;
}

void solve() {
  int N;
  cin >> N;
  
  vector<P> pl, pr;
  ll ans = 0;
  rep(i, N) {
    int k, l, r;
    cin >> k >> l >> r;
    int m = min(l, r);
    l -= m;
    r -= m;
    ans += m;
    if (l > 0) pl.emplace_back(k, l);
    else pr.emplace_back(N-k, r);
  }
  
  ans += f(pl);
  ans += f(pr);
  cout << ans << endl;
}

int main() {
  int T;
  cin >> T;
  rep(i, T) solve();
}

Measured memory_bytes: 10476
n = int(input())
a = list(map(int, input().split()))
s = 0
l = [0] * n
for i in range(1, n):
    l[i] = a[i] - l[i - 1]
# 2x+s=a[0]
x = (a[0] - l[-1]) // 2
ans = [0] * n
for i in range(n):
    if i % 2:
        ans[i] = l[i] - x
    else:
        ans[i] = x + l[i]
print(' '.join(map(lambda x: str(x*2), [ans[-1]] + ans[:-1])))

Measured memory_bytes: 24628
#include <bits/stdc++.h>
#define ll long long int
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
using namespace std;

int main( ) {
    ll N;
    cin>>N;
    ll count=1;
    vec A(N);
    rep(i,0,N) {
        cin>>A[i];
        if(A[i]==0) {
            cout<<"0"<<endl;
            return 0;
            }
        }
    sort(A);
    rep(i,0,N) {
        if(A[i]<=1000000000000000000/count) {
          count*=A[i];
        }
        else {
            cout<<"-1"<<endl;
            return 0;
        }
          
       
        }
        cout<<count<<endl;

    }

Measured memory_bytes: 3980