akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define PrintArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;
#define PrintPairs(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i].fi <<"," << cont[__i].se<<")";} cout<<endl;
#define Print(v) cout<<v<<endl;
#define PDBG() cout<<"Line:"<<__LINE__<<endl;
#define PrintArray2D(cont, fh, th, fw, tw) for(int __i=fh;__i<th;++__i){for(int __j=fw;__j<tw;++__j) {cout<<cont[__i][__j]<<" ";} cout<<endl;}cout<<endl;
#define Resize(cont,W,V) cont.resize(W,V);
#define Resize2D(cont,H,W,V) cont.resize(H);for(int i=0;i<H;++i)cont[i].resize(W,V);
#define Resize3D(cont,H,W,D,V) cont.resize(H);for(int i=0;i<H;++i)cont[i].resize(W);for(int i=0;i<H;++i)for(int j=0;j<W;++j)cont[i][j].resize(D,V);
/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 * priority_queue<int,vector<int>, greater<int>> Q;
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
/*
struct PairComp{
    int operator()(P l, P r) const {
        return l.fi==r.fi?l.se<r.se:l.fi<r.fi;
    }
};*/
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;

int main() {
    cout.precision(15);
    cout << fixed;
    ll H,W,K;
    cin >> H >> W>> K;
    vector<string> c(H);
    REP(i,H)
        cin>>c[i];
    ll ans=0;
    for(ll i=0;i< (1<<(H+W));++i) {
        ll h=i & ((1<<(H))-1);
        ll w=i>>H;
        ll sa=0;
        for(ll y=0;y<H;++y) {
            for(ll x=0;x<W;++x) {
                if(c[y][x]=='#') {
                    if ((h>>y)&1 && (w>>x)&1) {
                        sa++;
                    }
                }
            }
        }
        if (sa==K)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include<stdio.h>

int dp[50];

int fib(int n) {
    if (n == 0 || n == 1) return dp[n] = 1;
    if ( dp[n] != -1) return dp[n];
    return dp[n] = fib(n - 1) + fib(n - 2);
}

int main(void)
{
    int n, i;
    for (i = 0;i < 50; i++) dp[i] = -1;

    scanf("%d", &n);
    printf("%d\n", fib(n));

    return 0;
}


Measured memory_bytes: 2100
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(
            Console.ReadLine()
            .Where(x => x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u')
            .Count() != 0 ? 
            "vowel" : "consonant");
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <limits>
#include <cmath>
#include <map>

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  string s2 = s.substr(0, n/2);

  cout << (s2+s2 == s ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<string> s(n);
  map<string,int> mp;
  rep(i,n){
    cin >> s.at(i);
    sort(ALL(s.at(i)));
    mp[s.at(i)]++;
  }
  ll ans = 0;
  for(auto p:mp){
    ll i = p.second;
    ans+=i*(i-1)/2;
  }
  cout << ans << endl;
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	REP(i, n) {
		cin >> v[i];
	}
	sort(ALL(v));
	cout << v[n - 1] - v[0] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String a = sc.next();
        String b = sc.next();

        System.out.println(b+a);
    }
}


Measured memory_bytes: 38892
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;

template<typename T> class segtree {
private:
    int n,sz;
    vector<T> node;
public:
    segtree(vector<T>& v) : sz((int)v.size()){
        n = 1;
        while(n < sz){
            n *= 2;
        }
        node.assign(2*n,numeric_limits<T>::min());
        for(int i = 0; i < sz; i++){
            node[i+n] = v[i];
        }
        for(int i=n-1; i>=1; i--){
            node[i] = max(node[2*i],node[2*i+1]);
        }
    }
    void update(int k,T a)
    {
        node[k+=n] = a;
        while(k>>=1){
            node[k] = max(node[2*k],node[2*k+1]);
        }
    }
    T query(int a,int b)
    {
        T res1 = numeric_limits<T>::min();
        T res2 = numeric_limits<T>::min();
        a += n, b += n;
        while(a != b){
            if(a % 2) res1 = max(res1, node[a++]);
            if(b % 2) res2 = max(res2, node[--b]);
            a >>= 1, b>>= 1;
        }
        return max(res1, res2);
    }
    void print(){
        for(int i = 0; i < sz; i++){
            cout << query(i,i+1) << " ";
        }
        cout << endl;
    }
};

int main(){
    int n;
    cin >> n;
    vector<int>h(n);
    vector<int>aa(n);
    vector<ll>a(n);
    rep(i,n){
        cin >> h[i];
        aa[i] = h[i];
    }
    rep(i,n)cin >> a[i];
    sort(aa.begin(),aa.end());
    aa.erase(unique(aa.begin(),aa.end()),aa.end());
    vector<ll>dp(n,0);
    segtree<ll>seg(dp);
    rep(i,n){
        int pos = (int)(lower_bound(aa.begin(),aa.end(),h[i])- aa.begin());
//        show(pos);
//        show(seg.query(0,pos+1));
        seg.update(pos,max(a[i],a[i] + seg.query(0,pos+1)));
    }
    cout << seg.query(0,n) << endl;
}

Measured memory_bytes: 9088
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

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

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int _mergeSort(int arr[], int temp[], int left, int right);
int merge(int arr[], int temp[], int left, int mid, int right);

int mergeSort(int arr[], int array_size)
{
    int* temp = (int*)malloc(sizeof(int) * array_size);
    return _mergeSort(arr, temp, 0, array_size - 1);
}

int _mergeSort(int arr[], int temp[], int left, int right)
{
    int mid, inv_count = 0;
    if (right > left) {
        mid = (right + left) / 2;

        inv_count = _mergeSort(arr, temp, left, mid);
        inv_count += _mergeSort(arr, temp, mid + 1, right);

        inv_count += merge(arr, temp, left, mid + 1, right);
    }
    return inv_count;
}

int merge(int arr[], int temp[], int left, int mid, int right)
{
    int i, j, k;
    int inv_count = 0;

    i = left; /* i is index for left subarray*/
    j = mid; /* j is index for right subarray*/
    k = left; /* k is index for resultant merged subarray*/
    while ((i <= mid - 1) && (j <= right)) {
        if (arr[i] <= arr[j]) {
            temp[k++] = arr[i++];
        }
        else {
            temp[k++] = arr[j++];

            inv_count = inv_count + (mid - i);
        }
    }

    while (i <= mid - 1)
        temp[k++] = arr[i++];

    while (j <= right)
        temp[k++] = arr[j++];

    for (i = left; i <= right; i++)
        arr[i] = temp[i];

    return inv_count;
}

signed main() {
    int n, k;
    cin >> n >> k;

    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        A[i] = a - k;
    }

    int S[n+1];
    fill(S, S + n + 1, 0);
    for (int i = 0; i < n; i++) {
        S[i+1] = S[i] + A[i];
    }

    int inversion = mergeSort(S, n + 1);

    cout << n * (n + 1) / 2 - inversion << endl;

    return 0;
}

Measured memory_bytes: 4992
import numpy as np
x1, y1, x2, y2 = map(int, input().rstrip().split())
a = complex(x1, y1)
b = complex(x2, y2)
length = abs(a-b)
c = (a-b) * complex(np.cos(-np.pi/2), np.sin(-np.pi/2)) + b
x3 = int(np.round(c.real))
y3 = int(np.round(c.imag))
d = (b-a) * complex(np.cos(np.pi/2), np.sin(np.pi/2)) + a
x4 = int(np.round(d.real))
y4 = int(np.round(d.imag))
print(x3, y3, x4, y4)


Measured memory_bytes: 12496
s = input()

if("01" <= s[0]+s[1] <= "12"):
    if("01" <= s[2]+s[3] <= "12"):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if("01" <= s[2]+s[3] <= "12"):
        print("YYMM")
    else:
        print("NA")

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

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

    vector<ll> p(n);
    vector<ll> mi(n);

    rep(i,n){
        cin>>p.at(i);
        if(i==0){
            mi.at(i) = p.at(i);
        }else{
            mi.at(i) = min(p.at(i),mi.at(i-1));
        }
    }

    ll co=0;
    rep(i,n){
        if(p.at(i)<=mi.at(i)){
            co++;
        }
    }

    cout<<co<<endl;

}



