akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#define MN 101000

typedef long long ll;

int h[MN], nxt[2 * MN], to[2 * MN], K = 0;
int Max[MN], cMax[MN], Max2[MN], c[MN], cnt[MN], deg[MN];
ll mul[MN];
int d[MN], q[MN], hh = 0, tt = 0, d2[MN];
int n;

void ins(int u, int v) {nxt[++K] = h[u]; h[u] = K; to[K] = v;}

void bfs(int S)
{
	memset(d, -1, sizeof(d));
	d[S] = 0; q[tt++] = S;
	while(hh < tt)
	{
		int u = q[hh++];
		for(int i = h[u]; i; i = nxt[i])
		{
			if(d[to[i]] == -1)
			{
				d[to[i]] = d[u] + 1;
				q[tt++] = to[i];
			}
		}
	}
}

void dfs1(int x, int fa, int col)
{
	if(c[d[x]] != col)
	{
		if(deg[x] - 1 >= Max[d[x]]) c[d[x]] = col, cMax[d[x]] = Max[d[x]], Max[d[x]] = deg[x] - 1;
		else cMax[d[x]] = std::max(cMax[d[x]], deg[x] - 1);
	}
	else Max[d[x]] = std::max(Max[d[x]], deg[x] - 1);
	for(int i = h[x]; i; i = nxt[i]) if(to[i] != fa) dfs1(to[i], x, col);
}

int Max_dep = 0;

void dfs2(int x, int fa)
{
	Max_dep = std::max(Max_dep, d[x]);
	Max2[d[x] - 1] = std::max(Max2[d[x] - 1], deg[x] - 1);
	for(int i = h[x]; i; i = nxt[i]) if(to[i] != fa) dfs2(to[i], x);
}

int main()
{
	scanf("%d", &n); if(n == 2) return 0 * puts("1 2");
	for(int i = 0; i <= n; i++) Max[i] = cMax[i] = Max2[i] = 1;
	for(int i = 1; i < n; i++)
	{
		int u, v; scanf("%d%d", &u, &v);
		ins(u, v); ins(v, u); deg[u]++; deg[v]++;
	}
	bfs(1); int x = 0;
	for(int i = 1; i <= n; i++) if(!x || d[i] > d[x]) x = i;
	bfs(x); x = 0; memcpy(d2, d, sizeof(d));
	for(int i = 1; i <= n; i++) if(!x || d[i] > d[x]) x = i;
	int w = d[x]; bfs(x); int son = 0; x = 0; 
	for(int i = 1; i <= n; i++)
		if(d[i] + d2[i] == w && (d[i] == w / 2 || d2[i] == w / 2)) 
		{
			if(!x) x = i;
			else if(w & 1) son = i;
		}
	bfs(x); int o = 0;
	for(int i = h[x]; i; i = nxt[i]) dfs1(to[i], x, ++o);
	mul[n] = 1; for(int i = n - 1; i >= 1; i--) mul[i] = mul[i + 1] * Max[i];
	o = 0; long long ans = 1e18;
	for(int i = h[x]; i; i = nxt[i])
	{
		++o;
		if(son && to[i] != son) continue; 
		Max_dep = 0; dfs2(to[i], x);
		ll now = 1;
		for(int j = 1; j <= Max_dep; j++)
		{
			if(c[j] == o) now *= std::max(Max2[j], cMax[j]);
			else now *= std::max(Max2[j], Max[j]); 
		}
		now = now * mul[Max_dep + 1] * 2 * std::max(deg[to[i]] - 1, deg[x] - 1);
		ans = std::min(ans, now);
		if(son) return 0 * printf("%d %lld\n", w / 2 + 1, now);
		for(int j = 0; j <= Max_dep; j++) Max2[j] = 1;
	}
	ans = std::min(ans, mul[1] * deg[x]);
	printf("%d %lld\n", w / 2 + 1, ans);
}

Measured memory_bytes: 5120
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        int N,A,B;
        Scanner input;
        input = new Scanner(System.in);
        N = input.nextInt();
        A = input.nextInt();
        B = input.nextInt();
        int ans = 0;
        for (int i = 1; i <= N; i++){
          String tmp = String.valueOf(i);
          String[] sa = tmp.split("");
          int[] ia = Stream.of(sa).mapToInt(Integer::parseInt).toArray();
          int sum = java.util.Arrays.stream(ia).sum();
          if (A <= sum && sum <= B){
            ans += i;
          }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 42472
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
  int x=0,y=0,z=1,n=0,m=0,w=0;
  std::cin >> x>>y;
  rep(i,x){
    if(z<y){
      z*=2;
    }else{
      z+=y;
    }
  }
  std::cout << z << '\n';
}


