akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }


char S[52], T[52];

int main() {
	int i, k, l, m, n, o;

	scanf("%s%s", S, T);

	int slen = strlen(S);
	int tlen = strlen(T);

	for (k = slen - tlen; k >= 0; k--) {
		for (l = 0; l < tlen; l++) {
			if (T[l] != S[l + k] && S[l + k] != '?') {
				break;
			}
		}
		if (l == tlen) {
			break;
		}
	}
	if (k == -1) {
		puts("UNRESTORABLE");
	}
	else{
		for (m = 0; m < tlen; m++) {
			S[m + k] = T[m];
		}
		for (n = 0; n < slen; n++) {
			if (S[n] == '?') {
				S[n] = 'a';
			}
		}
		printf("%s\n", S);
	}

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

using LP = pair<ll, int>;
int main(){
	int N, M;
	cin >> N >> M;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];
	vector<LP> CB(M);
	for(int i=0; i<M; i++){
		ll c;  int b;
		cin >> b >> c;
		CB[i] = LP(c, b);
	}
	sort(A.begin(), A.end());// 昇順ソート
	sort(CB.rbegin(), CB.rend());// CBをCの値で降順ソート
	vector<ll> vec;//CBの内で解放からN個取り出して並べる
	for(int i=0; i<M; i++){
		for(int j=0; j<CB[i].second; j++){
			vec.push_back(CB[i].first);
		}
		if(vec.size() >= N) break;
	}
	// cout << " A: "; print_vec(A);
	// cout << " vec: "; print_vec(vec);
	
	ll ans = 0;
	for(int i=0; i<N; i++){
		if(vec.size() >= i+1) ans += max(A[i], vec[i]);
		else ans += A[i];
	}
	cout << ans << endl;

}



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

using namespace std;

using ll = long long;

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max({a, b, c}) << endl;

    return 0;
}


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

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> data(N);
    for(int i=0;i<N;i++){
        cin>>data[i];
    }
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    int ans=0;
    for(int i=0;i<K;i++){
        ans+=data[i];
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	int X[100] = { 0 };
	cin >> X[0] >> X[1] >> X[2];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			if (X[j] > X[j + 1]) {
				n = X[j];
				X[j] = X[j + 1];
				X[j + 1] = n;
			}
		}
	}
	for (int i = 0; i < 2; i++) {
		ans += X[i + 1] - X[i];
	}
	cout << ans;
}

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

int main() {
    long n, m, temp, ans;
    cin >> n >> m;
    temp = min(n, m / 2);
    n -= temp;
    m -= 2 * temp;
    if(n == 0 && m > 0) ans = temp + m / 4;
    else ans = temp;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    
    int counter,divisor_num = 0;
    for(counter = a; counter <= b; counter++){
        if(c%counter == 0) divisor_num++;
    }
    printf("%d\n", divisor_num);
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N;
        cin>>N;
        pair<ll,ll> ar[N];
        for(ll i=0;i<N;i++){
            cin>>ar[i].ff>>ar[i].ss;
        }
        string s="No";
        for(ll i=0;i<=N-3;i++){
            if(ar[i].ff==ar[i].ss&&ar[i+1].ff==ar[i+1].ss&&ar[i+2].ff==ar[i+2].ss)
                s="Yes";
        }
        cout<<s<<endl;
    }
}

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