Measured memory_bytes: 3328
#include <stdio.h>
#include <queue>
#include <algorithm>

using namespace std;

int A[1005][1005];
int cur[1005];
bool visit[1005];

struct element
{
	int idx1;
	int idx2;
	int time;
};

bool operator<(const element &a, const element &b)
{
	return a.time > b.time;
}

priority_queue<element> pq;

int main()
{
	int N;

	scanf("%d", &N);

	for (int i = 1; i <= N; ++i)
	{
		for (int j = 0; j < N - 1; ++j) scanf("%d", &A[i][j]);
	}

	for (int i = 1; i <= N; ++i)
	{
		if (visit[i]) continue;
		visit[i] = true;

		int target = A[i][cur[i]];
		
		if (!visit[target] && A[target][cur[target]] == i)
		{
			pq.push({ min(target, i), max(target, i), 1 });
			visit[target] = true;
		}
	}
	
	int remain = N*(N - 1);
	int last_time = 0;

	while(!pq.empty())
	{
		int idx1 = pq.top().idx1;
		int idx2 = pq.top().idx2;
		int time = pq.top().time;
		pq.pop();
		
		last_time = time;
		remain -= 2;

		cur[idx1]++;
		cur[idx2]++;

		if (cur[idx1] < N - 1)
		{
			int target = A[idx1][cur[idx1]];

			if (cur[target] < N - 1 && A[target][cur[target]] == idx1) pq.push({ min(target, idx1), max(target, idx1), time + 1 });
		}
		if (cur[idx2] < N - 1)
		{
			int target = A[idx2][cur[idx2]];

			if (cur[target] < N - 1 && A[target][cur[target]] == idx2) pq.push({ min(target, idx2), max(target, idx2), time + 1 });
		}
	}

	if (remain == 0) printf("%d\n", last_time);
	else printf("-1\n");

	return 0;
}

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