Measured memory_bytes: 256
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
// #pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);





// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(n)
    ll arr[n+1]={0};
    f(i,2,n+1)
    {
        read(x)
        arr[x]++;
    }
    f(i,1,n+1) cout<<arr[i]<<" ";
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 5224
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

set<string> s;
vector<string> v;
map<string, int> cnt;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n, mx = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        if (cnt[tmp] == 0) {
            v.push_back(tmp);
        }
        cnt[tmp]++;
        mx = max(mx, cnt[tmp]);
    }
    for (auto i : v) {
        if (cnt[i] == mx) {
            s.insert(i);
        }
    }
    for (auto i : s) {
        cout << i << '\n';
    }
    return 0;
}


Measured memory_bytes: 36080
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main(){
    cout<<fixed<<setprecision(10);
    ll n,k,count;
    ll score;
    double rate = 0;
    cin>>n>>k;
    rep(i,n){
        score = i+1;
        count = 0;
        while(score<k){
            score *=2;
            count++;
        }
        // cout<<1/(n*pow(2,count))<<endl;
        rate = rate + 1/(n*pow(2,count));
        // cout<<score<<" "<<count<<" "<<rate<<endl;
    }
    cout<<rate<<endl;
    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;

  auto nodes = new BiNode[](n);
  foreach (_; n.iota) {
    auto rd = readln.split.to!(int[]), id = rd[0], l = rd[1], r = rd[2];
    nodes[id] = new BiNode(id, l, r);
  }

  foreach (node; nodes) {
    if (node.l != -1) nodes[node.l].parent = node.id;
    if (node.r != -1) nodes[node.r].parent = node.id;
  }

  auto root = nodes.find!(node => node.isRoot).front;

  writeln("Preorder");
  writeln(" ", preorderWalk(nodes, root).to!(string[]).join(" "));
  writeln("Inorder");
  writeln(" ", inorderWalk(nodes, root).to!(string[]).join(" "));
  writeln("Postorder");
  writeln(" ", postorderWalk(nodes, root).to!(string[]).join(" "));
}

int[] preorderWalk(BiNode[] nodes, BiNode node)
{
  int[] r;
  r ~= [node.id];
  if (node.l != -1) r ~= preorderWalk(nodes, nodes[node.l]);
  if (node.r != -1) r ~= preorderWalk(nodes, nodes[node.r]);
  return r;
}

int[] inorderWalk(BiNode[] nodes, BiNode node)
{
  int[] r;
  if (node.l != -1) r ~= inorderWalk(nodes, nodes[node.l]);
  r ~= [node.id];
  if (node.r != -1) r ~= inorderWalk(nodes, nodes[node.r]);
  return r;
}

int[] postorderWalk(BiNode[] nodes, BiNode node)
{
  int[] r;
  if (node.l != -1) r ~= postorderWalk(nodes, nodes[node.l]);
  if (node.r != -1) r ~= postorderWalk(nodes, nodes[node.r]);
  r ~= [node.id];
  return r;
}

class BiNode
{
  int id;
  int parent;
  int l, r;

  this(int id, int l, int r)
  {
    this.id = id;
    this.parent = -1;
    this.l = l;
    this.r = r;
  }

  bool isRoot()
  {
    return parent == -1;
  }
}

Measured memory_bytes: 2496
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        bool odd = false;
        long ans = 0;
        int min = int.MaxValue;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < 0)
            {
                odd = !odd;
                a[i] = -a[i];
            }
            ans += a[i];
            min = Math.Min(min, a[i]);
        }
        Console.WriteLine(odd ? ans - 2 * min : ans);
    }
}

