akhauriyash/Code-Regression huggingface dataset:
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

int main() {
  int n, ans = 0, k;
  scanf("%d %d", &n, &k);
  while (n--) {
    int x;
    scanf("%d", &x);
    if (x >= k) ans++;
  }
  printf("%d\n", ans);
  return 0;
}

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

typedef long long ll;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n;
    double m1 = n;
    m = sqrt(m1) + 1;
    cout << n << ": ";
    ll tmp = 2;
    vector<ll> ans;
    while(n != 1){
        if(n%tmp == 0){
            n /= tmp;
            ans.push_back(tmp);
            m1 = n;
            m = sqrt(m1) + 1;
        }else{
            if(tmp >= m){
                ans.push_back(n);
                break;
            }
            ++tmp;
        }
    }
    for(i = 0;i < ans.size()-1;++i){
        cout << ans.at(i) << " ";
    }
    cout << ans.at(i) << endl;
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,n,ans=0;
    cin >> a >> b >> c >> n;
    for (int i = 0; i * a <= n; ++i)
        for (int j = 0; j * b + i * a <= n; ++j) {
            int w = n - i * a - j * b;
            ans += w % c == 0;
        }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch XORWorld | diff XORWorld.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address XORWorld.cpp && ./a.out

/*
 
 3/16/2019
 
 11:25-11:54 AC
 
 n^(n+1) = 1 for even `n`
 <=> XOR{x : x=1,..,n} = { n(n%4==0), 1(n%4==1), n^1(n%4==2), 0(n%4==3) }
 
 */

LL A,B;

LL f(LL X) {
  if(X<0) return 0;
  LL rem=X%4;
  if(rem==0) return X;
  if(rem==1) return 1;
  if(rem==2) return X^1;
  return 0;
}