int main(){
  int n;
  cin >>n;
  vector<vector<int>>vec(2,vector<int>(n));
  for (int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin >> vec.at(i).at(j);
    }
  }
  int p=0;
  for(int i=0;i<n;i++){
    int sum1=0;
    int sum2=0;
    int sum=0;
    for(int j=0;j<n;j++){
      if(i>=j){
        sum1+=vec.at(0).at(j);
      }
      if(i<=j){

      sum2+=vec.at(1).at(j);
      }
    }
    sum=sum1+sum2;
    p=max(p,sum);
  }
  cout << p <<endl;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(Math.min(a + b, Math.min(b + c, c + a)));
	}
}


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

int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    vector<ll>X(N);
    vector<ll>H(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> H[i];
    }
    vector<pair<ll, ll>>v(N);
    for (int i = 0; i < N; ++i) {
        v[i] = make_pair(X[i], H[i]);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < N; ++i) {
        X[i] = v[i].first;
        H[i] = v[i].second;
    }

    ll ans = 0;
    ll bomb = 0;
    ll left = X[0] - 1;
    queue<pair<ll, ll>>que;
    for (int i = 0; i < N; ++i) {
        while (! que.empty()) {
            if (que.front().first < X[i]) {
                bomb -= que.front().second;
                que.pop();
            } else {
                break;
            }
        }
        H[i] -= bomb * A;
        ll dist = X[i] + D + D;
        if (H[i] <= 0) continue;
        ll b = H[i] / A;
        if (H[i] % A) b++;
        bomb += b;
        ans += b;
        que.push(make_pair(dist, b));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8192
//***********************************************************//
    #include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //*********************************************************//





    int main()
    {

    IOS;
 int a,b;
    cin>>a>>b;
    if(a<=8 && b<=8 ){cout<<"Yay!";}
    else {cout<<":(";}

    return 0;
     }



Measured memory_bytes: 3524
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

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

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

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

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

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

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

int H[200];

main()
{
	IOS
	
	int n;
	cin >> n;
	
	int nr = 0;
	
	while(n--)
	{
		int x;
		cin >> x;
		
		if(H[x] == 0)
			nr++;
		
		H[x] = 1;
	}
	
	cout << nr;
}

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

int main()
{
    int a,b,c,sol=0,x,y,z;
    cin>>a>>b>>c;
    x=max(a,b)-min(a,b);
    y=max(a,c)-min(a,c);
    z=max(b,c)-min(b,c);
    sol=x+y+z-max(max(x,y),z);
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
player_num,first_point,q = gets.chomp.split.map(&:to_i)
a = []
q.times{ a << gets.to_i }

players_points = Array.new(player_num, first_point)

def p_winner arr
  arr.each do |point|
    puts point.positive? ? "Yes" : "No"
  end
end

def move_round players_points, a
  players_points.map!{|i| i - a.length}
  a.each do |ansered_player_index|
    players_points[ansered_player_index - 1] = players_points[ansered_player_index - 1] + 1
  end
  return players_points
end

p_winner move_round(players_points, a)

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

using namespace std;

int main() {
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> ref(a);
	vector<int> mic(b);
	for (int i = 0; i < a; i++) {
		cin >> ref[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> mic[i];
	}
	vector<int> x(m);
	vector<int> y(m);
	vector<int> c(m);
	int j = *min_element(ref.begin(), ref.end());
	int h = *min_element(mic.begin(), mic.end());
	int ans = h + j;
	for (int i = 0; i < m; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		x--, y--;
		ans = min(ans, ref[x] + mic[y] - c);
	}
	cout << ans;
}

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

int main() {
  
  string a,b,c;
  cin >> a >> b >> c;
  
  char x = a[0] - 32;
  char y = b[0] - 32;
  char z = c[0] - 32;
  
  cout << x << y << z << endl;
  
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int64_t gcd(int64_t m, int64_t n) {
  int64_t tmp;
  while (m % n != 0) {
    tmp = n;
    n = m % n;
    m = tmp;
  }
  return n;
}
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }

int main(void) {
  ios::sync_with_stdio(false);
  int64_t A, B;
  cin >> A >> B;
  int64_t ans = lcm(A, B);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		while(true) {
		    //高橋君の体力
		    C -= B;
		    if(C<=0) {
		        System.out.println("Yes");
		        break;
		    }
		    //青木君の体力
		    A -= D;
		    if(A<=0){
		        System.out.println("No");
		        break;
		    }
		}
		    
		    
    }
}

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

#define N 100

int main(){
int unp[N][N];
int n,u,k,v,i,j;

scanf("%d",&n);

for(i=0;i<n;i++){
  for(j=0;j<n;j++) unp[i][j]=0;
}

for(i=0;i<n;i++){
  scanf("%d %d",&u,&k);
  u--;

  for(j=0;j<k;j++){
    scanf("%d",&v);
    v--;
    unp[u][v]=1;
  }
}

for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    if(j) cout << " ";
    cout << unp[i][j];
  }
  printf("\n");
}



  return 0;
}