Measured memory_bytes: 29020
"use strict";
const Main = function(input){
	let xs = input.trim().split(' ');
    let z = xs[1].split('');
    let a = xs[0].split('').reverse();
    let b = xs[1].split('').reverse();
    let c = xs[2].split('');
    
    if(a[0] == z[0] && b[0] == c[0]){
      console.log('YES');
    }else{
      console.log('NO');
    }
  
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

using namespace std;

typedef long long ll;

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

void left_turn(int &idx, vector<char> &ans, const string &S, const int N) {
    // printf("left_turn start, idx: %d\n", idx);
    while (idx < N) {
        if (S[idx] == ')') {
            idx++;
            break;
        } else {
            ans.push_back('(');
            idx++;
            left_turn(idx, ans, S, N);
            ans.push_back(')');
        }
    }
    // printf("left_turn end, idx: %d\n", idx);
}

void solve(vector<char> &ans, const string &S, const int N) {
    int idx = 0;
    while (idx < N) {
        if (S[idx] == '(') {
            ans.push_back('(');
            idx++;
            left_turn(idx, ans, S, N);
            ans.push_back(')');
        } else {
            idx++;
            ans.insert(ans.begin(), '(');
            ans.push_back(')');
        }
    }
}

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

    string S;
    cin >> S;

    vector<char> ans;
    solve(ans, S, N);

    for (int i = 0; i < (int) ans.size(); i++) {
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    string s=stin();
    vec a(n+1),sum(n+1);
    sum[0]=0;
    rep(i,n){
        a[i+1]=s.at(i)=='#'?1:0;
        if(a[i+1]==1)sum[i+1]=sum[i]+1;
        else sum[i+1]=sum[i];
    }
    int ans=INT_MAX;
    rep2(i,0,n){
        ans=min(ans,sum[i]+(n-i)-(sum[n]-sum[i]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#include <queue>
using namespace std;
using P = pair<int, int>;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int N, M;
bool used[55][55];
vector<string> table;
bool dfs(int y, int x, int cnt, int dir)
{
    if(y == 0 and x == 0 and cnt == 3) return true;
    dir = (dir + 3) % 4;
    for(int i = 0; i < 4; i++)
    {
        int ny = y + dy[(dir + i) % 4];
        int nx = x + dx[(dir + i) % 4];
        if(ny < 0 or nx < 0 or ny >= N or nx >= M) continue;
        if(table[ny][nx] == '#' or used[ny][nx]) continue;

        if(y == N - 1 and x == 0) cnt++;
        if(y == N - 1 and x == M - 1) cnt++;
        if(y == 0 and x == M - 1) cnt++;
        used[ny][nx] = true;
        if(dfs(ny, nx, cnt, (dir + i) % 4)) return true;
    }
    return false;
}
signed main(void)
{
    while(cin >> N >> M, N or M)
    {
        table.resize(N);
        memset(used, false, sizeof(used));
        for(int i = 0; i < N; i++) cin >> table[i];
        //↓ start
        if(dfs(0, 0, 0, 0)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3268
#ifdef LOCAL_EXEC
#include "include.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define trace(...)
#endif

using LL = long long;

const LL MOD = 998244353;

LL modpow(LL a, LL n) {
	LL res = 1;
	for (; n > 0; n >>= 1) {
		if (n & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
	}
	return res;
}

const int N = 1e7 + 1;
LL fact[N], inv[N];
LL choose(int n, int r) {
	return (fact[n] * ((inv[r] * inv[n - r]) % MOD)) % MOD;
}

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

	fact[0] = inv[0] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv[i] = modpow(fact[i], MOD - 2);
	}

	int n; cin >> n;
	LL rem = 0;
	for (int i = n / 2 + 1; i <= n; i++) {
		rem += (choose(n, i) * modpow(2, n - i + 1)) % MOD;
	}
	LL ans = (modpow(3, n) + MOD - (rem % MOD)) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

int main() {
  int H,W;
  cin>>H>>W;
  string s;
  getline(cin,s);
  rep(j,H){
    getline(cin,s);
    rep(i,2){cout<<s<<endl;}
  }
  
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin >> arr[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1])
        ,dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout << dp[n-1];
    return 0;
   // return dp[n-1];

}

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

int	main() {
	int N;
	cin >>N;
	long S0=0;
	long S1=0;
	long T0=0;
	long T1=0;
	for (int i=0; i<N; i++) {
		long a;
		cin >>a;
		S0 +=a;
		S1 +=a;
		if (0==i%2) {
			if (0>=S0) {
				S0=1-S0;
				T0 +=S0;
				S0=1;
			}
			if (0<=S1) {
				S1=S1+1;
				T1 +=S1;
				S1=-1;
			}
		} else {
			if (0<=S0) {
				S0=S0+1;
				T0 +=S0;
				S0=-1;
			}
			if (0>=S1) {
				S1=1-S1;
				T1 +=S1;
				S1=1;
			}
		}
	}
	cout <<min(T0, T1) <<endl;
	return 0;
};


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {

        // 入力
        long[] nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];

        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++)
        {
            long[] tmp = Console.ReadLine().Split().Select(long.Parse).ToArray();
            a[i] = tmp[0];
            b[i] = tmp[1];
        }

        Array.Sort(a, b);
        long count = 0;
        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            count += b[i];
            if (count < m)
            {
                ans += a[i] * b[i];
            }
            else if (count == m)
            {
                ans += a[i] * b[i];
                break;
            }
            else
            {
                ans += a[i] * (m - (count - b[i]));
                break;
            }
        }

        Console.WriteLine(ans);
    }
}


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

int main() {
    int N,A,a,counter,ans =0;
    cin >> N;
    ans = 10000;

    for (int i = 0; i < N; i++)
    {
        cin >> A;
        a = A;
        if (A % 2 == 0){
            while (a % 2 == 0)
            {
                ++counter;
                a = a / 2;
            }
        }
        else
        {
            counter = 0;
        }
        if (counter < ans)
        {
            ans = counter;
        }
        counter = 0;
    };

    cout << ans << endl;
    
}


Measured memory_bytes: 256
/*input
11011010001011
*/
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define N 100005
#define T int t;cin>>t;while(t--)
using namespace std;

signed main(){
    char s[N];
    cin>>s;
    int a = 0,b = 0;
    for(int i=0;s[i];i++){
        if(s[i]=='0') a++;
        else b++;
    }
    cout << min(a,b)*2 << '\n';
    return 0;
}


Measured memory_bytes: 384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
import std.container : DList;

int[2][10^^5] GP;
bool[10^^5] MS;

alias S = Tuple!(int, "i", int, "c");

void main()
{
    auto K = readln.chomp.to!int;

    foreach (i; 1..K) {
        GP[i][0] = (i*10)%K;
        GP[i][1] = (i+1)%K;
    }

    auto ss = DList!S(S(1, 1));
    for (;;) {
        auto h = ss.front;
        if (!h.i) break;
        ss.removeFront();
        if (MS[h.i]) continue;
        MS[h.i] = true;

        auto n = GP[h.i];
        ss.insertFront(S(n[0], h.c));
        ss.insertBack(S(n[1], h.c+1));
    }

    writeln(ss.front.c);
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N);
  vi a(2 * N); in(a);
  sort(all(a));
  ll ans = 0;
  rep(i,N) ans += a[i * 2];
  out(ans);

}

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

int main()
{
	int n,m;
    cin >> n >> m;
    
    int hei[n];
    for(int i=0;i<n;i++)
    {
        cin >> hei[i];
    }
    
   bool is[n];
    memset(is,true,sizeof(is));
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin >> a >> b;
        
        if(hei[a-1] == hei[b-1])
        {
            is[b-1] = false;
            is[a-1] = false;
        }
        else if(hei[a-1] > hei[b-1])
        {
            is[b-1] = false;
        }
        else if(hei[a-1] < hei[b-1])
        {
            is[a-1] = false;
        }
    }
    
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(is[i])
        {
            cnt++;
        }
    }
    
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4080
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    A,B,T = map(int, input().split())
  else:
    # A = 3
    # B = 5
    # T = 7
    # A,B,T = 3,2,9
    A,B,T = 20,20,19
  
  print(T//A*B)
    
main()

Measured memory_bytes: 2940
import java.util.*;
import java.io.*;
import java.lang.*;
import static java.lang.System.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int[] poles = new int[3];
		for (int i = 0; i < 3; i++) {
			poles[i] = sc.nextInt();
		}
		String isBeautiful = "NO";
		if (poles[1]-poles[0] == poles[2] - poles[1]) {
			isBeautiful = "YES";
		}
		out.println(isBeautiful);
	}
}