template <typename T>
class SegmentTree {
	const int n;
	const T id;
	vector<T> data;
	int size(int n) {
		int res;
		for (res = 1; res < n; res <<= 1);
		return res;
	}
public:
	SegmentTree(int n_, T id_) :
		n(size(n_)), id(id_), data(size(n_) * 2, id_) {}
	void Update(int p, T val) {
		p += n;
		data[p] = val;
		while (p >>= 1) data[p] = max(data[p * 2], data[p * 2 + 1]);
	}
	T Find(int l, int r) {
		if (r < l) return id;
		l += n; r += n + 1;
		T res1 = id, res2 = id;
		while (l != r) {
			if (l & 1) res1 = max(res1, data[l++]);
			if (r & 1) res2 = max(data[--r], res2);
			l >>= 1; r >>= 1;
		}
		return max(res1, res2);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, x;
	cin >> n;
	SegmentTree<ll> st(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> x; x--;
		st.Update(x, st.Find(0, x - 1) + x + 1);
	}
	printf("%lld\n", (ll)n * (n + 1) / 2 - st.Find(0, n - 1));
	return 0;
}

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

using namespace std;


int main(){


    int n, d;
    cin >> n >> d;

    vector<vector<int> > x(n, vector<int>(d));
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < d; ++j)
            cin >> x[i][j];


    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            int dis = 0;
            for(int k = 0; k < d; ++k) {
                dis += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            double tmp = sqrt(dis);
            if(tmp == (double)(int)tmp) ++cnt;
        }
    }

    cout << cnt << endl;



    return 0;
}


Measured memory_bytes: 256
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/), cid = 0;
function next(a) { return a ? cin[cid++] : +cin[cid++]; }
function nexts(n, a) { return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a); }
function nextm(h, w, a) { var r = [], i = 0; if (a) for (; i < h; i++)r.push(cin.slice(cid, cid += w)); else for (; i < h; i++)r.push(cin.slice(cid, cid += w).map(a => +a)); return r; }
function xArray(v) { var a = arguments, l = a.length, r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})"; while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")"; return eval(r); }

var myOut = main();
if (myOut !== undefined) console.log(myOut);

function main() {
    var s = next(1);
    return s === "ABC" ? "ARC" : "ABC";
}
// 2422824228の場合
// s[i]...8,  2,   2,    4,                         2
// k......1, 10, 100, 1000,           10000%2019=1924, 10万%2019=19240%2019=1069
// x......8, 28, 228, 4228%2019=0190, 20190%2019=2924*2+190=4038=0


Measured memory_bytes: 29624
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  const int N = 200005;

int32_t main()
{



    IOS

    


    string s;
    cin >> s;

    if(s == "ABC")cout << "ARC";
    else cout << "ABC";

















    
    return 0;
}



Measured memory_bytes: 3608
my $x = glob <>;
my @prime;

$i = 1;
while (1) {
    $i++;

    my $is_prime = 1;
    for ( my $j = 2 ; $j < $i**0.5 ; $j++ ) {
        if ( $i % $j == 0 ) {
            $is_prime = 0;
            last;
        }
    }

    if ( not $is_prime ) {
        next;
    }

    if ( $i >= $x ) {
        last;
    }
    push( @prime, $i );
}

print($i)

Measured memory_bytes: 1536
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int a[5],b[5];
	int ssr,sr;
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		ssr=0;
		sr=0;
		fu(0,4){
			if(a[i]==b[i]){
				ssr++;
				a[i]=INF;
				b[i]=INF;
			}
		}
		fu(0,4){
			if(b[i]!=INF){
				for(int r=0;r<4;r++){
					if(b[i]==a[r]) sr++;
				}
			}
		}
		cout<<ssr<<" "<<sr<<endl;
	}
}

Measured memory_bytes: 1160
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int A = int.Parse(input[0]);
		int B = int.Parse(input[1]);
		int C = int.Parse(input[2]);
		if (A + B >= C)
        {
			Console.WriteLine("Yes");
        }
		else
        {
      		Console.WriteLine("No");
        }
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >>H>>W;
  vector<vector<char>> A(H, vector<char>(W));
  vector<int> h;
  vector<int> w;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin>>A[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
   vector<char> v(W,'.');
    if(A[i]!=v){
      h.push_back(i);
    }
  }
  for (int i = 0; i < W; i++) {
    bool a=false;
    for (int j = 0; j < H; j++) {
      if(A[j][i]=='#'){
        a =true;
        break;
      }
    }
    if(a){
      w.push_back(i);
    }
  }
  for (int x : h) {
    for(int y : w){
      cout<<A[x][y];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [K, X] = r.nn()

    return K * 500 >= X ? 'Yes' : 'No'
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明
// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) {
		a_powered *= a;
	}
	return a_powered;
}