Measured memory_bytes: 3244
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int K = int.Parse(str[1]);
        int L = int.Parse(str[2]);
        int[] P1 = new int[K];
        int[] Q1 = new int[K];
        int[] P2 = new int[L];
        int[] Q2 = new int[L];
        UnionFind U1 = new UnionFind(N);
        for(int i=0;i<K;i++){
            str = Console.ReadLine().Split(' ');
            int p = int.Parse(str[0])-1;
            int q = int.Parse(str[1])-1;
            P1[i] = p;
            Q1[i] = q;
            U1.Union(p,q);
        }
        UnionFind U2 = new UnionFind(N);
        for(int i=0;i<L;i++){
            str = Console.ReadLine().Split(' ');
            int p = int.Parse(str[0])-1;
            int q = int.Parse(str[1])-1;
            P2[i] = p;
            Q2[i] = q;
            U2.Union(p,q);
        }
        int[] a = new int[N];
        for(int i=0;i<N;i++){
            a[i] = i;
        }
        int[] u1 = new int[N];
        int[] u2 = new int[N];
        for(int i=0;i<N;i++){
            u1[i] = U1.Get(i);
            u2[i] = U2.Get(i);
        }
        Array.Sort(a,(x,y)=>(u1[x] > u1[y]) ? 1 : (u1[x] == u1[y] ? (u2[x] - u2[y]) : -1));
        int[] b = new int[N];
        {
            int i = 0;
            int count = 1;
            while(i != N){
                while(i != N-1 && u1[a[i]] == u1[a[i+1]] && u2[a[i]] == u2[a[i+1]]){
                    count++;
                    i++;
                }
                for(int j=i-count+1;j<=i;j++){
                    b[a[j]] = count;
                }
                count = 1;
                i++;
            }
        }
        for(int i=0;i<N;i++){
            sb.Append(b[i]+" ");
        }
        sb.Append("\n");
    }
}
class UnionFind{
    public int[] par;
    public UnionFind(int n){
        par = new int[n];
        for(int i=0;i<n;i++){
            par[i] = i;
        }
    }
    public void Union(int x,int y){
        par[Get(x)] = Get(y); 
    }
    public bool Same(int x,int y){
        return Get(x) == Get(y);
    }
    public int Get(int x){
        if(x != par[x]){
            par[x] = Get(par[x]);
        }
        return par[x];
    }
}

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