Measured memory_bytes: 21972
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    s = input()

    ans = -float("inf")
    for i in range(1, n):
        l = set(s[:i])
        r = set(s[i:])
        ans = max(ans, len(l.intersection(r)))

    print(ans)


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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

bool find(vector<int> vec, int num) {
    auto itr = find(ALL(vec), num);
    size_t index = distance(vec.begin(), itr);
    return index != vec.size();
} 

void Main() {
    int x,y;
    cin>>x>>y;

    vector<int> g1 = {1,3,5,7,8,10,12};
    vector<int> g2 = {4,6,9,11};

    if (x == 2 || y == 2) cout << "No" << endl;
    else if ((find(g1, x) && find(g1, y)) || (find(g2, x) && find(g2, y))) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

			int a=sc.nextInt();
			int b=sc.nextInt();
			int c=sc.nextInt();

				if(a<b&&b<c) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}

	}
}


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

int main(){
  int n , k;
  cin >> n >> k; 
  double sum = 0;
  for(int i=1;i<=n;i++){
    double s = 1;
    int x = i;
    while(x < k){
      s *= 0.5;
      x *= 2;
    }
    sum += s / n;
  }
  cout << setprecision(15) << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include<cstdio>
#include <cstring>
#include <algorithm>
#define ll long long int
using namespace std;

ll arr[100030];
ll a[100030],b[100030],c[100030];
ll dp[100030][5];
ll n,k;

ll call(int i,int t)
{
    int ans1 = 0,ans2 = 0,ans3 = 0;
    if(i == n)
        return 0;
    if(dp[i][t] != -1)
        return dp[i][t];
    else if(t == 0)
    {
        ans2 = a[i]+call(i+1,1);
        ans3 = a[i]+call(i+1,2);
        dp[i][t] = max(ans2,ans3);
        return dp[i][t];
    }
    else if(t == 1)
    {
        ans1 = b[i]+call(i+1,0);
        ans3 = b[i]+call(i+1,2);
        dp[i][t] = max(ans1,ans3);
        return dp[i][t];
    }
    else if(t==2)
    {
        ans1 = c[i]+call(i+1,0);
        ans2 = c[i]+call(i+1,1);
        dp[i][t] = max(ans2,ans1);
        return dp[i][t];
    }
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    memset(dp,-1,sizeof(dp));
    int max = 0;
    for(int i=0;i<n;i++)
    {
        int x = call(0,i);
        if(x > max)
            max = x;
    }
    cout<<max;


}


Measured memory_bytes: 11136
using System;
class Program
 {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            int c = int.Parse(str[1]);
          	if (b < 1 || 10000 < b || c < 1 || 10000 < c)
            {
              return;
            }
          
          	int result = c * b;
          	if (result % 2 == 0)
            {
              Console.Write("Even");
            }
          	else
            {
              Console.Write("Odd");
            }
        }
 }