LL f_org(LL X) {
  if(X<0) return 0;
  LL res=0;
  REP(i,45) {
    LL cy=1LL<<(i+1);
    LL a=(X+1)/cy,b=(X+1)%cy;
    LL pow=(1LL<<i);
    LL p=pow*a+max(0LL,b-pow);
    p%=2;
//    dump(i,a,b,p);
    if(p==1LL) res|=(1LL<<i);
  }
  return res;
}
void solve() {
  LL res=f(A-1)^f(B);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define xfor(i, a, b) for (int i = a; i < b; i++)
#define ifor(i, a, b) for (int i = a; i <= b; i++)
#define rxfor(i, b, a) for (int i = b; i > a; i--)
#define rifor(i, b, a) for (int i = b; i >= a; i--)
#define foreach(v, c) for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;

long long r, g, b, bad;
int main()
{
    int n;
    string S;
    cin >> n >> S;
    for (int i = 0; i < n; i++) {
        S[i] == 'R' ? r++ : S[i] == 'G' ? g++ : b++;
        for (int j = i + 1, k = i + 2; k < n; j += 1, k += 2) {
            if ((S[i] ^ S[j] ^ S[k]) == ('R' ^ 'G' ^ 'B'))
                bad++;
        }
    }
    cout << r * g * b - bad << endl;
}


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

long long gcd(long long a, long long b)
{
	while (b != 0) {
		long long temp = a;
		a = b;
		b = temp % b;
	}
	return a;
}

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

int main(void)
{
	long long n;

	std::cin >> n;

	std::vector<long long> v(n);

	for (size_t i = 0; i < v.size(); i++) {
		std::cin >> v[i];
	}

	if (n == 1) {
		std::cout << v[0] << std::endl;
		return 0;
	}

	long long ans = lcm(v[0], v[1]);

	for (size_t i = 2; i < v.size(); i++) {
		ans = lcm(ans, v[i]);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	a := make([]int, 3*3)
	for i := 0; i < 3*3; i++ {
		a[i] = nextInt()
	}
	// 0 1 2
	// 3 4 5
	// 6 7 8

	n := nextInt()
	b := make([]int, n)

	//fmt.Println(a, n, b)
	for i := 0; i < n; i++ {
		b[i] = nextInt()

		for j, aa := range a {
			if b[i] == aa {
				a[j] = 0
			}
		}

	}

	// 横
	if a[0] == 0 && a[1] == 0 && a[2] == 0 {
		fmt.Println("Yes")
		return
	}
	if a[3] == 0 && a[4] == 0 && a[5] == 0 {
		fmt.Println("Yes")
		return
	}
	if a[6] == 0 && a[7] == 0 && a[8] == 0 {
		fmt.Println("Yes")
		return
	}

	// 縦
	if a[0] == 0 && a[3] == 0 && a[6] == 0 {
		fmt.Println("Yes")
		return
	}
	if a[1] == 0 && a[4] == 0 && a[7] == 0 {
		fmt.Println("Yes")
		return
	}
	if a[2] == 0 && a[5] == 0 && a[8] == 0 {
		fmt.Println("Yes")
		return
	}
	// 斜め
	if a[0] == 0 && a[4] == 0 && a[8] == 0 {
		fmt.Println("Yes")
		return
	}
	if a[2] == 0 && a[4] == 0 && a[6] == 0 {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}

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


Measured memory_bytes: 640
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < pll > vec;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n)
    {
		vec.clear();
		for(ll i = 0; i < n; i++)
		{
			slld(input);

			vec.push_back({input,2});
		}

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

		vec[0].second = 1;

		ll sum = 0;

		for(ll i = 1, j = 0; i < n; i++)
		{
			sum += vec[j].first;

			vec[j].second--;

			if(vec[j].second == 0) j++;
		}

		cout << sum << endl;
    }


}





Measured memory_bytes: 7516
#include<iostream>
using namespace std;
int N;
long A[3<<17];
long ans,mod=1e9+7;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	long ans=0;
	for(int i=0;i<60;i++)
	{
		long cnt=0;
		for(int j=0;j<N;j++)cnt+=A[j]>>i&1;
		long tmp=cnt*(N-cnt)%mod;
		for(int j=0;j<i;j++)tmp=tmp*2%mod;
		ans+=tmp;
	}
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 2560
j,a['   '],z=1e6;main(i){for(;++i<z||~scanf(j="%d\n",a)&&printf(j,a[*a]);a[i]=*a+=!a[i])for(j=i<998?i*i:z;!a[i]?a[j]=j<z:0;j+=i);}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int main(){
  int X,N;
  scanf("%d",&X);
  scanf("%d",&N);
  int p[100];
  for (int i=0; i<N; i++){
      scanf("%d", p+i);
  }
  int l[100][2];
  for (int i=0; i<100; i++){
      l[i][0] = 0;
      l[i][1] = 0;
  }
  for (int i=0; i<N; i++){
      if (p[i] == X){
        l[0][0] = 1;
        l[0][1] = 1;
      }else if (p[i] < X){
          l[abs(p[i] - X)][0] = 1;
      }else{
          l[abs(p[i] - X)][1] = 1;
      }
  }
  for (int i=0; i<100; i++){
    if (l[i][0] == 0){
      printf("%d",X-i);
      return 0;
    }
    else if (l[i][1] == 0){
      printf("%d",X+i);
      return 0;
    }
  }
  return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<string> map(h);
    for (int i = 0; i<h; i++){
        cin >> map.at(i);
    }

    vector<bool> row(h, false);
    vector<bool> column(w, false);

    for (int i = 0; i<h; i++){
        for (int j = 0; j<w; j++){
            if (map.at(i).at(j) == '#'){
                row.at(i) = true;
                break;
            }
        }
    }

    for (int i = 0; i<w; i++){
        for (int j = 0; j<h; j++){
            if (map.at(j).at(i) == '#'){
                column.at(i) = true;
                break;
            }
        }
    }

    for (int i = 0; i<h; i++){
        if (row.at(i)){
            for (int j = 0; j<w; j++){
                if (column.at(j)){
                    cout << map.at(i).at(j);
                }
            }
            cout << endl;
        }
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

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

   int max = 0;
   int ans = 0;
   for (int i = 1; i <= N; i++) {
      int tmp = i;
      int cnt = 0;
      while ( tmp % 2 == 0) {
         tmp /= 2;
         cnt++;
      }
      if (cnt >= max) {
         ans = i;
         max = cnt;
      }
   }
   cout << ans << endl;
   return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(4) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {
    int n, a, b;
    cin >> n >> a >> b;
    a = abs(a - b);
    if (!(a & 1)) {
        cout << "Alice";
    } else {
        cout << "Borys";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

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

	UINT s = n+1;

	for (UINT i = 2; i < n / 2; i++)
	{
		if (n % i == 0)
		{
			s = min(s, i + (n / i));
		}
		if (i > (n / i))
		{
			break;
		}
	}

	cout << (s - 2) << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var R = new Array(N);
  for(var i=0;i<N;i++){
    var tmp=input[i+1].split(" ");
    R[i]=[i+1,tmp[0],parseInt(tmp[1])];
  }
  R.sort(function(a,b){
    if (a[1] < b[1]) return -1;
    if (a[1] > b[1]) return 1;
    if (a[2] < b[2]) return 1;
    if (a[2] > b[2]) return -1;
    return 0;
  })

  var ans="";
  for(var i=0;i<N;i++){
    if(i!=N-1){
      ans+=R[i][0]+"\n";
    }else{
      ans+=R[i][0];
    }
  }
  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

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

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const int MAXN = 2e5+5;

int n;
ll a[MAXN];

int main(){
	scan(n);
	for(int i=0; i<n; i++) scan(a[i]);
	for(int i=0; i<n; i++) a[i] = a[i] - (i+1);
	sort(a, a+n);
	ll b = a[n/2];
	ll ans=0;
	for(int i=0; i<n; i++) ans += abs(a[i]-b);
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var M = cin.ReadInt;
			var Table = N%2==0 ?
				Enumerable.Range(1, M).Select(i => $"{i} {(i<(double)(N/2+1)/2 ? N+1-i : N-i)}") :
				Enumerable.Range(1, M).Select(i => $"{i} {N+1-i}");
			Console.WriteLine(Table.Join("\n"));
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}

}

Measured memory_bytes: 40868
#include<stdio.h>
signed main(){
    int n;
    scanf("%d",&n);
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9){
        printf("hon\n");
    }
    if(n==0||n==1||n==6||n==8){
        printf("pon\n");
    }
    if(n==3){
        printf("bon\n");
    }
    return(0);
}

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

const int MAX_N = 1e5 + 5, inf = 1e9 + 7;
int n, k, ans;
bool mark[MAX_N];
int nxt[MAX_N];
int dis[MAX_N];
vector <int> topo;
vector <int> child[MAX_N];

void dfs (int v) {
	mark[v] = true;
	if (!mark[nxt[v]])
		dfs(nxt[v]);

	topo.push_back(v);
}

int dfs2 (int v = 0) {
	int tmp = dis[v];
	for (int u: child[v])
		tmp = max(tmp, dfs2(u));


	if (!v)
		return 0;

	if (tmp - dis[v] == k - 1 && nxt[v]) {
		ans++;
		nxt[v] = 0;
		dis[v] = 1;
		return -inf;
	}

	return tmp;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> nxt[i];
		nxt[i]--;

		if (i) {
			child[nxt[i]].push_back(i);
			cnt += nxt[i] != 0;
		}
	}
	if (nxt[0] != 0) {
		ans++;
		nxt[0] = 0;
	}

	if (k == 1) {
		ans += cnt;
		cout << ans << "\n";
		return 0;
	}

	for (int i = 0; i < n; i++)
		if (!mark[i])
			dfs(i);

	for (int v: topo)
		dis[v] = 1 + dis[nxt[v]];


	dfs2();
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 11768
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
c = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [[-1, -1] for i in range(n+1)]

dp[0] = [0, 0]
for i in range(1, n+1):
    for ai in a:
        ci = c[ai]
        if i - ci >= 0 and dp[i-ci][0] != -1:
            if dp[i][0] < dp[i-ci][0] + 1:
                dp[i] = [dp[i-ci][0] + 1, ai]
i = n
ans = []
while i > 0:
    ai = dp[i][1]
    ans.append(ai)
    i -= c[ai]
ans.sort(reverse=True)
print("".join(map(str, ans)))


Measured memory_bytes: 42096
#include <stdio.h>

int main(void){
	int r,c;
	int i,j,k;
	int sum;
	int sheet[101][101];
	scanf("%d %d",&r,&c);
	for(;;){
	for(i=0;i<r;i++){
		for(j=0;j<c;j++) scanf("%d",&sheet[i][j]);
	}
	
	for(i=0;i<r;i++){
			int sum = 0;
		for(j=0;j<c;j++){
			sum +=  sheet[i][j];
		}
			sheet[i][j] = sum;
	}

	for(i=0;i<=c;i++){
			sum = 0;
		for(j=0;j<r;j++){
			sum += sheet[j][i];
		}
		sheet[j][i] = sum;
	}

	for(i=0;i<=r;i++){
		for(j=0;j<=c;j++){
			if(j) printf(" ");
			printf("%d",sheet[i][j]);
		}
		printf("\n");
	}
	return 0;
	}
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

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

const int N = (int)5e5 + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e16;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

string s;
int a[N];
int main ()
{
    cin >> s;
    for (int i = 0; i < sz(s); ++i)
    {
        if (s[i] == '<') a[i + 1] = max(a[i + 1], a[i] + 1);
    }
    for (int i = sz(s) - 1; i >= 0; --i)
    {
        if (s[i] == '>') a[i] = max(a[i], a[i + 1] + 1);
    }
    ll ans = 0;
    for (int i = 0; i <= sz(s); ++i) ans += a[i];
    cout << ans << "\n";
    return 0;
}


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

int main() {
    int n; cin >> n;
    for (int day = 1; day <= n; ++day) {
        int bath_cost, pool_cost, b_num, p_num; cin >> bath_cost >> pool_cost >> b_num >> p_num;
        double normal_cost = double (bath_cost) * b_num + pool_cost * p_num;
        double discount_cost = 10000000;
        if (b_num < 5 || p_num < 2) {
          if (b_num < 5) b_num = 5;
          if (p_num < 2) p_num = 2;
          discount_cost = (double(bath_cost) * b_num + pool_cost * p_num) * 0.8;
        }
        else if (b_num >= 5 && p_num >= 2) {
          normal_cost *= 0.8;
        }
        
        double ans = min(normal_cost, discount_cost);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
#include <cstdlib>

using namespace std;

void solve(){
  long long int n; cin >> n;
  vector<long long int> v(n + 1, 0);
  vector<long long int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    v[a[i]]++;
  }

  long long int sum = 0;
  for(int i = 0; i <= n; i++){
    if(v[i] > 1){
      sum += v[i] * (v[i] - 1) / 2;
    }
  }

  for(int i = 0; i < n; i++){
    long long int ans = sum;
    if(v[a[i]] > 1){
      ans = ans - (v[a[i]] * (v[a[i]] - 1)) / 2 + (v[a[i]] - 1) * (v[a[i]] - 2) / 2;
    }
    cout << ans << endl;
  }

  return;
}

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


Measured memory_bytes: 5760
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;

signed main(){
    int a;
    cin>>a;
    int b;
    cin>>b;
    cout<<max({a+b,a-b,a*b})<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int A[15],n,m,q,a[55],b[55],c[55],d[55],ans;
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)  
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	for(int i=1;i<=n;i++) A[i]=1;
	while(!A[0])
	{
		int res=0;
		for(int i=1;i<=q;i++)
		{
			if((A[b[i]]-A[a[i]])==c[i])res+=d[i];
		}
		ans=max(res,ans);
		for(int i=n;i>=0;i--)
		{
			if(A[i]<m)
			{
				A[i]++;
				for(int j=i+1;j<=n;j++) A[j]=A[i];
				break;
			}
		}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<cmath>
#define ll long long
#define mx 800
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
inline ll jdz(ll x){return x>0?x:-x;}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
#define N 100011
ll a[N],n,s=0;
int main(){
	in(n);
	Fur(i,1,n){in(a[i]);s+=jdz(a[i]-a[i-1]);}s+=jdz(a[n]);
	Fur(i,1,n)outn(s-jdz(a[i]-a[i-1])-jdz(a[i]-a[i+1])+jdz(a[i-1]-a[i+1]));
}
/*

*/


Measured memory_bytes: 2560
#include <stdio.h>
int X[5];
int main() {
	int A;
	for (int i = 1; i <= 6; i++)
	{
		scanf("%d", &A);
		X[A]++;
	}
	int cna = 0;
	int cnb = 0;
	for (int i = 1; i <= 4; i++)
	{
		if (X[i] == 1) {
			cna++;
		}
		else if (X[i] == 2) {
			cnb++;
		}
	}
	if (cna == 2 && cnb == 2)
	{
		puts("YES");
		return 0;
	}
	else {
		puts("NO");
		return 0;
	}
}



Measured memory_bytes: 128
N = int(input())
D, X = map(int, input().split())
A = [0] * N
ans = 0
for i in range(N):
    a = int(input())
    A[i] = a
sum = 1
for a in A:
    for i in range(1, 100):
        if 1 + (a * i) > D:
            break
        sum += 1
    ans += sum
    sum = 1
ans += X
print(ans)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),K = in();
    vector<int> h(N);
    REP(i,N)h[i] = in();
    sort(ALL(h),greater<>());
    int minumum = 1000000000;
    REP(i,N-K+1){
        minumum = min(minumum,h[i] - h[i + K - 1]);
    }
    cout << minumum << "\n";
}

Measured memory_bytes: 640
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,j,m,n,card[4][14];
    char x;
    
    for(i=0;i<4;i++){
        for(j=1;j<14;j++){
            card[i][j]=0;
        }
    }
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s",&x);
        scanf("%d",&j);
        
        if(x=='S'){
            m=0;
        }else if(x=='H'){
            m=1;
        }else if(x=='C'){
            m=2;
        }else if(x=='D'){
            m=3;
        }
        card[m][j]=1;
    }
    for(i=0;i<4;i++){
        for(j=1;j<14;j++){
            if(card[i][j]==0){
                if(i==0){
                    printf("S %d\n",j);
                }else if(i==1){
                    printf("H %d\n",j);
                }else if(i==2){
                    printf("C %d\n",j);
                }else if(i==3){
                    printf("D %d\n",j);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
N,S=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353

#左端で考える
#左からiまででjを作る場合の数

dp=[0]*S
dp[0]=1
ans=0

for i in range(N):
    h=dp[:]
    a=A[i]
    if a>S:
        continue
    if a==S:
        ans=(ans+(i+1)*(N-i))%mod
        continue
        
    h[a]=(h[a]+i+1)%mod
    for j in range(a+1,S):
        h[j]=(h[j]+dp[j-a])%mod
    ans=(ans+dp[S-a]*(N-i))%mod
    dp=h
    
print(ans)

Measured memory_bytes: 42220
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    // ll A, B;
    // cin >> A >> B;

    // ll ans = 0;

    // if(true){
    //     cout << "Yes" << endl;
    // }else{
    //     cout << "No" << endl;
    // }

    char a, b;
    cin >> a >> b;
    if(a == 'H' && b == 'D'){
        cout << "D" << endl;
    }else if(a == 'D' && b == 'H'){
        cout << "D" << endl;
    }else if(a == 'D' && b == 'D'){
        cout << "H" << endl;
    }else{
        cout << "H" << endl;
    }

}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 200000;
    int N, A[MAX_N];
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A, A + N);
    ll res = 0;
    REP(i, N) {
        res += abs(A[i] - A[N / 2]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
// atcoder/agc040/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    vector<string> v;
    string t;
    each (c, s) {
      if (t.empty() || t.back() == c) t += c;
      else {
        v.push_back(t);
        t = string(1, c);
      }
    }
    if (t.size()) v.push_back(t);
    // cout << v << endl;
    lli sum = 0;
    each (i, v) {
      sum += (lli)i.size() * (i.size() + 1) / 2;
    }
    for (int i = 0; i + 1 < v.size(); ++i) {
      if (v[i][0] == '<') {
        sum -= min(v[i].size(), v[i + 1].size());
      }
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 14356
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.nextLine();
        char c = s.charAt(0);
		
		if(c == 'A') System.out.println('T');
		else if(c == 'T') System.out.println('A');
		else if(c == 'C') System.out.println('G');
		else System.out.println('C');
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;
typedef int ll;

int n;
string dp[1<<10][11];

int popcount(ll x){
    int ret = 0;
    while(x){
        x &= x-1;
        ret++;
    }
    return ret;
}
string comb(string a, string b){
	int i;
	for(i=0;i<a.size();i++)
		if(b.find(a.substr(i)) == 0){
			break;
		}
//	cout << a << " + " << b << " = " << a.substr(0,i) + b << endl;
	return a.substr(0,i) + b;
}

main(){
	int i,j,k;
	while(cin >> n, n){
		vector<string> s;
		string tmp[11];
		for(i=0;i<(1<<n);i++)
			for(j=0;j<n;j++) dp[i][j]="";
		for(i=0;i<n;i++){
			cin >> tmp[i];
			for(j=0;j<i;j++){
				if(tmp[j] == tmp[i]){
					i--;n--;
					break;
				}
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(i!=j && tmp[j].find(tmp[i]) != -1){
					break;
				}
			}
			if(j==n) s.push_back(tmp[i]);
		}
		n = s.size();
		for(i=0;i<(1<<n);i++)
			for(j=0;j<n;j++) dp[i][j]="";
		for(i=0;i<n;i++) dp[1<<i][i]=s[i];
		string ans="";
		for(i=0;i<(1<<n);i++){
			for(j=0;j<n;j++){
				for(k=0;k<n;k++){
					if(i&(1<<j) || !(i&(1<<k))) continue;
					string ret = comb(s[j], dp[i][k]);
					if( dp[i|(1<<j)][j]=="" ||
					   (ret.size()==dp[i|(1<<j)][j].size() && ret < dp[i|(1<<j)][j]) ||
					    ret.size()<dp[i|(1<<j)][j].size()) 
						dp[i|(1<<j)][j] = ret;
				}
				if(i==(1<<n)-1){
					if( ans=="" ||
					   (ans.size()==dp[i][j].size() && ans > dp[i][j]) ||
					    ans.size() > dp[i][j].size()) 
						ans = dp[i][j];
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

class UnionFind {
    public:
        UnionFind(int n);
        int find(int x);
        bool same(int x, int y);
        void unite(int xp, int yp);

    private:
        vector<int> par;
        vector<int> rnk;      
};

UnionFind::UnionFind(int n)
    : par(vector<int>(n)), rnk(vector<int>(n, 0))
{
    for(int i=0; i<n; ++i) par[i] = i;
}

int UnionFind::find(int x) {
    if(x != par[x]) par[x] = find(par[x]);
    return par[x];
}

bool UnionFind::same(int x, int y) {
    return find(x) == find(y);
}

void UnionFind::unite(int xp, int yp) {
    int x = find(xp);
    int y = find(yp);
    if(x == y) return;
    if(rnk[x] > rnk[y]) {
        par[y] = x;
    } else {
        par[x] = y;
        if(rnk[x] == rnk[y]) rnk[y]++;
    }
}

int main() {
    int n,q;
    cin >> n >> q;
    UnionFind uf(n);
    while(q--) {
        int c,x,y;
        cin >> c >> x >> y;
        if(c) cout << uf.same(x, y) << endl;
        else uf.unite(x, y);
    }
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2){
        cout << '1' << endl;
    }else{
        cout << '0' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

typedef long long int lli;
using namespace std;

int n;

lli solve() {
    lli sum = 0;
    for (int i = 1; i <= n; i++) {

        for (int j = i; j < n; j++) {
            int s = 0;
            for (int k = i; k <= j; k++)
                s += k;
            if (s == n) {
                sum++;
            }
        }
    }

    return sum;
}

int main() {
    ios::sync_with_stdio(false);

    while (cin >> n, n)
        cout << solve() << endl;
}

Measured memory_bytes: 1188
#Grid Repainting 2

#初期化
S = []
p = []
flag = True

#入力
H,W = map(int, input().split())
for i in range(H):
	s = input()
	s_list = list(s)
	S.append(s_list)

#計算
for i in range(0, H-1, 1):
	for j in range(0, W-1, 1):
		if S[i][j] == "#" and S[i+1][j] == "." and S[i][j+1] == "."  and S[i-1][j] == "." and S[i][j-1] == "." :
			flag = False
		

#出力
if flag == True:
	print("Yes")

else:
	print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define MOD 1000000007

long long fact(long long x)	{
  long long r = 1;
  for (long long i = 1; i <= x; i++)	{
    r = (r * i) % MOD;
  }
  return (r % MOD);
}

int main()	{
  long long m, d;
  cin >> m >> d;
  if (abs(m - d) >= 2)	{
    cout << 0 << endl;
    return 0;
  }
  else if (m == d) {
    cout << ((2) * ((fact(m) % MOD) * (fact(d) % MOD) % MOD)) % MOD << endl;
  }
  else if (m == d + 1 || d == m + 1)	{
    cout << ((fact(m) % MOD) * (fact(d) % MOD)) % MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m,a[100010],ans=0;
    multiset<ll> st;
    cin>>n>>m;
    rep(i,n){
        cin>>a[i];
        st.insert(a[i]);
    }
    sort(a,a+n);
    reverse(a,a+n);
    rep(i,m){
        auto itr=st.end();
        itr--;
        ll b=*itr;
        st.insert(b/2);
        st.erase(itr);
    }
    for(auto i:st){
        ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll pw(ll a , ll b)  { return (!b ? 1 : (b & 1 ? a * pw(a * a , b / 2) : pw(a * a , b / 2))); }

const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;

int v[MAXN], w[MAXN];

ll dp[MAXN];

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int n, W;
    cin >> n >> W;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    dp[0] = 0;
    for(int i = 1; i <= 1e6; i++){
        dp[i] = 1e17;
    }
    for(int i = 0; i < n; i++){
        for(int j = 100000; j >= v[i]; j--){
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    for(int j = 100000; j >= 0; j--){
        if(dp[j] <= W){
            return cout << j, 0;
        }
    }
    return 0;
}




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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

int main(){
	string s; cin>>s;
  if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) printf("Yes");
  else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) printf("Yes");
  else if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]) printf("Yes");
  else printf("No");
  
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stdlib.h>
#include <functional>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;

int n, m;
vector<int> vec[210];

int main()
{
	int i, j;
	scanf("%d", &n);

	for (i = 1; i <= 200; ++i) {
		for (j = 1; i*j <= 200; ++j) {
			vec[i*j].push_back(i);
		}
	}

	int cnt = 0;
	for (i = 3; i <= n; i += 2) {
		if (vec[i].size() == 8) cnt++;
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 256
#include <cstdio>

int n, k, p;

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d %d", &k, &p);

        int ans = k % p;
        if(ans == 0) printf("%d\n", p);
        else printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 2736
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N, M := nextInt(), nextInt()

	adj := make([][]int, N+1)
	for i := 1; i <= N; i++ {
		adj[i] = make([]int, 0)
	}

	for j := 0; j < M; j++ {
		a, b := nextInt(), nextInt()
		adj[a] = append(adj[a], b)
		adj[b] = append(adj[b], a)
	}

	reached := make([]bool, N+1)
	max_group_size := 0

	for i := 1; i <= N; i++ {
		if reached[i] {
			continue
		}
		q := make([]int, 0)
		var x int
		group_size := 0
		q = append(q, i)
		reached[i] = true
		for len(q) > 0 {
			x, q = q[0], q[1:]
			group_size += 1
			for _, y := range adj[x] {
				if reached[y] {
					continue
				}
				reached[y] = true
				q = append(q, y)
			}
		}
		if group_size > max_group_size {
			max_group_size = group_size
		}
	}

	fmt.Println(max_group_size)
}


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

int main() {

  vector<int> x(3);
  cin >> x[0] >> x[1] >> x[2];
  
  sort(x.begin(),x.end());
  
  int d1 = x[2] - x[0], d2 = x[2] - x[1],ans = 0;
  
  if ( d2 > 0 ){
    ans += d2;
    d1 -= d2;
  }
  
  if ( d1 % 2 == 0 ){
    ans += d1 /2;
  }else{
    ans += d1 / 2 + 2;
  }
  
  cout << ans << endl; 
  
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0;i < n;++i)    cin >> x[i];

    int min_sum = 1000000000;
    int ans_p;
    for(int p = 1;p <= 100;++p){
        int sum = 0;
        for(int i = 0;i < x.size();++i){
            sum += (x[i]-p) * (x[i]-p);
        }

        if(min_sum > sum){
            min_sum = sum;
            ans_p = p;
        }
    }

    cout << min_sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int d, n, a=1, s=0;
    cin >> d >> n;
    for(int i=0; i<d; i++)
        a*=100;
    if(n<100)
    s=a*n;
    else
    s=101*a;
    cout << s << '\n';
}

Measured memory_bytes: 256