akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#pragma GCC optimize ("02")
#define ll long long
#define oo 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

	string s, s2;
	bool ok = true;
	cin >> s;
	int sz = s.size(), br = 0;
	for(int i=0; i<(sz-1)/2; i++){
		if(s[i] != s[sz-i-1]){
			ok = false;
			break;
		}
		s2[i] = s[i];
		br++;
	}


	for(int i=0; i<(br+1)/2; i++){
		if(s2[i] != s2[br-1-i]){
			ok = false;
		}
	}

	if(ok == false) cout << "No";
	else cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
        string s; cin >> s;

        ll res = 0;
        for (int len = 2; len < sz(s); len+=2) {
                bool possible = true;
                FOR(i, 0, len/2) {
                        if (s[i] != s[len/2+i]) possible = false;
                }
                if (possible) res = len;
        }
        cout << res << endl;
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 256
n,m,*a=map(int,open(0).read().split())
dp=[-1]*(n+1)
for i in a:
    dp[i]=0
dp[0]=1 
for i in range(1,n+1):
    if dp[i]!=0:
        dp[i]=dp[i-1]+dp[i-2]*(i>1)
print(dp[-1]%(10**9+7))

Measured memory_bytes: 462708
#pragma warning(disable:4996)
#pragma warning(disable:4786)
#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;