Measured memory_bytes: 13140
// ABC063_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    string S;
    cin >> S;
    vector<ll> num(26, 0);
    REP(i, S.size()) {
        num[S[i]-'a']++;
    }
    // calculation
    bool flag = true;
    REP(i, num.size()) {
        if (num[i] >= 2) {
            flag = false;
            break;
        }
    }
    
    if (flag) {
        cout << "yes" << "\n";
    } else {
        cout << "no" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[300],i,s,total=0,k=0;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        total+=a[i];
    }
    for(i=1;i<=n;i++)
    {
        if((a[i]*4*m)>=total)
        {
            k++;
        }
    }
    if(k>=m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

int dp[100005];

int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n];

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

    dp[0] = 0;
    // dp[1]=abs(arr[1]-arr[0]);

    for (i = 1; i < n; i++)
    {
        dp[i] = INT_MAX;
    }

    if (n < k)
    {
        for (i = 0; i < n; i++)
        {
            for (j = i + 1; j < n; j++)
            {
                // if(i+j>=n)
                // {
                //     break;
                // }
                int diff = abs(arr[i] - arr[j]);
                int val = diff + dp[i];

                if (val < dp[j])
                {
                    dp[j] = val;
                }
            }
        }
    }
    else
    {
        for (i = 0; i < n - 1; i++)
        {
            for (j = 1; j <= k; j++)
            {
                if(i+j>=n)
                {
                    break;
                }
                int diff = abs(arr[i] - arr[i + j]);
                int val = diff + dp[i];

                if (val < dp[i + j])
                {
                    dp[i + j] = val;
                }
            }
        }
    }

    cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 1024
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

ll m[200005];

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

ll c[2020];

void solve()
{
    string s; cin >> s;
    int k = 1;
    m[0] = 0;
    rep(i, s.size())
    {
        m[i+1] = (m[i] + (s[s.size()-1-i] - '0') * k) % 2019;
        k = (k * 10) % 2019;
    }
    rep(i, s.size()+1)
    {
        c[m[i]]++;
    }
    ll sum = 0;
    rep(i, 2020)
    {
        sum += c[i] * (c[i] - 1) / 2;
    }
    cout << sum << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  
  if(b - a == c - b)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
aa,bb,cc = gets.split.map(&:to_i).sort()
ans = 0


if cc - aa >= 2
    while cc - aa >= 2
        aa += 2
        ans += 1
    end
end
if cc - bb >= 2
    while cc - bb >= 2
        bb += 2
        ans += 1
    end
end

q = []

q << [aa,bb,cc, 0]

while !q.empty?
    a,b,c, cnt = q.shift
    if a==b && b == c
        puts ans + cnt
        exit(0)
    end
    q << [a+1, b+1, c, cnt+1]
    q << [a, b+1, c+1, cnt+1]
    q << [a+1, b, c+1, cnt+1]
end

Measured memory_bytes: 1788
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int H = int.Parse(ipt[0]);
    int N = int.Parse(ipt[1]);
    ipt = Console.ReadLine().Split(' ');
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += int.Parse(ipt[i]);
    }
    Console.WriteLine(H <= sum ? "Yes" : "No");
  }
}

Measured memory_bytes: 18528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  ll odd = 1;
  for (ll i = 0; i < n; i++) {
    if (a[i] % 2 == 0) odd *= 2;
  }
  cout << pow(3, n) - odd << endl;
}

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;
typedef pair<int,int> P;

