akhauriyash/Code-Regression huggingface dataset:
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var output = 0;
	for(var i = 1; i <= N; i++){
		var tmp = i.toString();
		if(tmp.length % 2 == 1){
			output++;
		}
	}
	myout(output);
}


Measured memory_bytes: 35320
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); in.nextLine();
		ArrayList<ArrayList<Integer>> al = new ArrayList<>();
		for( int i = 0; i < n; i++ ) {
			al.add(new ArrayList<Integer>());
			for( int j = 0; j < 26; j++ ) al.get(i).add(0);
		}
		for( int i = 0; i < n; i++) {
			String temp = in.nextLine();
			for( int j = 0; j < temp.length(); j++ ) {
				int ind = (int)temp.charAt(j)-'a';
				int curr = al.get(i).get(ind);
				al.get(i).set(ind,curr+1);
			}
		}
		int[] alph = new int[26];
		Arrays.fill(alph, Integer.MAX_VALUE);
		for( int i = 0; i < n; i++ ) {
			for( int j = 0; j < 26; j++ ) {
				alph[j] = Math.min(alph[j],al.get(i).get(j));
			}
		}

		StringBuilder sb = new StringBuilder();
		for( int i = 0; i < alph.length; i++ ) {
			for( int j = 0; j < alph[i]; j++ ) {
				sb.append((char)(i+'a'));
			}
		}

		System.out.println(sb.toString());
		//System.out.println(Arrays.toString(alph));

		// for( int i = 0; i < n; i++ ) {
		// 	for( int j = 0; j < 5; j++ ) {
		// 		System.out.print(al.get(i).get(j)+" ");
		// 	}
		// 	System.out.println();
		// }
	}	
}

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x) {
	bool f = 0;
	x = 0;
	char c = getchar();
	while(c != '-' && (c < '0' || c > '9')) c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	if(f) x = -x;
	return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y) {
	scf(x);
	return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z) {
	scf(x);
	scf(y);
	return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w) {
	scf(x);
	scf(y);
	scf(z);
	return scf(w);
}

inline char mygetchar() {
	char c = getchar();
	while(c == ' ' || c == '\n') c = getchar();
	return c;
}

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

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

#ifdef King_George
#define DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 2010;

const int maxm = maxn * maxn;

const int mod = 1e9 + 7;

int n, k;
int dp[maxn][maxn];
int fac[maxm], ifac[maxm];

int pow_mod(int x, int n) {
	int y = 1;
	while(n) {
		if(n & 1) {
			y = 1ll * y * x % mod;
		}
		x = 1ll * x * x % mod;
		n >>= 1;
	}
	return y;
}

void pre() {
	fac[0] = 1;
	for (int i = 1; i < maxm; ++i) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
	}
	ifac[maxm - 1] = pow_mod(fac[maxm - 1], mod - 2);
	for (int i = maxm - 1; i >= 1; --i) {
		ifac[i - 1] = 1ll * ifac[i] * i % mod;
	}
	return;
}