int main(int argc, char *argv[]){
    int N, M;
    cin >> N >> M;

    int Mmem[M+1] = {};
    int Mmem_temp[M+1] = {};
    Mmem[0] = 1;
    Mmem_temp[0] = 1;

    for (int i=0; i<N; i++) {
        for(int j=1; j<M+1; j++){
            Mmem_temp[j] = 1;
        }

        int K;
        cin >> K;
        for (int j=0; j<K; j++){
            int Atemp;
            cin >> Atemp;
            Mmem_temp[Atemp] = 0;
        }

        for(int j=1; j<M+1; j++){
            if(Mmem_temp[j] == 1){
                Mmem[j] = 1;
            }
        }
    }

    int ans = 0;
    for(int i=1; i<M+1; i++){
        if (Mmem[i] == 0) ans++;
    }

    cout << ans << endl;
}


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

using namespace std;

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

    double ans = 0;
    for (int i = 1; i <= n; i++) {
        int j = i;
        double p = 1;
        while (j < k) {
            j *= 2;
            p /= 2;
        }
        ans += p;
    }

    ans /= n;
    cout << setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;

int main() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);

	int A, B, C, D; cin >> A >>B >> C >> D;

	if (A * B > C * D)cout << A * B << endl;
	else if (A * B < C * D)cout << C * D << endl;
	else cout << A * B << endl;
	return 0;
}



Measured memory_bytes: 3576
k, a, b = map(int, input().split(' '))

delta_per_act_hit = 1
delta_per_act_exchange = (b - a) / 2

if delta_per_act_hit >= delta_per_act_exchange:
    print(1+k)
    exit(0)

else:
    # if there are sufficient number of biscuits, do exchanging
    num_exchangeable = (k - (a-1)) // 2

    if num_exchangeable <= 0:
        print(1+k)
        exit(0)
    else:
        print(1 + (b-a) * num_exchangeable + (k - num_exchangeable*2))
        exit(0)


Measured memory_bytes: 3060
n,m = map(int, input().split())
p_cnt = [0 for i in range(n+1)]
a = []
for i in range(m):
    p,y = map(int, input().split())
    a.append((y,p,i))
a.sort()
b = []
for y,p,i in a:
    p_cnt[p] += 1
    b.append((i,'{0:06}{1:06}'.format(p,p_cnt[p])))
b.sort()
for i,bi in b:
    print(bi)