int main(void) {
    queue<ll> qq;
    ll K; cin >> K;
    ll ans;
    for(int i=1;i<=9;i++) qq.push(i);
    for(int i=0; i<K; i++) {
        ll x=qq.front();
        ans = x;
        qq.pop();
        if(x%10!=0) qq.push(10*x+x%10-1);
        qq.push(10*x+x%10);
        if(x%10!=9) qq.push(10*x+x%10+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;


int main(){
    int a,b,k;
    cin>>a>>b>>k;
    if(b-a+1>k*2){
        rep(i,a,a+k) cout<<i<<endl;
        Rep(i,b-k+1,b) cout<<i<<endl;
    }else{
        Rep(i,a,b) cout<<i<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int N = scanner.nextInt();
		int n = 2;
		
		System.out.println(lcm(N, n));

	}
  
	static int gcd(int N, int n) {
		return n > 0 ? gcd(n, N%n) : N;
	}
	
	public static int lcm(int N, int n) {
		return N * n / gcd(N, n);
	}

}

Measured memory_bytes: 21972
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x1: i64 = read();
    let y1: i64 = read();
    let x2: i64 = read();
    let y2: i64 = read();

    let xd = x2 - x1;
    let yd = y2 - y1;

    let x3 = x2 - yd;
    let y3 = y2 + xd;

    let x4 = x3 - xd;
    let y4 = y1 + xd;

    println!("{} {} {} {}", x3, y3, x4, y4);
}


Measured memory_bytes: 4352
N,M = map(int, input().split())

ls = []
st = { i+1 for i in range(N) }
for i in range(M):
    inl = list(map(int, input().split()))
    switches = inl[1:]
    ls.append(switches)

checker = list(map(int,input().split()))

res = [0]
def check(inpu = st, mp = {}, res_ = res):
    if len(inpu):
        val = inpu.pop()
        mp0 = mp.copy()
        mp0[val] = 0
        mp1 = mp.copy()
        mp1[val] = 1
        check(inpu.copy(), mp0)
        check(inpu.copy(), mp1)
    else:
        # print(mp)
        all_ = True
        for key, sws in enumerate(ls):
            summed = 0
            for sw in sws:
                summed += mp[sw]
            summed %= 2
            if summed != checker[key]:
                all_ = False
        if all_:
            res[0] += 1

check()
print(res[0])


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

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

    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin>>x.at(i);
    }

    vector<int> y(n);
    for(int i=0;i<n;i++){
        cin>>y.at(i);
    }

    long double Dxy_m=0;
    for(int i=0;i<n;i++){
        Dxy_m += abs(x.at(i)-y.at(i));
    }
    cout << fixed << setprecision(15) << Dxy_m << endl;

    long double Dxy_e=0;
    for(int i=0;i<n;i++){
        Dxy_e += pow(abs(x.at(i)-y.at(i)),2);
    }
    Dxy_e = sqrt(Dxy_e);
    cout << fixed << setprecision(15) << Dxy_e << endl;


    long double Dxy_p3=0;
    for(int i=0;i<n;i++){
        Dxy_p3 += pow(abs(x.at(i)-y.at(i)),3);
    }
    Dxy_p3 = pow(Dxy_p3,1.0/3.0);
    cout << fixed << setprecision(15) << Dxy_p3 << endl;


    long double Dxy_mi=0;
    for(int i=0;i<n;i++){
        Dxy_mi= max((long double)abs(x.at(i)-y.at(i)),Dxy_mi);
    }
    cout << fixed << setprecision(15) << Dxy_mi << endl;


    return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 200005
#define INF 1000005
#define endl "\n"
int arr[MAX];
int f[INF];
bool p[INF];
bool flag[MAX];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(lli i = 2; i<=INF; i++){
		if(!p[i]){
			for(lli j = i*i; j<=INF; j+=i){
				p[j] = true;
 			}
		}
	}
	lli n;
	cin>>n;
	for(lli i = 0; i<n; i++){
		cin>>arr[i];
		f[arr[i]]++;
	}
	lli c = 0;
	bool flag = false;
	for(lli i = 0; i<n; i++){
		flag = false;
		f[arr[i]]--;
		if(!p[arr[i]]){
			if(f[1] || f[arr[i]]){
			}
			else{
				c++;
			}
			f[arr[i]]++;
			continue;
		}
		for(lli j = 1; j*j <= arr[i]; j++){
			if(arr[i]%j == 0){
				if(f[j] || f[arr[i]/j]){
					flag = true;
					break;
				}
			}
		}
		if(!flag){
			c++;
		}
		f[arr[i]]++;
	}
	cout<<c<<endl;
	
}