int main() {
 long long a,b;
 long long tes=2;
 vector<long long> vec1;
 vector<long long> vec2;
 cin>>a>>b;
 while(a>=tes*tes){
     if(a%tes==0){
         vec1.push_back(tes);
         a/=tes;
     }
     else{
         tes++;
     }
 }
 vec1.push_back(a);
 tes=2;
 while(b>=tes*tes){
     if(b%tes==0){
         vec2.push_back(tes);
         b/=tes;
     }
     else{
         tes++;
     }
 }
 vec2.push_back(b);
 long long ret=1;
 rep(i,vec1.size()){
    ret*=vec1.at(i);
 }
 rep(i,vec2.size()){
     bool f=true;
     rep(j,vec1.size()){
         if(vec2.at(i)==vec1.at(j)){
             f=false;
             vec1.at(j)=0;
             break;
         }
     }
     if(f){
         ret*=vec2.at(i);
     }

 }
 cout<<ret<<endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

int main(void){
    int n,debt;
    debt=100000;
    std::cin>>n;
    while(n--){
        debt*=1.05;
        if(debt%1000){
            debt+=1000-debt%1000;    
        }
    }
    std::cout<<debt<<std::endl;
    return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  long double per=0;
  rep(i,0,N){
    sum=0;
    num=i+1;
    while(num<K){
      num*=2;
      sum++;
    }
    per+=(long double)1.0/(N*repow(2,sum,INF));   
  }
  HpOut(per);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)

mod=int(1e9+7)
n,k=map(int,input().split())
g=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1; b-=1
  g[a].append(b); g[b].append(a);
 
dp=[-1 for x in range(n)]
def f(v,p):
  if dp[v]!=-1:
    return dp[v]

  dp[v]=1
  j=1+int(v!=0)
  for i in g[v]:
    if i!=p:
      dp[v]=(dp[v]*f(i,v)*max(k-j,0))%mod
      j+=1
  return dp[v]
 
print(f(0,-1)*k%mod)

Measured memory_bytes: 88172
#include<bits/stdc++.h>
using namespace std;
long long int f(long long int x)
{
    if(x==1)
    {
        return 1;
    }
    else
    {
        return 1+2*f(x/2);
    }
    
}
int main()
{
    long long int a;
    cin>>a;
    cout<<f(a)<<endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,k=map(int,input().split())

if(k%2==0):
  if abs(a-b)<10**18:
    print(a-b)
  else:
    print("Unfair")
else:
  if abs(a-b)<10**18:
    print(b-a)
  else:
    print("Unfair")

Measured memory_bytes: 2940
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	long long a;scanf("%lld",&a);
	long long b=1;
	long long ret=0;
	while(a){
		ret+=b;
		a/=2;
		b*=2;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N, L; cin >> N >> L;
    vector<int> v(N);
    int sum = 0;
    for(int i=0; i<N; i++) {
        v[i] = L + i;
        sum += v[i];
    }

    int mi = 1 << 28, ans = -1;
    for(int i=0; i<N; i++) {
        int v1 = sum;
        int v2 = sum - v[i];
        int diff = abs(v1 - v2);
        if(mi > diff) {
            mi = diff;
            ans = v2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
        "sort"
)

func solution(n int, v []int) float64 {
        sort.Ints(v)
        out := float64(v[0])
        for i := 1; i < n; i++ {
                out = (out + float64(v[i])) / 2
        }
        return out
}

func main() {
        var n int
        fmt.Scan(&n)

        v := make([]int, 0, n)
        for i := 0; i < n; i++ {
                t := 0
                fmt.Scan(&t)
                v = append(v, t)
        }
        fmt.Println(solution(n, v))
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            Dictionary<string,int> valList = new Dictionary<string, int>();
            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();
                if (valList.ContainsKey(s))
                {
                    valList[s]++;
                }
                else
                {
                    valList.Add(s,1);
                }
            }
            var M = int.Parse(Console.ReadLine());
            for (int i = 0; i < M; i++)
            {
                var s = Console.ReadLine();
                if (valList.ContainsKey(s))
                {
                    valList[s]--;
                }
                else
                {
                    valList.Add(s, -1);
                }
            }

            if (valList.Values.Max() >= 0)
            {
                Console.WriteLine(valList.Values.Max());

            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}

Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  
  int L, R;
  cin >> L >> R;
  if (L / 2019 != R / 2019){
    L %= 2019;
    R %= 2019;
    R += 2019;
  }
  if (L / 2019 == R / 2019){
    L %= 2019;
    R %= 2019;
  }
  int ans = 2020;
  
  for (int i = L; i < R; i++) {
    for (int j = R; j > i; j--) {
      ans = min(ans, (i * j) % 2019);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void swap(long *a , long *b) {
	long tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int main () {
	long n , a , b , c;
	long i;
	scanf("%ld" , &n);
	for(i = 0; i < n; i++) {
		scanf("%ld %ld %ld" , &a , &b , &c);

		if (a < b) swap(&a , &b);
		if (a < c) swap(&a , &c);
		if (b < c) swap(&b , &c);

		if (b * b + c * c == a * a) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
//18:32

#include<stdio.h>

int main(){
  int ans = 0;
  char s[100];

  scanf("%s", s);

  for(int i=0; i<4; i++){
    if(s[i] == '+'){
      ans++;
    }
    else if(s[i] == '-'){
      ans--;
    }
  }
  
  printf("%d\n", ans);

  return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		long ans = 0;
		int[] sumr = new int[N+1];
		int[] sumg = new int[N+1];
		int[] sumb  = new int[N+1];
		for(int i = 1; i <= N; i++) {
			sumr[i] = sumr[i-1];
			sumg[i] = sumg[i-1];
			sumb[i] = sumb[i-1];
			if(S.charAt(i-1) == 'R')
				sumr[i]++;
			else if(S.charAt(i-1) == 'G')
				sumg[i]++;
			else
				sumb[i]++;
		}
		for(int i = 0; i < N; i++) {
			if(S.charAt(i) == 'R') {
				for(int j = i+1; j < N; j++) {
					if(S.charAt(j) == 'G') {
						ans += sumb[N] - sumb[j];
						if(2*j-i < N)
							if(S.charAt(2*j-i) == 'B')
								ans--;
					}
					else if(S.charAt(j) == 'B') {
						ans += sumg[N] - sumg[j];
						if(2*j-i < N)
							if(S.charAt(2*j-i) == 'G')
								ans--;
					}
				}
			}
			else if(S.charAt(i) == 'G') {
				for(int j = i+1; j < N; j++) {
					if(S.charAt(j) == 'R') {
						ans += sumb[N] - sumb[j];
						if(2*j-i < N)
							if(S.charAt(2*j-i) == 'B')
								ans--;
					}
					else if(S.charAt(j) == 'B') {
						ans += sumr[N] - sumr[j];
						if(2*j-i < N)
							if(S.charAt(2*j-i) == 'R')
								ans--;
					}
				}
			}
			else {
				for(int j = i+1; j < N; j++) {
					if(S.charAt(j) == 'R') {
						ans += sumg[N] - sumg[j];
						if(2*j-i < N)
							if(S.charAt(2*j-i) == 'G')
								ans--;
					}
					else if(S.charAt(j) == 'G') {
						ans += sumr[N] - sumr[j];
						if(2*j-i < N)
							if(S.charAt(2*j-i) == 'R')
								ans--;
					}
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 39364
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

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

    int n;
    cin >> n;
    int sz = n * n;
    vector<int> p(sz);
    for(int i = 0; i < sz; ++i) cin >> p[i];
    vector<P> pos(sz + 1);
    int cur = 1;
    vector<vector<int>> board(n, vector<int>(n));
    vector<vector<int>> dist(n, vector<int>(n, INF));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            board[i][j] = cur;
            pos[cur++] = P(i, j);
            chmin(dist[i][j], min({i, j, n - 1 - i, n - 1 - j}));
        }
    }
    
    int ans = 0;
    for(int val : p){
        int sx = pos[val].first, sy = pos[val].second;
        ans += dist[sx][sy]--;
        board[sx][sy] = 0;
        deque<P> deq;
        deq.push_back(P(sx, sy));
        while(!deq.empty()){
            P point = deq.front();
            deq.pop_front();
            int x = point.first, y = point.second;
            for(int i = 0; i < 4; ++i){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx < 0 || nx >= n || ny < 0 || ny >= n)  continue;
                if(board[nx][ny]){
                    if(dist[nx][ny] > dist[x][y] + 1){
                        dist[nx][ny] = dist[x][y] + 1;
                        deq.push_back(P(nx, ny));
                    }
                }
                else{
                    if(dist[nx][ny] > dist[x][y]){
                        dist[nx][ny] = dist[x][y];
                        deq.push_front(P(nx, ny));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {

    //dice????????????????????????????????????
    dice dice = new dice();

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    //??¢?????°?????\???(num[1]???????????????1)
    String num[] = br.readLine().split("[\\s]+");
    for (int i = 0; i < num.length ; i++) {
      dice.diceNum[i+1] = Integer.parseInt(num[i]);
    }

    //????????\???
    String oder[] = br.readLine().split("");

    //???????????°(???????????°)??°?????????
    for (int i = 0; i < oder.length; i++) {
      //??????????????£?????????????????????
      if (oder[i].equals("N")) {
        dice.oderN();
      } else if (oder[i].equals("W")) {
        dice.oderW();
      } else if (oder[i].equals("E")) {
        dice.oderE();
      } else if (oder[i].equals("S")){
        dice.oderS();
      }
    }

    //?????¨??£??¢?????°????????????
    System.out.println(dice.diceNum[1]);

  }

}

class dice {
  //??????????????¢?????????0???6,0???????????????
  int diceNum[] = new int[7];
  //????????¨?????°
  int stoc;

  //N???????????¢???????????¨???
  public void oderN() {
    //1?????¢?????°????????????
    stoc = diceNum[1];
    //1????????£?????¢???2?????????
    diceNum[1] = diceNum[2];
    //2????????£?????¢???6?????????
    diceNum[2] = diceNum[6];
    //6????????£?????¢???5?????????
    diceNum[6] = diceNum[5];
    //5????????£?????¢???1?????????
    diceNum[5] = stoc;

  }

  //W???????????¢??????
  public void oderW() {

    stoc = diceNum[1];
    diceNum[1] = diceNum[3];
    diceNum[3] = diceNum[6];
    diceNum[6] = diceNum[4];
    diceNum[4] = stoc;

  }

  //E???????????¢??????
  public void oderE() {

    stoc = diceNum[1];
    diceNum[1] = diceNum[4];
    diceNum[4] = diceNum[6];
    diceNum[6] = diceNum[3];
    diceNum[3] = stoc;

  }

  //S???????????¢??????
  public void oderS() {

    stoc = diceNum[1];
    diceNum[1] = diceNum[5];
    diceNum[5] = diceNum[6];
    diceNum[6] = diceNum[2];
    diceNum[2] = stoc;

  }

}

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

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		String s = in.readString();
		String s1 = in.readString();
		String compare = new StringBuilder(s).reverse().toString();
		if(compare.equals(s1)) System.out.println("YES");
		else System.out.println("NO");
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
signed main()
{
    int k;
    cin >> k;
    int cnt = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <=k; j++)
        {
            for (int l = 1; l <= k; l++)
            {
                int x = gcd(i, j);
                cnt += gcd(x, l);
            }
        }
        
    }
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	
	while ( scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
		
	}
	
	printf("%d\n", pop());

	return 0;
}


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int n,m;
  cin >> n;
  double p;
  if (n%2){
    m=(n/2)+1;
    p=(double)m/(double)n;
  }else{
    p=1.0/2.0;
  }
  cout << p << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n;
    cin>>n;
    vector<int> v(n),dp(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    dp[0]=0,dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    cout<<dp[n-1]<<'\n';
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
        while (!(line = br.readLine()).equals("-")) {
            String s = line;
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                int m = Integer.parseInt(br.readLine());
                s = s.substring(m, s.length()) + s.substring(0, m);
            }
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 24352
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const LR = arg.slice(1, M + 1);
    let low  = parseInt(LR[0].split(" ")[0]);
    let high = parseInt(LR[0].split(" ")[1]);
    
    for(let i in LR) {
        let L = parseInt(LR[i].split(" ")[0]);
        let R = parseInt(LR[i].split(" ")[1]);
        
        if(high < L) {
            console.log(0);
            return;
        }
        
        if(low > R) {
            console.log(0);
            return;
        }
        
        if(low < L) {
            low = L;
        }
        
        if(high > R) {
            high = R;
        }
    }

    
    console.log((high - low) + 1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 38192
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <iomanip>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

ll combination(int n, int r){
	if(n == r || r == 0) return 1;
	return combination(n, r - 1) * (n - r + 1) / r;
}

ll n, a, b, v[51] = {};

int main() {
	cin >> n >> a >> b;
	for(int i = 0;i < n;i++){
		cin >> v[i];
	}
	sort(v, v + n);

	double ave = 0.0;
	for(int i = 0;i < a;i++){
		ave += v[n - 1 - i];
	}
	ave /= (double)a;

	cout << fixed << setprecision(10);
	cout << ave << endl;

	ll ans = 0;
	if(v[n - 1] == v[n - a]){
		ll howMax = 0;
		for(int i = 0;i < n;i++){
			if(v[i] == v[n - 1]) howMax++;
		}
		for(int i = a;i <= min(howMax, b);i++){
			ans += combination(howMax, i);
		}
	}else{
		ll howN = 0, howR = 0;
		for(int i = 0;i < n;i++){
			if(v[n - a] == v[i]) howN++;
		}
		for(int i = n - a;i < n;i++){
			if(v[n - a] == v[i]) howR++;
		}
		ans = combination(howN, howR);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s.at(i);
    int f = 0;
    rep(i, n-1){
        if(s.at(i).at(s.at(i).size()-1) != s.at(i+1).at(0)) f = 1;
    }
    sort(s.begin(), s.end());
    rep(i, n-1){
        if(s.at(i) == s.at(i+1)) f = 1;
    }
    if(f == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256