int C(int n, int m) {
	return (n < m || m < 0) ? 0 : 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main() {
	pre();
	scf(n, k);
	if(k == 1) {
		puts("1");
		return 0;
	}
	dp[0][0] = 1;
	int tmp;
	forn(i, 0, n) {
		forn(j, 0, n) {
			if(tmp = dp[i][j]) {
				if(j < i) {
					dp[i][j + 1] = (1ll * tmp * C((n - j) * (k - 1) + n - i - 1, k - 2) + dp[i][j + 1]) % mod;
				}
				(dp[i + 1][j] += tmp) %= mod;
			}
		}
	}
	printf("%d\n", 1ll * fac[n] * dp[n][n] % mod);
	return 0;
}

Measured memory_bytes: 47488
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  long long int N, lltmp;
  std::string strtmp;
  std::vector<std::pair<std::string, std::pair<long long int, long long int> > > res;

  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    std::cin >> strtmp >> lltmp;
    res.push_back(std::make_pair(strtmp, std::make_pair(-lltmp, i+1)));
  }

  std::sort(res.begin(), res.end());

  std::cerr << "Answer: " << std::endl;
  for(int i = 0; i < N; i++){
    std::cout << res[i].second.second << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    bool f=1;
    if((sum*2)%(n*(n+1))!=0)f=0;
    else{
        ll k=(sum*2)/(n*(n+1));
        vector<ll>b(0);
        rep(i,n-1){
            if(a[i+1]-a[i]-k<=0&&abs(a[i+1]-a[i]-k)%n==0)continue;
            f=0;
        }
        if(a[0]-a[n-1]-k>0||abs(a[0]-a[n-1]-k)%n!=0)f=0;
    }
    cout<<(f?"YES":"NO")<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<pair<int, int>> v(n);
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        v[i].first = a;
        v[i].second = i;
    }

    sort(v.rbegin(), v.rend());

    for(int i = 0; i < n; i++) {
        if(i != v[0].second) {
            cout << v[0].first << endl;
        } else {
            cout << v[1].first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main()
{
    char in;
    scanf("%c",&in);

    if( in=='a' || in=='e' || in=='i' || in=='o' || in=='u' || in=='A' || in=='E' || in=='I' || in=='O' || in=='U')
        printf("vowel\n");

    else printf("consonant\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#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()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL n, m;
    cin >> n >> m;
    vector<LL> x(n), y(m);
    REP(i, n) cin >> x[i];
    REP(i, m) cin >> y[i];
    
    LL xsum = 0, ysum = 0;
    REP(i, n) xsum += ((i * x[i]) - ((n-i-1) * x[i])), xsum %= MOD;
    REP(i, m) ysum += ((i * y[i]) - ((m-i-1) * y[i])), ysum %= MOD;
    cout << xsum * ysum % MOD << endl;
}


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

using pii = pair<int, int>;
using ll = long long;

constexpr ll M = 1e9 + 7;

ll inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}

ll fact(int n, bool inv_) {
    static vector<ll> v1 = {1}, v2 = {1};
    if(n >= (int)v1.size()) {
        int const from = v1.size(), to = n + 1024;
        v1.reserve(to);
        v2.reserve(to);
        for(int i = from; i < to; ++i) {
            v1.push_back(v1.back() * i % M);
            v2.push_back(v2.back() * inv(i, M) % M);
        }
    }
    return inv_ ? v2[n] : v1[n];
}

ll comb(int n, int r) {
    if(r < 0 || r > n) {
        return 1;
    }
    ll res = fact(n, false) * fact(r, true) % M;
    res = res * fact(n - r, true) % M;
    return res;
}

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<pii> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end(), [](auto const& p1, auto const& p2) {
        return p1.first + p1.second < p2.first + p2.second;
    });

    vector<ll> dp(n);
    for(int i = 0; i < n; ++i) {
        int xi = v[i].second;
        int yi = v[i].first;
        dp[i] = comb(xi + yi - 2, yi - 1);
        for(int j = 0; j < i; ++j) {
            int xj = v[j].second;
            int yj = v[j].first;
            if(xi >= xj && yi >= yj) {
                dp[i] = (dp[i] - dp[j] * comb(xi - xj + yi - yj, xi - xj)) % M;
                dp[i] = (dp[i] + M) % M;
            }
        }
    }
    for(int i = 0; i < n; ++i) {
        int x = v[i].second, y = v[i].first;
        dp[i] = (dp[i] * comb(w - x + h - y, w - x)) % M;
    }
    ll res = comb(h + w - 2, h - 1);
    for(int i = 0; i < n; ++i) {
        res = (res - dp[i] + M) % M;
    }

    cout << res << endl;
}


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<ll> v(m+1);
  rep(i,m){
    cin>>v.at(i);
  }
  ll INF = 1e9+7;
  vector<ll> h(n+1,0);
  h.at(0) = 1;
  int j = 0;
  if (v.at(0) != 1){
    h.at(1) = 1;
  }
  else{
    j++;
  }
  for(ll i = 2;i<n+1;i++){
    h.at(i) = h.at(i-1) + h.at(i-2);
    h.at(i) = h.at(i) % INF;
    if (i == v.at(j)){
      h.at(i) = 0;
      j++;
    }
  }
  cout << h.at(n) % INF << endl;
}

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

using ll = long long;

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

  ll res = 0;
  int N;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    if (i % 3 != 0 && i % 5 != 0) {
      res += i;
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}


//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

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








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

//諸機能
#pragma region MACRO 
#define putans(x) cerr << "answer: " ; cout << (x) << endl
#define dputans(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define substr(s,i,l) string((s), (i), (l))
#define tos(x) (to_string((x)))
#ifdef _DEBUG //ファイルからテストデータを読み込む
	std::ifstream ifs("data.txt");
	#define input ifs >>
#else 
	#define input cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll; 