Measured memory_bytes: 9204
#include <stdio.h>

#define INF -2000000001

int main(){
  int i,n,A[501];

  scanf("%d",&n);
  for(i=0;i<502;i++) A[i]=INF;

  for(i=1;i<=n;i++) scanf("%d",&A[i]);

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);

    if(A[i/2]!=INF) printf("parent key = %d, ",A[i/2]);
    if(A[2*i]!=INF) printf("left key = %d, ",A[2*i]);
    if(A[2*i+1]!=INF) printf("right key = %d, ",A[2*i+1]);

    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2044
<?php
class AOJ0534 {
    var $T;
    var $TC;
    var $L;
    var $LC;

    public function init() {
        $L = &$this->L;
        $LC = &$this->LC;
        $T = &$this->T;
        $TC = &$this->TC;
        
        $in = file_get_contents('/dev/stdin');
        $L = explode( "\n", trim($in) );
        $LC = count($L);
        $T = array();
        $TC = 0;
    }
    
    public function input() {
        $L = &$this->L;
        $LC = &$this->LC;
        $T = &$this->T;
        $TC = &$this->TC;
        
        for ( $i = 0; $i < $LC; ++ $i ) {
            if ( $L[$i] == "0" ) break;
            $n = $L[$i++];
            $T[$TC] = array();
            for ( $j = 0; $j < $n; ++ $j ) {
                $T[$TC][] = intval($L[$i++]);
            }
            $TC++;
            $i--;
        }
    }

    public function check($s) {
        for ( $i = 1; $i <= 3; ++ $i ) {
            $key = str_repeat( $i, 4 );
            if ( strstr( $s, $key ) ) return true;
        }
        return false;
    }

    public function calc($s) {
        while ( $this->check($s) ) {
            for ( $i = 1; $i <= 3; ++ $i ) {
                $regexp = "/".$i."{4,}/";
                $s = preg_replace( $regexp, '', $s );
            }
        }
        return $res = strlen($s);
    }

    public function check_around( $s, $k ) {
        $res = 0;
        $n = strlen($s);
        for ( $i = 0; $i < 4; ++ $i ) {
            $id = $k - $i - 1;
            if ( $id < 0 ) break;
            if ( $s[$k] != $s[$id] ) break;
            $res ++;
        }
        for ( $i = 0; $i < 4; ++ $i ) {
            $id = $k + $i + 1;
            if ( $id >= $n ) break;
            if ( $s[$k] != $s[$id] ) break;
            $res ++;
        }
        return $res + 1;
    }
    
    public function solve($s_) {
        $res = PHP_INT_MAX;
        $s = implode('', $s_);
        for ( $i = 1; $i <= 3; ++ $i ) {
            $regexp = "/".$i."{4,}/";
            $s = preg_replace( $regexp, str_repeat($i, 4), $s );
        }
        $n = strlen($s);
        for ( $i = 0; $i < $n; ++ $i ) {
            $t = $s;
            for ( $j = 1; $j <= 3; ++ $j ) {
                if ( $t[$i] == $j ) continue;
                $t[$i] = $j;
                if ( $this->check_around( $t, $i ) < 4 ) continue;
                if ( ( $i-1 >= 0 && $t[$i-1] == $j ) || ( $i+1 < $n && $t[$i+1] == $j ) ) {
                    $res = min( $res, $this->calc($t) );
                }
            }
        }
        return $res;
    }
    
    public function run() {
        $this->init();
        $this->input();
        foreach ( $this->T as $test ) {
            echo $this->solve($test)."\n";
        }
    }
}

$instance = new AOJ0534;
$instance->run();