Measured memory_bytes: 36428
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int w,h;
	int dx[128]={0};
	int dy[128]={0};
	dx['<'] = -1;
	dx['>'] = 1;
	dy['^'] = -1;
	dy['v'] = 1;
	while(cin >> h >> w , w){
		char data[128][128]={0};
		rep(i,h)rep(j,w)cin >> data[i][j];
		int x = 0 , y = 0 , f = 0;
		while(data[y][x]!='.'){
			char c = data[y][x];
			if(c == '-'){f = 1 ; break;}
			else data[y][x] = '-';
			x += dx[c] , y += dy[c];
		}
		if(f)cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5+1;
int n, k;
ll DP[N], DP2[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  DP[0] = 1;
  FOR(i, 0, n){
    int a;
    cin >> a;
    ll s = 0;
    FOR(i, 0, k+1){
      s += DP[i];
      if(i > a) s -= DP[i-a-1];
      DP2[i] = s%MOD;
    }
    swap(DP, DP2);
  }
  cout << (DP[k]%MOD+MOD)%MOD << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;

    vi ans(n);
    rep (i, n) {
        for (int j = i + 1; j < n; j++) {
            int ma = inf;
            chmin(ma, j - i);
            chmin(ma, abs(x - i) + abs(y - j) + 1);
            ans[ma]++;
        }
    }

    rep1 (i, n - 1) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);

vector<int>v[2*N];

void solve(int T){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        v[a[i]].pb(i);
    }
    int ans=0,lst=-1;
    for(int i=1;i<=n;i++){
        //cout<<lst<<"\n";
        if(v[i].empty() && ans==0){
            cout<<"-1\n";
            return;
        }
        if(v[i].empty() && ans>0){
            cout<<n-ans<<"\n";
            return;
        }
        auto it=upper_bound(v[i].begin(),v[i].end(),lst);
        if(it!=v[i].end()){
            lst=*it;
            ans++;
            continue;
        }
        if(it==v[i].end() && ans==0){
            cout<<"-1\n";
            return;
        }
        if(it==v[i].end() && ans>0){
            cout<<n-ans<<"\n";
            return;
        }
    }
    cout<<n-ans<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 15004
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.append(1000000001)  # > 1,000,000,000
q = int(input())
for i in range(q):
	k = int(input())
	p = bisect_left(a, k)
	print(1 if a[p] == k else 0)



Measured memory_bytes: 17216
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
vector<string>v;
int main() {
	int n;
	string s[101];
	cin >> n;
	rep(i, n)cin >> s[i];
	v.push_back(s[0]);
	for (int i = 1;i < n;i++) {
		if (s[i][0] != s[i - 1][s[i - 1].size() - 1]) {
			cout << "No" << endl;
			return 0;
		}
		for (int j = 0;j < v.size();j++) {
			if (s[i] == v[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
		v.push_back(s[i]);
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll n;
	std::cin >> n;

	ll k;
	std::cin >> k;

	std::vector<ll> x(n,0);
	for(int i = 0;i < n;++i) std::cin >> x[i];

	ll ans = 0;
	std::vector<ll> a_cost(n*n,0), b_cost(n*n,0);
	for(int i = 0;i < n;++i)
	{
		const ll nx = x[i];
		const ll ny = i+1;
		ll min_a = 99999999;
		ll min_b = 99999999;
		for(ll j = 0;j < n;++j)
		{
			const ll y = j+1;
			ll tmp_a = nx + abs(ny-y); // A-COST
			ll tmp_b = abs(nx-k) + abs(ny-y); // B-COST
			if(min_a > tmp_a) min_a = tmp_a;
			if(min_b > tmp_b) min_b = tmp_b;
		}
		ans += (min_a > min_b) ? min_b : min_a;
	}

	std::cout << ans * 2 << std::endl;

	return 0;
}

Measured memory_bytes: 384
import sys; readline = sys.stdin.readline
from collections import deque
 
N = int(readline())
S = readline().rstrip()
 
e1, e2, e3 = set([]), set([]), set([])
 
for i in range(N):
    for s2 in e2:
        e3.add(s2 + S[i])
    
    for s1 in e1:
        e2.add(s1 + S[i])
 
    e1.add(S[i])
 
print(len(e3))

Measured memory_bytes: 3444
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(string, s);
    rep(bit, 0, 1 << 3) {
        int sum = s[0] - '0';
        rep(i, 0, 3) {
            if ((bit >> i) & 1) {
                sum += s[i + 1] - '0';
            } else {
                sum -= s[i + 1] - '0';
            }
        }
        if (sum != 7) continue;

        cout << s[0];
        rep(i, 0, 3) {
            if ((bit >> i) & 1) {
                cout << '+';
            } else {
                cout << '-';
            }
            cout << s[i + 1];
        }
        cout << "=7\n";
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include <fstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    for (ll i = 1; i <= 9; i++) {
        if (N%i == 0 && N/i <= 9) {
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::cmp::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn is_prime(n: u32) -> bool {
    if n <= 1 {
        return false;
    }
    for i in 2..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            return false;
        }
    }
    true
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let mut cnt = 0;
    for _ in 0..n {
        let x = sc.read();
        if is_prime(x) {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}



Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    int A[202020] = {0};
    rep(i, n-1) {
        int a;
        cin >> a;
        A[a-1]++;
    }
    rep(i, n) {
        cout << A[i] << endl;
    }
}

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


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

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int count=0;
  int sum=accumulate(a.begin(),a.end(),0);
  for (int i=0; i<m; i++) {
    if (a.at(i) >= (double)sum/(4*m))
      count++;
  }
  if (count==m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

int main(){
   IOS;
ll t;t=1;//cin>>t;

while(t--){
string a;cin>>a;
ll ans=0;
for(ll i=0;i<a.size();i++){
    ans=ans+(int)(a[i]-'0');
}
if(ans%9==0) cout<<"Yes";
else cout<<"No";
  
}
    
return 0;    
}

Measured memory_bytes: 3776
N,W=map(int,input().split());d={0:0}
for _ in [0]*N:
 w,v=map(int,input().split())
 for x,y in d.copy().items():
  if x+w<=W:d[x+w]=max(d.get(x+w,0),y+v)
print(max(d.values()))

Measured memory_bytes: 3632
l,r=map(int,input().split())
temp=2019
for i in range(l,r+1):
    for j in range(i+1,r+1):
        if temp>(i*j)%2019:
            temp = (i * j) % 2019
            if temp==0:
                break
    if temp==0:
        break

print(temp)




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

typedef long long ll;

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

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

int main() {
    vector<int> X(3);
    cin >> X[0] >> X[1] >> X[2];
    
    sort(X.begin(),X.end());
    
    int a,b;
    
    a = X[2] - X[0];
    b = X[2] - X[1];
    
    a /= 2;
    b /= 2;
    
    //cout << a << " " << b << endl;
    
    int p,q;
    
    p = X[0] + a * 2;
    q = X[1] + b * 2;
    
    if ( 2 * X[2] - p - q == 2 ){
        cout << a + b + 1 << endl;
    } else if (2 * X[2] - p - q == 0 ){
        cout << a + b << endl;
    } else {
        cout << a + b + 2 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3592
using System;

namespace AOJ
{
    class CircumscribedCircle
    {
        public static void Main()
        {
            int cnt = int.Parse(Console.ReadLine());
            for (int i = 1; i <= cnt; i++)
            {
                var input = Console.ReadLine().Trim().Split(' ');
                double x1 = double.Parse(input[0]);
                double y1 = double.Parse(input[1]);
                double x2 = double.Parse(input[2]);
                double y2 = double.Parse(input[3]);
                double x3 = double.Parse(input[4]);
                double y3 = double.Parse(input[5]);
                double x12 = Math.Pow(x1,2);
                double y12 = Math.Pow(y1,2);
                double x22 = Math.Pow(x2,2);
                double y22 = Math.Pow(y2,2);
                double x32 = Math.Pow(x3,2);
                double y32 = Math.Pow(y3,2);
                double x = ((y1 - y3) * (y12 - y22 + x12 - x22) - (y1 - y2) * (y12 - y32 + x12 - x32)) /
                    (2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3));
                double y = ((x1 - x3) * (x12 - x22 + y12 - y22) - (x1 - x2) * (x12 - x32 + y12 - y32)) /
                    (2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3));
                double r = Math.Sqrt(Math.Pow(x1 - x, 2) + Math.Pow(y1 - y, 2));
                x = Math.Round(x * 1000, MidpointRounding.AwayFromZero) / 1000;
                y = Math.Round(y * 1000, MidpointRounding.AwayFromZero) / 1000;
                r = Math.Round(r * 1000, MidpointRounding.AwayFromZero) / 1000;
                Console.WriteLine(x.ToString("F3") + " " + y.ToString("F3") + " " + r.ToString("F3"));
            }
        }
    }
}

Measured memory_bytes: 5728
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; string S; cin>>N>>S;
    int ans = 0, cnt = 0;
    int Slen = S.size();
    for (int i = 1; i < Slen; ++i) {
        if(S[i] == S[i-1]) cnt++;
    }
    ans = Slen - cnt;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
#else
using LONG = long long int;
#endif

int main(void) {
  string s;
  string exact = "CODEFESTIVAL2016";
  cin >> s;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == exact[i]) count++;
  }
  cout << (16 - count) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt()};
        int[] card = new int[a[0]];
        for (int i = 0; i < a[0]; i++) {
            card[i] = sc.nextInt();
        }
        if (a[0] == 1) {
            System.out.println(Math.abs(card[0] - a[2]));
        } else {
            System.out.println(Math.max(
                Math.abs(card[card.length - 1] - a[2]),
                Math.abs(card[card.length - 1] - card[card.length - 2])));
        }
    }
}


Measured memory_bytes: 26964
import collections

h, w = map(int, input().split())
src_y, src_x = map(int, input().split())
dst_y, dst_x = map(int, input().split())
src_y -= 1
dst_y -= 1
src_x -= 1
dst_x -= 1
grid = [input() for _ in range(h)]

UNDEF = -1
colors = [[UNDEF] * w for _ in range(h)]


ncolors = 0
def paint(grid, colors):
    global ncolors
    for y in range(h):
        for x in range(w):
            if grid[y][x] == '.' and colors[y][x] == UNDEF:
                q = collections.deque()
                colors[y][x] = ncolors
                q.append((y, x))
                while q:
                    i, j = q.popleft()

                    for ii, jj in (
                        (i - 1, j),
                        (i, j - 1),
                        (i, j + 1),
                        (i + 1, j)
                    ):
                        if 0 <= ii < h and 0 <= jj < w and colors[ii][jj] == UNDEF and grid[ii][jj] == '.':
                            colors[ii][jj] = ncolors
                            q.append((ii, jj))
                ncolors += 1

paint(grid, colors)


def build(grid, colors, ncolors):
    g = [set() for _ in range(ncolors)]
    for i in range(h):
        for j in range(w):
            if colors[i][j] != UNDEF:
                for ii in range(i - 2, i + 3):
                    for jj in range(j - 2, j + 3):
                        if 0 <= ii < h and 0 <= jj < w and colors[ii][jj] != colors[i][j] and colors[ii][jj] != UNDEF:
                            c1 = colors[ii][jj]
                            c2 = colors[i][j]
                            assert c1 != UNDEF and c2 != UNDEF
                            g[c1].add(c2)
                            g[c2].add(c1)
    return g

g = build(grid, colors, ncolors)

q = collections.deque()
src_color = colors[src_y][src_x]
dst_color = colors[dst_y][dst_x]
q.append((src_color, 0))
vis = [0] * ncolors
vis[src_color] = 1
ans = -1
while q:
    color, dist = q.popleft()
    if color == dst_color:
        ans = dist
        break
    for other in g[color]:
        if not vis[other]:
            q.append((other, dist + 1))
            vis[other] = 1

print(ans)


Measured memory_bytes: 127572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e9+7;
map<ll,int>d;
ll n;
int solve(ll x){
    if (d[x]) return d[x];
    return d[x]=((1ll*solve(x/2)+solve((x-1)/2)+solve((x-2)/2))%M);
}
int main(){
    d[0]=1,d[1]=2;
    scanf("%lld",&n);
    printf("%d",solve(n));
}

Measured memory_bytes: 256
#include<stdio.h>

main()
{
	int c ;

	c = getchar () ;

	if ( c == 97 || c == 105 || c == 117 || c == 101 || c == 111 )
	{
		printf ( "vowel\n" );
		return 0 ;
	}

	printf ( "consonant\n" );

	return 0 ;
}


Measured memory_bytes: 128
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFront;}}
void readM(T)(size_t r,size_t c,ref T[][]t){t=new T[][](r);foreach(ref ti;t)readA(c,ti);}

void main()
{
  auto t = 10;
  int n; readV(n);
  int[][] f; readM(n, t, f);
  int[][] p; readM(n, t+1, p);

  auto fb = new int[](n);
  foreach (i; 0..n)
    foreach (j; 0..t)
      if (f[i][j]) fb[i] = fb[i].bitSet(j);

  auto r = -10^^9;
  foreach (i; 1..1<<t) {
    auto s = 0;
    foreach (j; 0..n) s += p[j][(i&fb[j]).popcnt];
    r = max(r, s);
  }

  writeln(r);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


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

ll A, B;

int main() { 
    cin >> A >> B;
    ll out = -1;
    for (double i = B; i <= 2000; i++) {
      if (int(i*0.08)==A && int(i*0.1)==B) {
          out = i;
          break;
      }
    }
    cout << out << endl;
    return 0;
}


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

using namespace std;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    vector < int > a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k - 1];
    return 0;
}


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

int main(){
  int d;
  cin >> d;
  
  if(d == 25)
    cout << "Christmas" << endl;
  else if(d == 24)
    cout << "Christmas Eve" << endl;
  else if(d == 23)
    cout << "Christmas Eve Eve" << endl;
  else if(d == 22)
    cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
import itertools
import math

N = int(input())
x = []
y = []
for _ in range(N):
    a,b = map(int,input().split()[:2])
    x.append(a)
    y.append(b)

def distance(i,j):
    return math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)

sum=0

for i in itertools.permutations(range(N),N):
    ret=0
    for j in range(N-1):
        ret+=distance(i[j],i[j+1])
    sum+=ret

div = math.factorial(N)
print(sum /div)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
#include <functional>
#include <cassert>
 
typedef long long ll;
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << endl;
 
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000
 
 
int main(){
  ll n,d;
  cin >> n >> d;
 
  ll ans = 0;
   
  if(d == 1){
    ans = n*(n-1)/2;
  }else{
    ans = d + (n-d-1)*(n-d-2)/2+(n-d-1)*3;
  }
 
  cout << ans << endl;
   
  return 0;
}

Measured memory_bytes: 3088
S = list(input())
N = len(S)
A = N%2
B = (S[0]==S[-1])*1
if A==1 and B==1:
    print("Second")
elif A==1 and B==0:
    print("First")
elif A==0 and B==1:
    print("First")
elif A==0 and B==0:
    print("Second")


Measured memory_bytes: 67188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;
const double PI = acos(-1);

ll N = 0;

int main(void){
  double A, B, H, M;
  I(A);
  I(B);
  I(H);
  I(M);

  double hx = A * sin((H * 30 + M * 0.5) * PI / 180.0);
  double hy = A * cos((H * 30 + M * 0.5) * PI / 180.0);
  double mx = B * sin((M * 6) * PI / 180);
  double my = B * cos((M * 6) * PI / 180);

  double ret = sqrt((hx-mx)*(hx-mx) + (hy-my)*(hy-my));
  FIX;
  P(ret);

}


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

int main() {
  int a,b,c; cin>>a>>b>>c;
  if(b+c==a){cout<<"Yes"<<endl;}
  else if(a+c==b){cout<<"Yes"<<endl;}
  else if(a+b==c){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
//Volume0-0039
import java.util.*;

public class Main {
	
	public static void main(String[] args) {

		//declare
		char[] c;
		int    p,next,sum;
		
		//input
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			c = sc.nextLine().toCharArray();
			
			//initialize
			p=0;next=0;sum=0;
			
			//calculate
			for(int i=0;i<c.length;i++){
				p = chg(c[i]);
				if(i+1<c.length){next = chg(c[i+1]);}
				if(p < next){
					sum += (next - p);
					i++;
				} else {
					sum += p;
				}
			}
			
			//output
			System.out.println(sum);
		}
	}

	//translate
	private static int chg(char c){
		int ret = 0;
		switch (c) {
			case 'I':{ret =    1; break;}
			case 'V':{ret =    5; break;}
			case 'X':{ret =   10; break;}
			case 'L':{ret =   50; break;}
			case 'C':{ret =  100; break;}
			case 'D':{ret =  500; break;}
			case 'M':{ret = 1000;      ;}
		}
		return ret;
	}
}

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

int main() {
 int A, B, C;
  cin >> A >> B >> C;
  int times;
  if(A * C <= B) {
    times = C;
  }
  else {
    times = B / A;
  }
  
  
  cout << times << endl;
return 0;  
}

Measured memory_bytes: 256