typedef pair<int,int> pii; typedef pair<string,string> pss;typedef pair<int,string>pis;typedef pair<string,int>psi;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9 + 7)
#define INF (1e9)
#pragma endregion


int main()
{
	//int n, l; input n >> l;
	//vs s;
	//rep(i, n) {

	//}
	int a[3]; input a[0] >> a[1] >> a[2];
	int c5 = 0, c7 = 0;
	rep(i, 3) {
		if (a[i] == 5) c5++;
		if (a[i] == 7) c7++;
	}
	putans((( c5 == 2 && c7 == 1 ) ? "YES" : "NO"));
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int D=sc.nextInt(), N=sc.nextInt();
		
		int[] T=new int[D];
		int[] A=new int[N];
		int[] B=new int[N];
		int[] C=new int[N];
		int[] curr=new int[N];
		int[] next=new int[N];
		
		for(int i=0; i<D; i++)
			T[i]=sc.nextInt();
		
		for(int i=0; i<N; i++)
		{
			A[i]=sc.nextInt();
			B[i]=sc.nextInt();
			C[i]=sc.nextInt();
		}
		
		for(int i=0; i<D-1; i++)
		{
			for(int j=0; j<N; j++)
			{
				if(A[j]<=T[i] && T[i]<=B[j])
				for(int k=0; k<N; k++)
				{
					if(A[k]<=T[i+1] && T[i+1]<=B[k])
					{
						int currNext=0;
						currNext += curr[j];
						currNext += Math.abs(C[j]-C[k]);
						if(currNext > next[k])
							next[k] = currNext;
					}
				}
			}
			for(int j=0; j<N; j++)
			{
				curr[j] = next[j];
				next[j] = 0;
			}
		}
		
		int max=curr[0];
		for(int i=1; i<N; i++)
			max = Math.max(max, curr[i]);
		System.out.println(max);
	}
}

Measured memory_bytes: 21648
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;