int main(){
	string word;
	int page;
	map<string, set<int>> indexs;
	while (cin >> word >> page){
		indexs[word].insert(page);
	}
	for (auto index : indexs){
		cout << index.first << endl;
		for (auto page_a : index.second){
			cout << page_a;
			if (*(index.second.rbegin()) != page_a)
				cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int W,a,b;

	cin >> W >> a >> b;

	if(b>a+W){
		cout << b-(a+W);
	}else if(a>b+W){
		cout << a-(b+W);
	}else{
		cout << 0;
	}

	return 0;
}


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

long long int n,k,i,x,y,ans,mod;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;ans=0;mod=1e9+7;
	for (i=k;i<n+2;i++)
	{
		ans=ans-(i*i-i)/2+1;
		x=n+1-i;
		ans=ans+(n*n+n)/2-(x*x-x)/2;
		ans=ans%mod;
	}
	cout<<ans;
}


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

int main ()
{
    int n,ara[111],i,j;
    double total=0;
    cin>>n;
    for (i=1; i<=n; i++)
        cin>>ara[i];
    for (i=1; i<=n; i++)
    {
        total+=(1/(ara[i]*1.0));
    }
    total=1/total;
    cout<<total<<endl;

    return 0;
}


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

#define eps 1.0e-8
int main()
{

  int n, i, f;
  double d, dd, s1, s2;
  while (cin>>n, n) {
    s1 = s2 = 0;
    dd = 360.0;
    for (i = 1; i < n; i++) {
      cin>>d;
      dd -= d;
      s1 += sin(d * M_PI/180.0);
    }
    s1 += sin(dd * M_PI/180.0);
    cin>>n;
    dd = 360.0;
    for (i = 1; i < n; i++) {
      cin>>d;
      dd -= d;
      s2 += sin(d * M_PI/180.0);
    }
    s2 += sin(dd * M_PI/180.0);
    if (fabs(s1-s2) < eps) f = 0;
    else if (s1>s2) f = 1;
    else f = 2;
    cout<<f<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long n,i,l,r,m;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>l>>r;
		m=m+r-l+1;	
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
kekka=[]
for i in range(N):
    li=list(input().split())
    li=[int(s) for s in li]
    li=li[1::]
    #print(li)
    if i==0:
        base=li
    else:
        kekka.append(li)
count=1
summ=0
for j in base:
    for i in range(N-1):
        if j in kekka[i]:
            count+=1
        #print(count)
    summ+=count//N
    count=1
        #print(j,count)
print(summ)

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

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define reP(i, x, n) for(int i=x; i<n; i++)
#define aLL(x) x.begin(), x.end()
#define pB push_back
#define eB emplace_back
#define tRav(a, x) for(auto& a: x)
#define fI first
#define sE second
#define lB lower_bound
#define uB upper_bound
#define MOD 1000000007

typedef vector<int> vec;
typedef long long ll;
typedef unsigned long long ull;

bool isPalindrome(string str) 
{ 
    int l = 0;
    int h =str.length() - 1; 
  
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return false; 
        } 
    } 
   return true; 
} 


int main(){
    fast_cin();
    string s;cin>>s;
    int n=(s.length()-1)/2;
    int m=(s.length()+3)/2;
    string s1, s2;
   	for(int i=0;i<n;i++)
    	s1+=s[i];
    for(int i=m-1;i<s.length();i++)
    	s2+=s[i];
    int ans=0;
    ans+=isPalindrome(s);
    ans+=isPalindrome(s1);
    ans+=isPalindrome(s2);
    //cout<<ans<<endl;
    //cout<<s1<<" "<<s2;
    if(ans==3)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int sum_a;
	int i;

	scanf("%d %d %d",&a,&b,&c);
	a%=b;
	sum_a=a;
	for (i=1;i<b;++i)
	{
		sum_a+=a;
		if (sum_a>=b)
		{
			sum_a-=b;
		}
		if (sum_a==c)
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}



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

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

int main()
{
    ll x, y;
    cin >> x >> y;
    ll a, b;
    a = 2 * y - x;
    b = 2 * x - y;
    if (a % 3 != 0 || b % 3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    if (a < 0 || b < 0)
    {
        cout << 0 << endl;
        return 0;
    }
    a /= 3;
    b /= 3;
    ll ab = a + b;
    ll ans = 1, aa = 1, bb = 1, abab = 1;
    for (ll i = 1; i <= a; i++)
    {
        aa = (aa * i) % mod;
    }
    for (ll i = 1; i <= b; i++)
    {
        bb = (bb * i) % mod;
    }
    for (ll i = 1; i <= ab; i++)
    {
        abab = (abab * i) % mod;
    }
    ans = (abab * modinv(aa, mod)) % mod * modinv(bb, mod);
    cout << ans % mod << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

// All is correct except for one test case

int main(int argc, char const *argv[])
{
    long long base = 100;
    // Other people don't include this interest variable
    double interest = 0.01;
    long long years = 1;

    long long target; //103
    cin >> target;

    // How many years it take to get to or above target;

    for (int i = base; i <= target; ++years)
    {
        base = (base * interest) + base;
        if (base >= target)
        {
            cout << years << "\n";
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

vector<pair<int,int>> v;

int main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        v.push_back(make_pair(b,a));
    }
    sort(v.begin(),v.end());
    int count = 0;
    int f = -1;
    for(int i=0;i<m;i++){
        a = v[i].second;
        b = v[i].first;
        if(f >= a) continue;
        f = b-1;
        count++;
    }
    cout << count << endl;
    return 0;
}

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

int main() {
  char b;
  cin >> b;

  if (b == 'A') cout << "T" << endl;
  else if (b == 'T') cout << "A" << endl;
  else if (b == 'C') cout << "G" << endl;
  else cout << "C" << endl;
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt N, A[3]; cin >> N >> A[0] >> A[1] >> A[2];
	vector<char> vec;
	char preva = '#', prevb = '#';
	REP(i, N){
		char a, b; cin >> a >> b;
		int p = a-'A', q = b-'A';
		if(A[p] == 0 and A[q] == 0){
			if(preva == '#' and prevb == '#'){
				cout << "No" << ln;
				return 0;
			}
			char tmp = (vec.back()==preva ? prevb : preva);
			if(A[vec.back()-'A'] == 2 and A[tmp-'A'] == 0){
				swap(A[vec.back()-'A'], A[tmp-'A']);
				vec.pop_back(); vec.eb(tmp);
			} else {
				cout << "No" << ln;
				return 0;
			}
		}
		if(A[p] < A[q]){
			vec.eb(a);
			A[p]++; A[q]--;
		} else {
			vec.eb(b);
			A[q]++; A[p]--;
		}
		preva = a, prevb = b;
	}
	cout << "Yes" << ln;
	REP(i, N){
		cout << vec[i] << ln;
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <functional>
#include <set>
#include <iomanip>
#include <tuple>
typedef  long long ll;
using namespace std;

int main(void) {
	string s;
	cin >> s;
	
	int E = count(s.begin(), s.end(), 'E');
	int W = count(s.begin(), s.end(), 'W');
	int S = count(s.begin(), s.end(), 'S');
	int N = count(s.begin(), s.end(), 'N');

	if ((E > 0 && W > 0) && (S > 0 && N > 0)) cout << "Yes" << endl;
	else if ((E == 0 && W == 0) && (S > 0 && N > 0)) cout << "Yes" << endl;
	else if ((E == 0 && W == 0) && (S == 0 && N == 0)) cout << "Yes" << endl;
	else if ((E > 0 && W > 0) && (S == 0 && N == 0)) cout << "Yes" << endl;
	else cout << "No" << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> s[i][j];
    }
  }
  vector<int> dy = {-1, 1, 0, 0};
  vector<int> dx = {0, 0, -1, 1};

  rep(i, H) {
    rep(j, W) {
      bool check = false;
      if (s[i][j] == '.') continue;

      rep(k, 4) {
        if (i+dy[k] < 0 || i+dy[k] >= H || j+dx[k] < 0 || j + dx[k] >= W) continue;
        if (s[i+dy[k]][j+dx[k]] == '#') {
          check = true;
          break;
        }
      }
      if (!check) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3636
package main

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

func main() {
	N := ReadInt()
	A := ReadInts(N)

	ans := 0
	s := 0
	for i := 0; i < N; i++ {
		if A[i] == 0 {
			ans += s / 2
			s = 0
		} else {
			s += A[i]
		}
	}
	ans += s / 2
	fmt.Println(ans)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

int main()
{
    ll n, sum = 0;
    cin >> n;
    vector<ll> a(n);
    vector<ll> num(n);

    REP(i, n)
    {
        cin >> a.at(i);
        num.at(a.at(i) - 1)++;
    }

    REP(i, n)
    {
        sum += num.at(i) * (num.at(i) - 1) / 2;
    }

    REP(i, n)
    {
        ll ans;
        ans = sum - num.at(a.at(i)-1) * (num.at(a.at(i)-1) - 1) / 2 + (num.at(a.at(i)-1) - 1) * (num.at(a.at(i)-1) - 2) / 2;
        cout << ans << "\n";
    }
    return 0;
}


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

int main() {
    string S, T;
    int ans = 0;
    cin >> S >> T;
    for (int i = 0; i < 3; i++) {
        if (S.at(i) == T.at(i)) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  int k;
  cin >> k;
  vector<int> vec =
      vector<int>{1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                  1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << vec[k - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	ll N; cin >> N;
	V<ll> ds;
	for(ll i=1;i*i<=N;i++) if(N%i == 0){
		ds.pb(i);
		if(i*i != N) ds.pb(N/i);
	}
	ll ans = 0;
	for(ll d: ds){
		ll m = d-1;
		ll a = N/d;
		if(m > 0 && a<m) ans+=m;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

struct UnionFind{
    vector<ll> par;
    vector<ll> rank;

    UnionFind(ll N): par(N,-1), rank(N, 1){}

    ll root(ll x){
        if(par[x] < 0) return x;
        else{
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) swap(x,y);
        if(rank[x] == rank[y])rank[x]++;
        par[x] += par[y];
        par[y] = x;
        return;
    }

    bool is_same(ll x, ll y){
        return root(x) == root(y);
    }

    ll size(ll x){
        return -1 * par[root(x)];
    }
};

int main(){
    ll N,M;
    cin>>N>>M;
    UnionFind UF(N);

    rep(i,0,M){
        ll a,b;
        cin>>a>>b;a--;b--;
        UF.unite(a,b);
    }
    ll ans = 0;
    rep(i,0,N){
        ans = max(ans, UF.size(i));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
typedef tuple< int, int, int, int > State;
const int vy[2][7] = {
  {1, 0, -1, -1, -1, 0, 0},
  {1, 1, 0, -1, 0, 1, 0}
};
const int vx[7] = {0, 1, 1, 0, -1, -1, 0};

int sx, sy, gx, gy, N;
bool s[201][201];
int min_cost[201][201][6];
int lx, ly;

int Dijkstra()
{
  fill_n(**min_cost, 201 * 201 * 6, INF);
  priority_queue< State, vector< State >, greater< State > > que;
  que.emplace(0, sy, sx, 0);
  min_cost[sy][sx][0] = 0;
  while(!que.empty()) {
    int cost, y, x, mod;
    tie(cost, y, x, mod) = que.top(); que.pop();
    if(gx == x && gy == y) return(cost);
    if(cost > min_cost[y][x][mod]) continue;
    for(int i = 0; i < 7; i++) {
      int ny = y + vy[x & 1][i], nx = x + vx[i];
      if(abs(ny - 100) > ly - 100 || abs(nx - 100) > lx - 100) continue;
      if(s[ny][nx]) continue;
      int ncost = cost + (abs((x - 100) * (y - 100) * mod) % 6 != i);
      if(ncost >= min_cost[ny][nx][(mod + 1) % 6]) continue;
      min_cost[ny][nx][(mod + 1) % 6] = ncost;
      que.emplace(ncost, ny, nx, (mod + 1) % 6);
    }
  }
  return(-1);
}

int main()
{  
  cin >> sx >> sy >> gx >> gy;
  sx += 100, sy += 100;
  gx += 100, gy += 100;
  cin >> N;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    s[y + 100][x + 100]++;
  }
  cin >> lx >> ly;
  lx += 100, ly += 100;
  cout << Dijkstra() << endl;
}

Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n;
	string s;
	cin >> n;
	if (n == 0){
		cout << 0 << endl;
		return 0;
	}
	for (;;){
		if (n == 0) break;
		if (n % 2 == 1){
			s += '1';
			n /= -2;
		}else if (n % 2 == 0){
			s += '0';
			n /= -2;
		}else{
			s += '1';
			n = (n-2)/ -2;
		}
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second

struct BIT{
	int siz;
	int s[(1<<18)+10];
	void init(int siz_ = 1<<18){
		siz = siz_;
		for(int i = 1 ; i <= siz ; i ++){
			s[i] = 0;
		}
	}
	void add(int k,int x = 1){
		while(k <= siz){
			s[k] += x;
			k += k&-k;
		}
	}
	int sum(int k){
		int ret = 0;
		while(k > 0){
			ret += s[k];
			k -= k&-k;
		}
		return ret;
	}
};

ll calc_inv(vector<int> *vec){
	vector<pair<int,int>> v;
	for(int i = 0 ; i < vec->size() ; i ++){
		v.push_back(pair<int,int>((*vec)[i],i+1));
	}
	sort(v.begin(),v.end());
	static BIT bit;
	bit.init();
	ll cnt = vec->size(); cnt *= cnt-1; cnt /= 2;
	for(int i = 0 ; i < v.size() ; i ++){
		cnt -= bit.sum(v[i].sc);
		bit.add(v[i].sc);
	}
	return cnt;
}

int main(){
	string S;
	cin >> S;
	
	vector<int> vec[26];
	for(int i = 0 ; i < S.size() ; ++i){
		vec[S[i]-'a'].pb(i);
	}
	
	vector<P> v;
	int mid = -1;
	for(int i = 0 ; i < 26 ; ++i){
		for(int j = 0 ; j < -j-1+(int)vec[i].size() ; ++j){
			v.pb(P(vec[i][j],vec[i][-j-1+vec[i].size()]));
		}
		if(vec[i].size()%2 == 1){
			if(mid != -1){
				puts("-1");
				return 0;
			}
			mid = vec[i][vec[i].size()/2];
		}
	}
	
	sort(v.begin(),v.end());
	vector<int> per;
	for(int i = 0 ; i < v.size() ; i ++){
		per.pb(v[i].fr);
	}
	if(mid != -1)per.pb(mid);
	for(int i = -1+(int)v.size() ; i >= 0 ; --i){
		per.pb(v[i].sc);
	}
	
	cout << calc_inv(&per) << endl;
}



Measured memory_bytes: 6388
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
// #include <unordered_map>
#include <cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m, n) for (int i = m; i < n; i++)
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
#define ST(x, y, z) sort(x + y, x + z);
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
#define re read()
#define case  \
    int T;    \
    cin >> T; \
    rep(_,1,T)
// #define int ll
#define LL long long
#define int ll
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}

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

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

const int N =  100+5;
int a[N];
int dp[N][N];

int st[27][N];
signed main()
{
    //STDIN
    int n; n = re;
    cout << n + n*n + n*n*n << endl;
}

Measured memory_bytes: 3628
h,w = map(int,input().split())
s = [input() for _ in range(h)]

dist = [[-1]*w for _ in range(h)]
dist[0][0]=0
que = [(0,0)]
move = [(0,1),(0,-1),(1,0),(-1,0)]

n_white = 0
for i in range(h):
    n_white += s[i].count(".")

while que!=[]:
    (x , y) = que.pop(0)
    
    for m in move:
        nx = x + m[0]
        ny = y + m[1]
        if (0<=nx<h and 0<=ny<w):
            if dist[nx][ny] != -1: continue
            
            if s[nx][ny] == ".":
                dist[nx][ny] = dist[x][y]+1
                que.append((nx,ny))
distance = dist[-1][-1]
if distance == -1:
    print(-1)
else:
    print(n_white - distance - 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a1,b1,c1,d1,p,q;
	cin>>a1>>b1>>c1>>d1;
	if(a1*c1>a1*d1)
	{
		p=a1*c1;
	}
	else
	{
		p=a1*d1;
	}
	if(b1*c1>b1*d1)
	{
		q=b1*c1;
	}
	else
	{
		q=b1*d1;
	}
	if(p>q)
	{
		cout<<p<<endl;
	}
	else
	{
		cout<<q<<endl;
	}
}

Measured memory_bytes: 3632
X = int(input())

R = 3000
go = [i**5 for i in range(R)]


def foo():
    for i in range(R):
        for j in range(R):
            if go[i] - go[j] == X:
                return i, j
        for j in range(i, R):
            if go[i] + go[j] == X:
                return i, -j

    return 0, 0


A, B = foo()
print(A, B)


Measured memory_bytes: 9312
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;

signed main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    std::ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        if (n % 10 == 3) {
            cout << "bon\n";
        } else if ( n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
            cout << "pon\n";
        } else if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) {
            cout << "hon\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3644
from typing import List


def answer(n: int, x: int, m: List[int]) -> int:
    x -= sum(m)
    count = len(m)
    count += x // min(m)

    return count


def main():
    n, x = map(int, input().split())
    m = [int(input()) for _ in range(n)]
    print(answer(n, x, m))


if __name__ == '__main__':
    main()

Measured memory_bytes: 10148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for(auto&a : A) cin >> a;
	sort(A.begin(), A.end());

	ll ok = 1e18, ng = -1e18;
	while(ok - ng > 1) {
		ll mid = (ok + ng) / 2;
		ll eq_and_less_than_mid_num = 0;
		for(ll i=0;i<N-1;i++) {
			if(A[i] < 0) {
				// j > iについてA[i]との積がmidよりも小さくなるA[j]の数
				ll left = i;
				ll right = N;
				while(right - left > 1) {
					ll upper_mid = (left + right) / 2;
					if(A[i] * A[upper_mid] <= mid) right = upper_mid;
					else left = upper_mid;
				}
				eq_and_less_than_mid_num += (N - right);
			}else {
				ll left = i;
				ll right = N;
				while(right - left > 1) {
					ll upper_mid = (left + right) / 2;
					if(A[i] * A[upper_mid] <= mid) left = upper_mid;
					else right = upper_mid;
				}
				eq_and_less_than_mid_num += (left - i);
			}

		}
		if(eq_and_less_than_mid_num >= K) ok = mid; else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
signed main(){
    int l;
    cin>>l;
    double e=1.0000*l/3;
    double ans=e*e*e;
    printf("%.12lf\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string ans = "Yes";
    int N;
    cin >> N;
    vector<pair<long long, long long>> BA(N);
    for(int i = 0; i < N; i++) {
        long long A, B;
        cin >> A >> B;
        BA.at(i) = make_pair(B, A);
    }
    sort(BA.begin(), BA.end());
    
    vector<pair<long long, long long>> shimekiri_jikan;
    shimekiri_jikan.push_back(make_pair(BA.at(0).first, BA.at(0).second));
    for(int i = 1; i < N; i++) {
        int k = shimekiri_jikan.size();
        if(shimekiri_jikan.at(k-1).first == BA.at(i).first) {
            shimekiri_jikan.at(k-1).second += BA.at(i).second;
        }
        else shimekiri_jikan.push_back(make_pair(BA.at(i).first, BA.at(i).second));
    }
    sort(shimekiri_jikan.begin(), shimekiri_jikan.end());
    
    long long remain = shimekiri_jikan.at(0).first - shimekiri_jikan.at(0).second;
    if(remain<0) ans = "No";
    for(int i = 1; i < shimekiri_jikan.size(); i++) {
        remain += shimekiri_jikan.at(i).first - shimekiri_jikan.at(i-1).first;
        remain -= shimekiri_jikan.at(i).second;
        if(remain<0) ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 9456
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int N,R;

int main()
{
  int n;
  int ret=0;

  cin >> N >> R;

  if (N>=10) {
    printf("%d\n", R);
  } else {
    printf("%d\n", R + 100*(10 - N));
  }

  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 04.05.2019 15:30:39       
**/
#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool Stays(int len, int pos, vector<int> mv, vector<int> who) {
  debug(len, pos, mv, who);
  int L = 1;
  int R = len;
  for (int it = (int) mv.size() - 1; it >= 0; it--) {
    int m = mv[it];
    int w = who[it];
    if (w == 1) {
      if (m == -1) R = min(R + 1, len);
      else L = max(L - 1, 1);
    } else {
      if (m == -1) L++;
      else R--;
    }
    debug(it, L, R);
    if (L > R) return false;
  }
  return (L <= pos && pos <= R);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, n, sr, sc;
  cin >> h >> w >> n >> sr >> sc;
  string s, t;
  cin >> s >> t;
  vector<int> move_h, who_h;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'U') {
      move_h.push_back(-1);
      who_h.push_back(0);
    }
    if (s[i] == 'D') {
      move_h.push_back(1);
      who_h.push_back(0);
    }
    if (t[i] == 'U') {
      move_h.push_back(-1);
      who_h.push_back(1);
    }
    if (t[i] == 'D') {
      move_h.push_back(1);
      who_h.push_back(1);
    }
  }
  vector<int> move_w, who_w;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L') {
      move_w.push_back(-1);
      who_w.push_back(0);
    }
    if (s[i] == 'R') {
      move_w.push_back(1);
      who_w.push_back(0);
    }
    if (t[i] == 'L') {
      move_w.push_back(-1);
      who_w.push_back(1);
    }
    if (t[i] == 'R') {
      move_w.push_back(1);
      who_w.push_back(1);
    }
  }
  if (Stays(h, sr, move_h, who_h) && Stays(w, sc, move_w, who_w)) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}


Measured memory_bytes: 7088
#include<stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int a[n],b[n],c[n-1];
    for(int i=0;n>i;++i)
    scanf("%d",&a[i]);
    for(int i=0;n>i;++i)
    scanf("%d",&b[i]);
    for(int i=0;n-1>i;++i)
    scanf("%d",&c[i]);
    int sum=0;
    for(int i=0;n>i;++i)
    sum+=b[i];
    for(int i=0;n-1>i;++i){
        if(a[i]==a[i+1]-1)
        sum+=c[a[i]-1];
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
def ad_list_gen(S):
    l = len(S)
    ad_list = [[] for i in range(l)]
    al_dict = {}

    for i, moji in enumerate(S):
        if moji not in al_dict:
            al_dict[moji] = i
        else:
            ad_list[al_dict[moji]].append(i)
    
    return ad_list

S = input()
T = input()

ad_list = ad_list_gen(S)
ad_list2 = ad_list_gen(T)
if ad_list==ad_list2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 49200
n=int(input())
a=[int(i) for i in input().split()]
left=[0,abs(a[0])]+[0]*(n-2)
right=[0,abs(a[-1])]+[0]*(n-2)
for i in range(1,n-1):
    left[i+1]=left[i]+abs(a[i-1]-a[i])
    right[i+1]=right[i]+abs(a[n-i-1]-a[n-i])
for i in range(n):
    ans=left[i]+right[n-i-1]
    if i==0:
        ans+=abs(a[1])
    elif i==n-1:
        ans+=abs(a[n-2])
    else:
        ans+=abs(a[i+1]-a[i-1])
    print(ans)

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;

const ll MOD = 998244353;
const int MAXN = 2e5 + 5;

int n;

int closeup[4 * MAXN];
int closeright[4 * MAXN];

int lson(int v) {
    return 2 * v + 1;
}

int rson(int v) {
    return 2 * v + 2;
}

void push(int v, int setting[]) {
    if (setting[v] == -1) return;
    setting[lson(v)] = setting[rson(v)] = setting[v];
    setting[v] = -1;
}

void build(int v = 0, int tl = 0, int tr = n - 1) {
    if (tl == tr) {
        closeup[v] = n - 1;
        closeright[v] = n - 1;
        return;
    }
    int tm = (tl + tr) / 2;
    closeright[v] = closeup[v] = -1;
    build(lson(v), tl, tm);
    build(rson(v), tm + 1, tr);
}

void set_on_seg(int l, int r, int val, int setting[], int v = 0, int tl = 0, int tr = n - 1) {
    if (tl > r || tr < l || l > r) return;
    if (tl >= l && tr <= r) {
        setting[v] = val;
        return;
    }
    int tm = (tl + tr) / 2;
    push(v, setting);
    set_on_seg(l, r, val, setting, lson(v), tl, tm);
    set_on_seg(l, r, val, setting, rson(v), tm + 1, tr);
}

int get_elem(int ind, int setting[], int v = 0, int tl = 0, int tr = n - 1) {
    //cout << "v: " << v << ' ' << tl << ' ' << tr << ' ' << setting[v] << endl;
    if (tl == tr) {
        return setting[v];
    }
    int tm = (tl + tr) / 2;
    push(v, setting);
    if (ind <= tm) return get_elem(ind, setting, lson(v), tl, tm);
    else return get_elem(ind, setting, rson(v), tm + 1, tr);
}

int main() {
    int q;
    cin >> n >> q;
    ll blacks = (n - 2) * 1ll * (n - 2);
    build();
    while (q--) {
        int t, x;
        cin >> t >> x;
        --x;
        if (t == 1) {
            int minival = get_elem(x, closeup);
            //cout << "closeup: " << minival << endl;
            int l = -1, r = minival;
            blacks -= max(0, (minival - 1));
            while (r - l > 1) {
                int mid = (l + r) / 2;
                //cout << "mid: " << mid << ' ' << get_elem(mid, closeright) << endl;
                if (get_elem(mid, closeright) >= x) r = mid;
                else l = mid;
            }
           // cout << "seg: " << r << ' ' << minival - 1 << endl;
            if (r < minival) set_on_seg(r, minival - 1, x, closeright);
        } else {
            int minival = get_elem(x, closeright);
            //cout << "closeright: " << minival << endl;
            int l = -1, r = minival;
            blacks -= max(0, (minival - 1));
            while (r - l > 1) {
                int mid = (l + r) / 2;
                if (get_elem(mid, closeup) >= x) r = mid;
                else l = mid;
            }
            if (r < minival) set_on_seg(r, minival - 1, x, closeup);
        }
    }
    cout << blacks << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s, t;
	cin >> s >> t;

	ll res = sz(t);
	FOR(i,0,sz(s)-sz(t)+1) {
		ll cur = 0;
		FOR(j,0,sz(t)) cur += s[i+j] != t[j];
		res = min(res,cur);
	}
	cout << res << endl;

}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll val=max(a*d,b*c);
   cout<<max({a*c,b*d,val});




}

Measured memory_bytes: 3632
def main():
    n,k = map(int,input().split())
    xy = [list(map(int,input().split())) for _ in range(n)]

    ans = 10 ** 20

    for i in range(n):
        for j in range(i+1, n):
            for ii in range(n):
                for jj in range(ii+1, n):
                    l = min(xy[i][0], xy[j][0])
                    r = max(xy[i][0], xy[j][0])
                    d = min(xy[ii][1], xy[jj][1])
                    u = max(xy[ii][1], xy[jj][1])
                    cnt = 0
                    for x,y in xy:
                        if l <= x <= r and d <= y <= u:
                            cnt += 1
                    if cnt >= k:
                        ans = min(ans, (r-l) * (u - d))

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 52572
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
  int n;
  vector<int> hp(n);
  cin>>n;
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    hp[i]=t;
  }
  int g=__gcd(hp[1],hp[0]);
  for(int j=0;j<n;j++){
    g=__gcd(g,hp[j]);
  }
  cout<<g<<endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define ms memset
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define lower_bound lb
#define upper_bound ub

int main()
{
    int n; cin >> n;
    int m = n % 1000;
    if (m == 0) cout << 0 << '\n';
    else cout << 1000-m << '\n';
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(void) {
  int A,B ;
  
  cin >> A >>B;
  
  A += 11;
  B += 11;
  
  if(A%13 > B%13)	cout << ("Alice") ;
  else if(A%13 < B%13)	cout << ("Bob") ;
  else cout << ("Draw") << endl;
  
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int count = 0;
  if(S[0] == 'o') ++count;
  if(S[1] == 'o') ++count;
  if(S[2] == 'o') ++count;
  
  cout << 700 + (count*100) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    double sum = 0;
    vector<pair<ll, ll>> xy(n);
    rep(i, n) cin >> xy[i].first >> xy[i].second;
    sort(all(xy));
    do {
        rep(i, n - 1) {
            ll dx = xy[i].first - xy[i + 1].first;
            ll dy = xy[i].second - xy[i + 1].second;
            sum += sqrt(dx * dx + dy * dy);
        }
    }
    while(next_permutation(all(xy)));
    rep(i, n) sum /= (i + 1);
    printf("%.10f\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
/* contest template */

int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) { cout << "Yes"; }
	else { cout << "No"; }
}

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

using namespace std;

int main() {
    int a;
    string s;
    cin>>a;
    cin>>s;
    if (a>=3200) {
        cout<<s;
    } else {
        cout<<"red";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
 
using namespace std;
 
typedef complex<double> P;
 
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) ((EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
 
double cross(P a, P b) 
{
    return (a.real() * b.imag() - a.imag() * b.real());
}
 
bool is_parallel(P a1, P a2, P b1, P b2) 
{
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}
 
 
int main()
{
    int num;
    double  x1, y1, x2, y2, x3, y3, x4, y4;
     
    cin >> num;
    for (int i = 0; i < num; i++) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
         
        if (is_parallel(P(x1, y1), P(x2, y2), P(x3, y3), P(x4, y4)))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int> > Hs, Ws;

int init(int k)
{
	int sz;
	sz = 1;
	while (sz < k){
		sz *= 2;
	}
	
	return (sz);
}

void update(vector<int> &seg, int pos, int val)
{
	pos += (seg.size() / 2) - 1;
	seg[pos] = val;
	
	while (pos){
		pos = (pos - 1) / 2;
		seg[pos] = min(seg[2 * pos + 1], seg[2 * pos + 2]);
	};
}

int getMin(vector<int> &seg, int a, int b, int k, int l, int r)
{
	int vl, vr;
	
	if (b <= l || r <= a){
		return (INT_MAX);
	}
	
	if (a <= l && r <= b){
		return (seg[k]);
	}
	else {
		vl = getMin(seg, a, b, k * 2 + 1, l, (l + r) / 2);
		vr = getMin(seg, a, b, k * 2 + 2, (l + r) / 2, r);
	}
	
	return (min(vl, vr));
}

int main()
{
	int H, W, Q;
	

	while (1){
		scanf("%d %d %d", &H, &W, &Q);
		
		if (H + W + Q == 0){
			break;
		}
		
		Hs.resize(H);
		Ws.resize(W);
		
		int Hsz = 2 * init(W);
		int Wsz = 2 * init(H);
		
		for (int i = 0; i < H; i++){
			Hs[i].resize(Hsz);
			fill(Hs[i].begin(), Hs[i].end(), INT_MAX);
		}
		
		for (int i = 0; i < W; i++){
			Ws[i].resize(Wsz);
			fill(Ws[i].begin(), Ws[i].end(), INT_MAX);
		}
		
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				int t;
				scanf("%d", &t);
				update(Hs[i], j, t);
				update(Ws[j], i, t);
			}
		}
		
		for (int i = 0; i < Q; i++){
			int h1, w1, h2, w2;
			scanf("%d %d %d %d", &h1, &w1, &h2, &w2);
			int res = INT_MAX;
			
			if (h2 - h1 <= w2 - w1){
				for (int j = h1; j <= h2; j++){
					res = min(res, getMin(Hs[j], w1, w2 + 1, 0, 0, Hs[j].size() / 2));
				}
			}
			else {
				for (int j = w1; j <= w2; j++){
					res = min(res, getMin(Ws[j], h1, h2 + 1, 0, 0, Ws[j].size() / 2));
				}
			}
			
			printf("%d\n", res);
		}
		
	}
	
	return (0);
}

Measured memory_bytes: 63744
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;


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


int main() {
    int A, B, cost;
    cin >> A >> B;
    if (A >= 13) { cost = B; }
    else if (A >= 6) { cost = B / 2; }
    else { cost = 0; }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        scanner.nextInt();
        scanner.nextInt();
        final int m = scanner.nextInt();

        final Map<Integer, Integer> hCounts = new HashMap<>();
        final Map<Integer, Integer> wCounts = new HashMap<>();
        final Map<Integer, Set<Integer>> points = new HashMap<>();
        for (int i = 0; i < m; i++) {
            final int tmpH = scanner.nextInt();
            final int tmpW = scanner.nextInt();
            hCounts.compute(tmpH, (k, v) -> v == null ? 1 : v + 1);
            wCounts.compute(tmpW, (k, v) -> v == null ? 1 : v + 1);
            points.computeIfAbsent(tmpH, v -> new HashSet<>()).add(tmpW);
        }

        final int maxH = hCounts.values().stream().max(Integer::compare).orElseThrow();
        final int maxW = wCounts.values().stream().max(Integer::compareTo).orElseThrow();

        final Map<Integer, Integer> filteredH = hCounts.entrySet().stream()
            .filter(e -> e.getValue() == maxH)
            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

        final Map<Integer, Integer> filteredW = wCounts.entrySet().stream()
            .filter(e -> e.getValue() == maxW)
            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

        final int base = maxH + maxW;
        if ((long) filteredH.size() * (long) filteredW.size() > m) {
            System.out.println(base);
            return;
        }

        filteredH.entrySet().stream()
            .flatMap(h -> filteredW.entrySet().stream()
                .filter(w -> !points.containsKey(h.getKey()) || !points.get(h.getKey()).contains(w.getKey()))
            ).findAny()
            .ifPresentOrElse(
                e -> System.out.println(base),
                () -> System.out.println(base - 1)
            );
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 229636
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;


int main(void){
    int N,K;
    cin >> N >> K;
    vector<ll> h(N);
    for(int i = 0; i < N; i++){
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());
    
    ll ans = INFL;
    for(int i = 0; i <= N - K; i++){
        ans = min(ans, h.at(i + K - 1) - h.at(i));
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 1024
/*
	Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;

#define pii pair < ll, ll >
#define vi vector < ll >
#define vvi vector < vector < ll > >
#define vpii vector < pair < ll, ll > >
#define vvpii vector < vector < pair < ll, ll > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

pii dig(ll n){
	ll num = 0, m = n;
	while(m)
		num++, m/=10;
	ll x = 1;
	for(ll i=0; i<num-1; i++)
		x = x * 10;
	return {n/x, n%10};
}

int main()
{
	ll n, count = 0;
	cin >> n;
	
	ll mat[10][10] = {0};
	for(ll i=1; i<=n; i++){
		auto x = dig(i);
		mat[x.f][x.s]++;
	}

	for(ll i=1; i<=9; i++)
		for(ll j=1; j<=9; j++)
			count += mat[i][j]*mat[j][i];
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256