Measured memory_bytes: 14000
#include<iostream>
using namespace std;
string s,t;
main()
{
	cin>>s>>t;
	int now=0;
	for(int i=0;i<t.size();i++)
	{
		if(t[i]==s[now])
		{
			now+=2;
		}
		if(now/2>=s.size()/2)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	now=1;
	for(int i=0;i<t.size();i++)
	{
		if(t[i]==s[now])
		{
			now+=2;
		}
		if((now-1)/2>=(s.size()-1)/2)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  int cnt=0;
  for (int i = 0; i < 3; ++i)
   {
     if(s[i]=='R') cnt++;
   } 
   if(s[1]=='S'&&cnt==2) cnt--;
   cout<<cnt<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
main()
{
    int n; cin >> n;
    int h[n];
    for(int i=0;i<n;i++)
        cin >> h[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        int s = dp[i-1]+abs(h[i]-h[i-1]);
        int d = dp[i-2]+abs(h[i]-h[i-2]);
        dp[i] = min(s,d);
    }
    
    cout << dp[n-1] << "\n";

}       

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>

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

using namespace std;

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    x -= 1;
    y -= 1;
    vector<vector<int>> dist(n, vector<int>(n,-1));
    vector<int> cnt(n,0);
    queue<int> que;
    rep(i,n){
        dist[i][i] = 0;
        cnt[0] += 1;
        que.push(i);

        while(!que.empty()){
            int v = que.front();
            que.pop();
            if (v == x && dist[i][y] == -1) {
                que.push(y);
                dist[i][y] = dist[i][v] + 1;
                if ( dist[y][i] == -1){
                    cnt[dist[i][y]] += 1;
                }
                //dist[y][i] = dist[i][v] + 1;

            }
            if (dist[i][v+1] == -1){
                que.push(v + 1);
                dist[i][v + 1] = dist[i][v] + 1;
                if (dist[v+1][i] == -1){
                    cnt[dist[i][v + 1]] += 1;
                }
            //    dist[v + 1][i] = dist[i][v] + 1;

            }
            if (dist[i][v -1]  == -1)
            {
                que.push(v - 1);
                dist[i][v - 1] = dist[i][v] + 1;
                if (dist[v-1][i] == -1){
                    cnt[dist[i][v - 1]] += 1;
                }
                //dist[v - 1][i] = dist[i][v] + 1;

            }
        }
    }
    for (int i = 1; i < n; ++i)
    {
        cout << cnt[i] << endl;
    }
//    for (int i = 1; i < n; ++i)
//    {
//        result = 0;
//        idx = i;
//        while (true)
//        {
//            if (idx >= n)
 //               break;
 //           result += cnt[idx]*cnt[idx-i];
 //           idx += 1;
 //       }
 //       cout << result << endl;
 //   }
   
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    bool b=true;
    map<char,int> m;
    int h,w,a=1,count=0,d=0;
    char c;
    cin>>h>>w;
    for(int i=0;i<h*w;i++){
        cin>>c;
        if(m.find(c)!=m.end()){
            m[c]++;
        }
        else{
            m[c]=1;
        }
    }
    if(!(h%2))a*=2;
    if(!(w%2))a*=2;
    for(auto x:m){
        if(m[x.first]%a){
            b=false;
            break;
        }
        m[x.first]/=a;
    }
    if(b&&!(a%4)){
        cout<<"Yes"<<endl;
    }
    else if(b&&!(a%2)){
        for(auto x:m){
            if(m[x.first]%2){
                count++;
            }
        }
        if(count<=((h%2==0)?h/2:w/2)&&b)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        for(auto x:m){
            if(m[x.first]%2){
                count++;
            }
            if(m[x.first]%4){
                d++;
            }
        }
        if(count==1&&d<=h/2+w/2+1&&b)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
    
}

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

typedef long long ll;
using namespace std;



bool isPrime(int n){
    if(n < 2){
        return 0;
    }
    if(n%2 == 0){
        return n==2;
    }
    for(int i=3;i*i<=n;i++){
        if(n%i == 0) return 0;
    }
    return 1;
}


int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    int h=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(v[i]%2 != 0 && (i+1)%2 != 0) h++;
    }
    cout<<h<<endl;
    return 0;
}


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

main(){
    int n, B[10], P[2], b, s;
    cin >> n;
    for ( int t = 0; t < n; t++ ){
	for ( int i = 0; i < 10; i++ ) cin >> B[i];
	P[0] = P[1] = 0;
	bool p = true;
	for ( int i = 0; i < 10; i++ ){
	    if ( P[0] > P[1] ) { b = 0; s = 1; }
	    else { b = 1; s = 0;}
	    if ( B[i] > P[b] ) P[b] = B[i];
	    else if ( B[i] > P[s] ) P[s] = B[i];
	    else {p = false; break;}
	}
	if ( p ) cout << "YES" << endl;
	else cout << "NO" << endl;
    }
}

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

using namespace std;
int main(void){
    int N = 0,ans = 0,val = 0;
    cin >> N;
    for(int i = 1;i < 10; i++){
        ans = N % i;
        if(ans == 0) {
            ans = N / i;
            if(ans <= 9){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
import scala.io.Source
import scala.math._

object Main{
  def main(args: Array[String]){
    val lines = for{
      in <- Source.stdin.getLines.toList
    }yield in

    val num = lines.length / 2

    for(i <- 0 until num){
      println(stdDeviation(lines(i * 2 + 1).split(" ").toList.map(_.toDouble)))
    }
  }

  def stdDeviation(list: List[Double]): Double={
   sqrt(list.map{_ - (list.sum / list.length)}.map{pow(_, 2)}.sum / list.length)
  }
}

Measured memory_bytes: 92480