int main() {
	string str;
	int A[26] = {};
	while (getline(cin, str)) {
		int k = str.size();
		for (int i = 0; i < k; i++) {
			if (str[i] >= 'a' && str[i] <= 'z') {
				A[str[i] - 'a']++;
			}
			else if (str[i] >= 'A' && str[i] <= 'Z') {
				A[str[i] - 'A']++;
			}
		}
	}
	string str2;
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", i + 'a', A[i]);
	}
	return 0;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll 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() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll mn = a[0], mx = a[n - 1];
  vector<P> ans(n - 1);
  rep2(i, 1, n - 1) {
    ll x;
    if(a[i] >= 0) {
      x = mn;
      mn -= a[i];
    } else {
      x = mx;
      mx -= a[i];
    }
    ans[i - 1] = {x, a[i]};
  }
  ans[n - 2] = {mx, mn};
  cout << mx - mn << '\n';
  rep(i, n - 1) cout << ans[i].first << ' ' << ans[i].second << '\n';
}

Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int num[5];
    while(cin>>num[0],num[0]){
        bool hand[4]={};
        hand[num[0]]=1;
        for(int i=1;i<5;i++){
            cin>>num[i];
            hand[num[i]]=1;
        }
        if(hand[1]&&hand[2]&&hand[3]||!hand[1]&&!hand[2]||!hand[2]&&!hand[3]||!hand[3]&&!hand[1])
            for(int i=0;i<5;i++)cout<<"3\n";
        else {
            int win;
            if(!hand[3])win=1;
            else if(!hand[1])win=2;
            else win=3;
            for(int i=0;i<5;i++){
                if(win==num[i])cout<<"1\n";
                else cout<<"2\n";
            }
        }
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define str(n) to_string(n)
#define int(w) stoi(w)
#define len(l) l.size()
#define append(l,i) l.push_back(i)
int main() {
    string w;
    cin>>w;
    int ans=0;
    rep(i,w.length()-1){
        if (w.at(i)!=w.at(i+1)){
            ans+=1;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  long A[200000];
 
  cin >> N;
  
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  
  sort(A, A+N, greater<long>());
  
  long long Total = 0;
  
  for (int i = 1; i < N; i++)
  {
    Total += A[(i/2)];
  }
  
  cout << Total << endl;
}

Measured memory_bytes: 5144
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if(a == 1)
			a += 13;
		int b = sc.nextInt();
		if(b == 1)
			b += 13;
		String result;
		if(a > b)
			result = "Alice";
		else if(a < b)
			result = "Bob";
		else
			result = "Draw";
		System.out.println(result);
	}
}

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

int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a >= b && a >= c){
		cout << a * 10 + b + c << endl;
	}else if(b >= a && b >= c){
		cout << b * 10 + a + c << endl;
	}else{
		cout << c * 10 + a + b << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

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

vl A(N);
rep(i,N) cin >> A[i];

ll M = A[0] + K - A[N-1];
rep(i,N-1) {
    chmax(M, A[i+1] - A[i]);
}
cout << K - M << endl;

return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
typedef long long ll;
typedef vector<string> vec;
typedef vector<vec> mat;
typedef pair<int, int> P;

int main()
{
    int N;
    cin >> N;
    vec s(N);
    rep(i, N) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

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

    int cnt = 0;
    ll ans = 0;

    rep(i, N-1) {
        if (s[i+1] == s[i]) {
            cnt++;
            ans += cnt;
        } else {
            cnt = 0;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

int z[N];

signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n;
   cin >> n;
   string s, s1, ss;
   cin >> s >> s1;
   ss = s1 + '$' + s;
   int l = 0, r = 0;
   for (int i = 1; i < ss.size(); i++) {
      if (i <= r) z[i] = min(r - i + 1, z[i - l]);
      while (i + z[i] < ss.size() && ss[z[i]] == ss[z[i] + i]) z[i]++;

      if (i + z[i] - 1 > r) {
         r = i + z[i] - 1, l = i;
      }
   }
   int maxx = 0, ans = (int)s.size() + (int)s1.size(); 
   for (int i = s.size(); i < ss.size(); i++) {
      if (z[i] + i == ss.size()) {
         maxx = max(z[i], maxx);
         break;
      }
   }
   cout << ans - maxx;
}

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

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

#define x first
#define y second
#define pb push_back

using namespace std;

typedef long long ll;

const int MAXN = 100100;
const int LOGMAXN = 18;

int n, q, L, x[MAXN];
int l[MAXN][LOGMAXN];
int r[MAXN][LOGMAXN];

int Get(int dad[MAXN][LOGMAXN], int a, int len) {
  for (int i = 16; i >= 0; --i) {
    if (len - (1 << i) < 0) continue;
    len -= (1 << i);
    a = dad[a][i];
  }
  return a;
}

int main(void) {
  ios_base::sync_with_stdio(false);
  
  cin >> n;
  REP(i, n) cin >> x[i];
  cin >> L;

  int lt = 0, rt = 0;
  for (; rt < n; ++rt) {
    while (x[lt] + L < x[rt]) ++lt;
    l[rt][0] = lt;
  }
  
  lt = n - 1, rt = n - 1;
  for (; rt >= 0; --rt) {
    while (x[lt] - L > x[rt]) --lt;
    r[rt][0] = lt;
  }

  FOR(j, 1, LOGMAXN) {
    REP(i, n) {
      l[i][j] = l[l[i][j-1]][j-1];
      r[i][j] = r[r[i][j-1]][j-1];
    }
  }

  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b; --a; --b;
    int lo = 1, hi = n;
    while (lo < hi) {
      int mid = (lo + hi) / 2;
      if (a > b) {
        if (Get(l, a, mid) <= b) hi = mid;
        else lo = mid + 1;
      } else {
        if (Get(r, a, mid) >= b) hi = mid;
        else lo = mid + 1;
      }
    }
    cout << lo << endl;
  }

  return 0;
}

Measured memory_bytes: 15360
#include<stdio.h>

int main(void){
    int h,n,i,a;
    scanf("%d%d",&h,&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        h -= a;
    }
    if(h<=0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
N = int(input())
ls = [0 for i in range(10**5)]
now = 0
A = list(map(int,input().split()))
for i in range(N):
    now += A[i]
    ls[A[i]-1] += 1
q = int(input())
for i in range(q):
    a,b = map(int,input().split())
    now += (b-a)*ls[a-1]
    print(now)
    ls[b-1] += ls[a-1]
    ls[a-1] = 0


Measured memory_bytes: 89992
n,m=map(int,input().split())
e=[[0 for _ in range(n)] for i in range(n)]
for i in range(m):
    a,s=map(int,input().split())
    e[a-1][s-1]=1;e[s-1][a-1]=1
ans=0
from itertools import permutations as pe
for i in pe(range(1,n),r=None):
    #rは長さ、Noneでiteraterの長さ
    pre=0
    for a in i:
        if e[pre][a]!=1:break
        pre=a
    else:ans+=1
print(ans)

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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx-sx, y = ty-sy;
    rep(i,x) cout << 'R';
    rep(i,y) cout << 'U';
    rep(i,x) cout << 'L';
    rep(i,y) cout << 'D';
    cout << 'D';
    rep(i,x+1) cout << 'R';
    rep(i,y+1) cout << 'U';
    cout << 'L';
    cout << 'U';
    rep(i,x+1) cout << 'L';
    rep(i,y+1) cout << 'D';
    cout << 'R';
    return 0;
}

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

const int N = 3e5+1 , M = 5e3+5;

int n , t , b[N] , sol;

int main()
{
    multiset<int> mu;
    multiset<int>::iterator it;
    scanf("%d",&n);
    for(int i = 1;i<=n;i++)
    {
        scanf("%d",&t);
        it = mu.lower_bound(t);
        if(it==mu.begin())
            mu.insert(t);
        else
        {
            it--;
            mu.erase( it );
            mu.insert( t );
        }
    }
    printf("%d",mu.size());
    return 0;
}


Measured memory_bytes: 4992
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
//int n;
//char c;
//string s;
//short x[1000050],y[1000050];
//short _abs(short a,short b){
//	if(a>b)return a-b;
//	else return b-a; 
//}
//int main(){
//	ios_base::sync_with_stdio(false);
//	cin.tie(0);
////	freopen(".in","r",stdin);
////	freopen(".out","w",stdout);
//	cin>>n>>s;
//	if(n==1){
//		cout<<s;
//		return 0;
//	}
//	if(n==2){
//		cout<<(int)(max(s[0],s[1])-min(s[0],s[1]));
//		return 0;
//	}
//	for(int i=1;i<=n;i++){
//		c=s[i-1];
//		y[i]=c-'0';
////		cout<<y[i]<<' ';
//	}
////	cout<<'\n';
//	for(int i=2;i<=2;i++){
//		int flag=0,num=0,pos=0;
//		ll sum=0;
//		for(int j=1;j<=n+2-i;j++)x[j]=y[j];
//		for(int j=1;j<=n+1-i;j++){
//			y[j]=_abs(x[j],x[j+1]);
//			if(y[j]!=y[j]||j==1)sum+=y[j];
////			if(y[j])flag++,num=y[j],pos=j;
//		}
////		for(int j=1;j<=n+1-i;j++)cout<<y[j]<<' ';
////		cout<<'\n';
////		if(flag==0){
////			cout<<num;
////			return 0;
////		}
////		if(flag==1){
////			if(pos==1||pos==n+1-i){
////				cout<<num;
////				return 0;
////			}
//////			if(n+1-i<=pos&&pos==n+1-i)
////			if(y[pos-1]==0&&y[pos+1]==0){
////				cout<<0;
////				return 0;
////			}
////		}
//		cout<<(sum%2);
//		return 0;
//	}
//	cout<<y[1];
////	for(int i=1;i<=n;i++){
////		for(int j=1;j<=n;j++){
////			cout<<x[i][j]<<'\t'; 
////		}
////		cout<<'\n';
////	}
//	return 0;
//}
const int N=1e6+5;
int n,i,j,a[N];
char c[N];
bool ck1(){
	int tot=0;
	for(i=1;i<=n;++i)tot^=a[i]&1&(((n-1)&(i-1))==i-1);
	return tot==1;
}
bool ck2(){
	int tot=0;
	for(i=1;i<=n;++i)if(a[i]&1)return 0;
	for(i=1;i<=n;++i)tot^=(a[i]&2?1:0)&(((n-1)&(i-1))==i-1);
	return tot==1;
}
int main(){
	scanf("%d%s",&n,c+1);for(i=1;i<n;++i)a[i]=abs(c[i]-c[i+1]);--n;
	printf("%d\n",ck1()?1:ck2()?2:0);
}


Measured memory_bytes: 5120
NLinput = input()
NLinput = [int(x) for x in NLinput.split()]

N = NLinput[0]
L = NLinput[1]
input_D = input()
D_list = set([int(x) for x in input_D.split()])

bill = N
flag = True

while flag:
    temp = set([int(x) for x in list(str(bill))])
    if len(list(temp&D_list))==0:
        flag = False
    else:
        bill += 1
print(bill)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    char word;

    while(1){
        scanf("%c",&word);

        if('a'<=word && word<='z'){
            printf("%c",word-32);
            //-32
        }else if('A'<=word && word<='Z'){
            printf("%c",word+32);
            //+32
        }else if(word=='\n'){
            printf("\n");
            break;
        }else{
            printf("%c",word);
        }
    }
  
    return 0;
}


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

vector<pair<long long, vector<long long>>> outcome;

void go(vector<vector<long long>> information, long long x, long long m, long long n, long long index, vector<long long> information_acc, long long price_acc){
    if (index == n){
        auto success_flag = true;
        for (long long val : information_acc){
            if (val < x){
                success_flag = false;
                break;
            }
        }
        if (success_flag){
            outcome.push_back(make_pair(price_acc, information_acc));
        }
        return;
    } else {
        go(information, x, m, n, index+1, information_acc, price_acc);
        for (long long i=0;i<m;i++){
            information_acc[i] += information[index][i+1];
        }
        go(information, x, m, n, index+1, information_acc, price_acc + information[index][0]);
    }
}

int main(){
    long long n, m, x;
    cin>>n>>m>>x;
    vector<vector<long long>> information(n);
    for (long long i=0;i<n;i++){
        vector<long long> book(m+1);
        for (long long j=0;j<m+1;j++){
            cin >> book[j];
        }
        information[i] = book;
    }
    vector<long long> information_acc(m);for(long long i=0;i<m;i++){information_acc[i]=0;};

    go(information, x, m, n, 0, information_acc, 0);
    if (outcome.size() == 0){
        cout << -1 << endl;
    } else {
        sort(outcome.begin(), outcome.end());
        cout << outcome[0].first << endl;
    }
    

    return 0;
}

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

using namespace std;
#define rep(i, s, n) for(int i = s;i<n;i++)

int main(void) {
    vector<int> p_list;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        p_list.push_back(temp);
    }
    sort(p_list.begin(), p_list.end());

    int sum = 0;
    for (auto s : p_list) {
        sum += s;
    }
    sum -= p_list.back();
    sum += (p_list.back() / 2);
    cout << sum << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a = read().rstrip().decode()
al = [chr(ord('a') + i) for i in range(26)]
ans = len(a) * (len(a) - 1) // 2 + 1
for check in al:
    cnt = a.count(check)
    ans -= cnt * (cnt - 1) // 2
print(ans)


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

int main() {
  int a,b;
  cin>>a>>b;
  vector<int> A(2*b);
  for(int i=1;i<=a;i++){
    int c=0;
    for(int j=0;j<2*b;j++){
      cin>>A[j];
      if(i==A[j])
        c++;
      }
    cout<<c<<endl;
    }
  }

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
      for(int i=0;i<b;i++) cout<<to_string(a);
    }else {
      for(int i=0;i<a;i++) cout<<to_string(b);
    }


}



Measured memory_bytes: 256
N = int(input())
rlst = 'No'
for i in range(1, 10):
    if N%i==0:
        min_ = int(N/i)
        if min_ > 9:
            continue
        for j in range(min_, 10):
            if min_%j == 0:
                rlst = 'Yes'
                break;
print(rlst)

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

using namespace std;

long long n, m, k;

const long long MOD = 998244353;

long long modmult(long long a, long long b){
  return (a * b) % MOD;
}

long long modpls(long long a, long long b){
  return (a + b) % MOD;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

long long fact_tbl[2*100000+1] = {0};

void factgen(){
  fact_tbl[1] = fact_tbl[0] = 1;
  for(long long i = 2; i <= 2*100000; i++){
    fact_tbl[(int)i] = modmult(i, fact_tbl[(int)i - 1]);
    //if(i < 19){
    //  cout << fact_tbl[i] << " " << flush;
    //}
    
  }
  //cout << endl;
  return;
}

long long fastpow(long long a, long long n){
  long long ans = 1;
  while(n > 0){
    if(n & 1){
      ans = modmult(ans, a);
    }
    a *= a;
    a %= MOD;
    n = n >> 1;
  }
  return ans;
}

long long comp(long long a, long long b){
  return modmult(modmult(fact_tbl[(int)a], modinv(fact_tbl[(int)(a - b)], MOD)), modinv(fact_tbl[(int)b], MOD));
}

int main(){
  cin >> n >> m >> k;
  cin.ignore();
  factgen();

  //cout << "mdtest " << modmult(998224352, 2) << endl;
  //cout << "mdtest " << modinv(2, MOD) * 2 << endl;

  long long ans = 0;
  long long sel; // n-1このしきりへの印の付け方
  long long grp;
  long long grp_p;
  while (k >= 0){
    // sel = {N-1}_C_k
    sel = comp(n-1, k);
    //cout << "sel = " << sel << endl;
    grp = n - k - 1;
    grp_p =modmult(m, fastpow(m-1, grp));
    ans += modmult(sel, grp_p);
    ans %= MOD;
    --k;
  }
  std::printf("%lld\n", ans);
  return 0;
}
        


Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int n, m;
    cin >> n >> m;
    int sum = 0;
    rep(i, m) {
        int a;
        cin >> a;
        sum += a;
    }

    int ans = n - sum;
    if (ans<0) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] L = new int[N];
		Map<Integer, Integer> R = new HashMap<>();
		long ans = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			L[i] = A[i] + i;
			if(!R.containsKey(i-A[i]))
				R.put(i-A[i], 1);
			else
				R.put(i-A[i], R.get(i-A[i])+1);
		}
		for(int i : L)
			if(R.containsKey(i))
				ans += R.get(i);
		System.out.println(ans);
	}

}


Measured memory_bytes: 70768
i=input()

a=int(i[0])
b=int(i[1])
c=int(i[2])
d=int(i[3])

if a+b+c+d==7:
    x="+"
    y="+"
    z="+"
elif a+b+c-d==7:
    x="+"
    y="+"
    z="-"
elif a+b-c+d==7:
    x="+"
    y="-"
    z="+"    
elif a-b+c+d==7:
    x="-"
    y="+"
    z="+"
elif a-b-c+d==7:
    x="-"
    y="-"
    z="+"
elif a-b+c-d==7:
    x="-"
    y="+"
    z="-"
elif a+b-c-d==7:
    x="+"
    y="-"
    z="-"
elif a-b-c-d==7:
    x="-"
    y="-"
    z="-"
    
    
print(a,end="")
print(x,end="")
print(b,end="")
print(y,end="")
print(c,end="")
print(z,end="")
print(d,end="")
print("=7")

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
using namespace std;
char a[100];
int main(void)
{
     int i,j,k,n,m,l;
     scanf("%s",a);
     l=strlen(a);
     k=0;
     if(strcmp(a,"AKIHBR")==0)
          k=1;
     if(strcmp(a,"KIHABR")==0)
          k=1;
     if(strcmp(a,"KIHBAR")==0)
          k=1;
     if(strcmp(a,"KIHBRA")==0)
          k=1;
     if(strcmp(a,"KIHBR")==0)
          k=1;
     if(strcmp(a,"AKIHABR")==0)
          k=1;
     if(strcmp(a,"AKIHBAR")==0)
          k=1;
     if(strcmp(a,"AKIHBRA")==0)
          k=1;
     if(strcmp(a,"KIHABAR")==0)
          k=1;
     if(strcmp(a,"KIHABRA")==0)
          k=1;
     if(strcmp(a,"KIHBARA")==0)
          k=1;
     if(strcmp(a,"AKIHABAR")==0)
          k=1;
     if(strcmp(a,"AKIHABRA")==0)
          k=1;
     if(strcmp(a,"AKIHBARA")==0)
          k=1;
     if(strcmp(a,"KIHABARA")==0)
          k=1;
     if(strcmp(a,"AKIHABARA")==0)
          k=1;
     if(k==1)
          printf("YES\n");
     else
          printf("NO\n");
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define llu unsigned long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra
ll mod=1e9+7;
// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }

int main(){
    // IOS;  
    int n;
    cin>>n;
    double a[n+1];
    double dp[n+2]={0};
    dp[0]=1;
    for(int i=0;i<n;i++){
      cin>>a[i];
      for(int j=i+1;j>=0;j--){
        dp[j]=(j==0?0:dp[j-1]*a[i])+dp[j]*(1-a[i]);
      }
    }
    double ans=0;
    for(int i=n;i>=ceil((double)n/2);i--){
      ans=ans+dp[i];
    }
    printf("%.10lf\n",ans);
 }
 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
int N,M,Q;



int main() {
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	cin >> Q;
	rep(i, Q) {
		int b, m, e;
		cin >> b >> m >> e;
		rotate(A.begin() + b, A.begin() + m, A.begin() + e);
	}
	rep(i, N - 1) {
		cout << A[i] << " ";
	}
	cout << A[N - 1]<<endl;
	return 0;
}





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

bool isGuu(string str){
    int l=str.length();
    if(l%2!=0) return false;
    return str.substr(0, l/2) == str.substr(l/2, l);

}

int main(){
    string str;
    cin >> str;
    while(str.length() != 0){
        auto end=str.rbegin();
        str.erase(str.end()-1, str.end());
        if(isGuu(str)) break;
    }
    cout << str.length() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    double x1,y1,x2,y2,z,x,y;
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    x=(x2-x1)*(x2-x1);
    y=(y2-y1)*(y2-y1);
    z=x+y;
    printf("%.8lf\n",sqrt(z));
    return 0;
}



Measured memory_bytes: 2076
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>


using namespace std;

void Solution()
{
    int n;
    
    
    while(cin>>n)
    {
        int count = 0;
        
        if (n == 0)
        {
            break;
        }
        
        //algorithm
        for (int i = 5; i <= n; i *= 5)  // 5's multiples can lead to "0"
        {
            count += n / i; // this method is the same as "while(n != 0) count += n/5; n /= 5;"
        }
        
        cout<<count<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var s string

func main() {
	sc.Split(bufio.ScanWords)

	s = nextStr()
	n := len(s)
	greater, less := make([]int, n+1), make([]int, n+1)
	g, l := 0, 0
	sum := 0
	for i := 1; i <= n; i++ {

		if string(s[i-1]) == "<" {
			g++
		} else if string(s[i-1]) == ">" {
			g = 0
		}
		if string(s[n-i]) == "<" {
			l = 0
		} else if string(s[n-i]) == ">" {
			l++
		}
		greater[i] = g
		less[n-i] = l
	}

	for i := 0; i <= n; i++ {
		sum += maxInt(greater[i], less[i])
	}

	fmt.Println(sum)

}


Measured memory_bytes: 11628
N, K = map(int, input().split())

A = list(map(int, input().split()))
past = [0]*min(K, 2*10**5)
ps = set()
now = 1
step = 0
for i in range(K):
    past[i] = now
    ps.add(now)
    now = A[now-1]
    if now in ps:
        step += 1
        break

if step > 0:
    id = past.index(now)
    step = i+1 - id
    p = (K-id) % step
    now = past[id+p]

print(now)


Measured memory_bytes: 33100
#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <math.h>

struct Edge{
  int to;
  int id;
};
std::vector<std::vector<Edge> > g;
std::vector<int> ans;

void dfs(int i, int p=-1, int c=0){
/*   printf("dfs(%d, %d, %d)\n",i,p,c); */
  int k=1;
  for (int j=0; j<g[i].size(); j++){
/*     printf("g[%d][%d].to=%d\n",i,j,g[i][j].to);
    printf("k=%d\n",k); */
    if (g[i][j].to==p){
      continue;
    }
    if (k==c){
      k++;
    }
    ans[g[i][j].id]=k;
/*     printf("color ans[%d]=%d\n",g[i][j].id, k);
    printf("dfs(%d, %d, %d) is called\n",g[i][j].to, i, k); */
    dfs(g[i][j].to, i, k);
    k++;
  }
  return;
}
int main(){
  int N;
  int a, b;
  scanf("%d",&N);
  ans.resize(N);
  g.resize(N);
  for (int i=0; i<N-1; i++){
    scanf("%d %d", &a, &b);
    a--;
    b--;
    g[a].push_back((Edge){b,i});
    g[b].push_back((Edge){a,i});
  }
  dfs(0);
/*   printf("=======\n"); */
  int retval = 0;
  for (int i=0; i<N; i++){
    retval = fmax(retval, g[i].size());
  }
  printf("%d\n",retval);
  for (int i=0; i<N-1; i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}

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

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	if (2 * C >= A + B) cout << X * A + Y * B;
	else cout << 2 * C * min(X, Y) + min(2 * C, A) * (X - min(X, Y)) + min(2 * C, B) * (Y - min(X, Y));
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、2C<A+Bでない限り普通に買った方が良い
次にそうでない時を考える
そうでないなら、まずmin(A, B)だけ2Cを買った方が良い
よって2C * min(X, Y) + 残りの分になる
更に残りの分について、2Cとそのピザどっちが安いか考えて買えばいい
*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    while(b != 0){
        ll tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

ll lcm(ll a, ll b){
    ll e = gcd(a, b);
    return (a/e)*b;
}

int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll E = lcm(C, D);
    //cout << E << endl;
    ll a = (A-1) - ((A-1)/C + (A-1)/D - (A-1)/E);
    ll b = B - (B/C + B/D - B/E);
    cout << b-a << endl;
}

Measured memory_bytes: 256