akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pub push_back
#define pob pop_back

typedef vector<int> vi;
typedef vector<vi> graf;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> wgraf;

typedef vector<double> vd;
typedef pair<double,double> dd;
typedef vector<dd> vdd;

typedef uint64_t ui64;

int main(){

	int n;
	cin >> n;

	vii data(n);

	for(int i = 0; i < n; i++){

		cin >> data[i].f;
		data[i].s = i+1;

	}

	sort(data.begin(), data.end());

	for(auto x: data){

		cout << x.s << " ";

	}

	cout << endl;
	return 0;
}


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

using namespace std;

#define EPS 1e-9
#define For(i,N) FOR(i,N)
#define Forr(i,a,b) FORR(i,a,b)
#define Fotr(i,a,b,c) FOTR(i,a,b,c)
#define FOR(i,N) FORR(i, 0, N)
#define FORR(i,a,b) FOTR(i, a, b, 1)
#define FOTR(i,a,b,c) for(int i=(a);i<(b);i+=(c))
#define FOREACH(i,x) for(__typeof__((x).begin())i=(x).begin();i!=(x).end();i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define BCHK(a,x) (((a)>>(x))&1)
#define BSET(a,x) ((a)|(1<<(x)))
#define BCLR(a,x) ((a)&(~(1<<(x))))
#define BTGL(a,x) ((a)^(1<<(x)))
#define FMT(...) (sprintf(CRTBUFF, __VA_ARGS__)?CRTBUFF:0)
#define read() freopen("input.txt","r",stdin)
#define write() freopen("output.txt","w",stdout)
#define cpp_io() {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define BUFFSIZE 30000
#define INF 1000000000
#define MAX 300010
#define MOD 1000000007
#define pb push_back
#define mkpr make_pair
#define pii pair<int, int>
#define PI acos(-1)
#define ll long long
#define fi first
#define si second
#define all(x) x.begin(), x.end()

char CRTBUFF[BUFFSIZE];
#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};
ll power(ll x,ll y)
{
    if( y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);

}
int main(){
    cpp_io();
    #ifdef LOCAL
        //read();
        //write();
    #endif
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        s[i] = 'x';
    }cout<<s<<endl;





    return 0;

}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MAX = 3000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int X, Y;

	cin >> X >> Y;

	if((X+Y) % 3 != 0){
		cout << "0" << "\n";
		return 0;
	}

	// 前処理
	COMinit();

	// 連立方程式を解く
	int x = 2*Y - X;
	int y = 2*X - Y;
	ll ans;
	if(x%3 == 0 && y%3==0){
		x /= 3;
		y /= 3;
		ans = COM(x+y, x);
	}
	else{
		ans = 0;
	}
	cout << ans <<"\n";

return 0;
}

Measured memory_bytes: 70528
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.clone();
	let v:Vec<char> = buf.trim().chars().collect();
	let n:i32 = s.trim().parse().ok().unwrap();
	let mut dig:i32 = 0;
	for i in 0..v.len() {
		dig += (v[i] as i32) - ('0' as i32);
	}
	if n%dig == 0 {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
#include <stdio.h>

char map[101][101];
int hantei[100][100];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
int ans, h, w;
char mi;

void tansaku(int,int);

main(){
  int i, j;

  while(1){
    scanf("%d %d", &h, &w);
    if(h==0 && w==0) break;

    getchar();
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        scanf("%c", &map[i][j]);
        hantei[i][j]=1;
      }
      getchar();
    }

    ans=0;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(hantei[i][j]==1){
          mi=map[i][j];
          tansaku(i,j);
          ans++;
        }
      }
    }

    printf("%d\n", ans);

  }
  return 0;
}

void tansaku(int y, int x){
  int i, tx, ty;

  hantei[y][x]=0;
  for(i=0;i<4;i++){
    tx=x+dx[i];
    ty=y+dy[i];
    if(tx>=0 && tx<w && ty>=0 && ty<h){
      if(hantei[ty][tx]==1){
        if(map[ty][tx]==mi){
          tansaku(ty,tx);
        }
      }
    }
  }

  return;
}

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

int main()
{
	int d=D;
	int i,j,k,l;
	int c[26]={0};
	int s[D][26]={0};
	int t[365]={0};


	int bestcon[365]={0};
	int bestnum=0;


	scanf("%d",&d);
	for(i=0;i<26;i++)
    {
	    scanf("%d",(&c[i]));
    }
    for(j=0;j<365;j++)
    {
        bestnum=0;
        for(k=0;k<26;k++)
        {
            scanf("%d",(&s[j][k]));

            if(bestnum<s[j][k])
            {
                bestnum=s[j][k];
                bestcon[j]=k;
            }

        }
    }
    // input 終了

    int work=0;

    for(j=0;j<365;j++)
    {
        t[j]=j%26;
    }
    for(j=0;j<364;j++)
    {
        int phase=j/26;
        work=t[j];
        t[j]=t[phase*26+bestcon[j]];
        t[phase*26+bestcon[j]]=work;

        //t[j]=t[j%26];
    }
    t[364]=bestcon[364];
    //printf("ttt:%d\n",t[364]);
    for(j=0;j<364;j++)
    {
        t[j]=t[(j%26)];
    }

    //scoring　開始
    int date=0;
    int last[26]={0};
    int satis=0;

    for(date=0;date<365;date++)
    {
        int todays_con=t[date];
        satis+=s[date][todays_con];
        last[todays_con]=date;
        for(k=0;k<26;k++)
        {
            if(k==todays_con)continue;
            else
            {
                satis-=(c[k]*(date-last[k]));
            }
        }

    }

    //scoring 終了
    //printf("ttt:%d\n",t[364]);
    // output 開始
	for(i=0;i<365;i++)
    {
	    int phase=i/26;
	    //if(t[i]==0)t[i]++;
	    printf("%d\n",t[i]+1);
    }

	//printf("%d",satis);
}

Measured memory_bytes: 1776
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
//#pragma optimize GCC("O3")
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	// kazde cislo zo vstupu sa da zapisat
	// ako x/(2^a*5^b)
	// Kazde x mozme upravit do takehoto tvaru pomocou gcd.
	// Nech b[i] = 10^9 * a[i]. potom a[i] = b[i]/(2^9*5^9)
	// Zaujimaju nas len mocniny 2 a 5 v b.
	vector<pair<ll, ll> > a(n);
	const ll c = 9;
	vector<vector<ll> > f(c * 2+7, vector<ll>(c * 2+7, 0));
	ll good = 0;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		int b = -1;
		for (int j = 0; j < s.size(); j++)
		{
			if (s[j] == '.')
			{
				b = j;
				break;
			}
		}
		if (b == -1)
		{
			s.push_back(b);
			b = s.size() - 1;
		}
		s.resize(b + 10, '0');
		s.erase(s.begin() + b);
		ll num = stoll(s);
		//cout << num << endl;
		a[i].first = -c;
		a[i].second = -c;
		while (num % 2 == 0)
		{
			num /= 2;
			a[i].first++;
		}
		while (num % 5 == 0)
		{
			num /= 5;
			a[i].second++;
		}
		a[i].first = min(a[i].first, c); // viac ako 9 nebudeme potrebovat
		a[i].second = min(a[i].second, c); // viac ako 9 nebudeme potrebovat
		for (int c2 = -c; c2 <= c; c2++)
		{
			for (int c5 = -c; c5 <= c; c5++)
			{
				if (a[i].first + c2 >= 0 && a[i].second + c5 >= 0)
				{
					good += f[c2 + c][c5 + c];
				}
			}
		}
		f[a[i].first + c][a[i].second + c]++;
	}
	cout << good << "\n";
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int k;
	cin>>k;
	int h[n+1];
	for(int i=1; i<=n; i++) cin>>h[i];
	
	if(k>=n-1) {cout<<h[n]-h[1]; return 0;}

	int dp[n+1];

	dp[0] = 0;
	dp[1] = 0;

	for(int i=2; i<=k+1; i++) dp[i] = abs(h[i] - h[1]);

	for(int i=k+2; i<=n; i++)
	{
		int min = INT_MAX;
		for(int j=i-1; j>=i-k; j--)
		{
			int val = dp[j] + abs(h[i]-h[j]);
			if(val < min) min = val;
		}

		dp[i] = min;
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
int main(){
  ll n,k;
  cin >>n>>k;
  ll h[n+1];
  ll dp[n+1];
  for(ll i=1;i<n+1;i++) cin >>h[i];
  for(ll i=0;i<n+1;i++) dp[i]=1e13+7;
  dp[1]=0;//足場1動かなくていいので0
  dp[2]=abs(h[2]-h[1]);
  for(ll i=3;i<n+1;i++){
    ll d=1e13;
    for(ll j=1;j<=k;j++){
      if(i-j<=0) continue;
      d=min(d,dp[i-j]+abs(h[i-j]-h[i]));
    }
    dp[i]=d;
  }
  cout << dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#define repi(i,x,n) for(int i = x; i < n; i++)
#define rep(i,n) repi(i,0,n)
#define int long long
using namespace std;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int EPS = 1e-7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    double T, D; cin >> T >> D;
    double t1, t2; cin >> t1 >> t2;
    double d1, d2; cin >> d1 >> d2;
    double ans = INF;
    for(int i = 0; i <= D; i++)
    {
        for(int j = 0; j <= D; j++)
        {
            if(i == 0 and j == 0) continue;
            if(d1 * i + d2 * j > D) continue;;
            double a = (d1 * i) / 1000, b = (d2 * j) / 1000;
            double k = (t1 * a + t2 * b) / (a + b);
            ans = min(ans, abs(k - T));
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3300
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;


int main() {
  string S;
  cin >> S;
  int number[S.size()];
  long S_int = stol(S);

  for(int i=0;i<S.size();i++){
    number[i] = S_int%10;
    S_int /= 10;
  }
  
  long ans = 0;

  for(long i=0;i<(1<<(S.size()-1));i++){
    long temp = i;
    long factor = 1;
    ans += (number[0]);
    for(int j=1;j<S.size();j++){

      if(temp&0b1){
        factor = 1;
      }else{
        factor *= 10;
      }

      temp >>= 1;

      ans += (number[j]*factor);
    }
  }


  cout << ans << endl;
  
}


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

int main(){
    int x, i=0, r=0;
    cin >> x;
    while(r!=360){
        ++i;
        r += x;
        if(r > 360) r -= 360;
    }
    cout(i);
}


Measured memory_bytes: 3632
def main():
    a, b, k = [int(s) for s in input().split()]

    for i in range(k):
        if i % 2 == 0:
            a, b = play(a, b)
        else:
            b, a = play(b, a)

    print(a, b)

def play(a, b):
    return (a // 2, b + a // 2)

main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[2000], cpy[2000];
	int len, i;
	
	fgets(str, 2000, stdin);
	
	len = strlen(str);
	
	for (i = 0; i < len; i++){
		if (strncmp(&str[i], "apple", 5) == 0){
			strncpy(&cpy[i], "peach", 5);
			i += 4;
		}
		else if (strncmp(&str[i], "peach", 5) == 0){
			strncpy(&cpy[i], "apple", 5);
			i += 4;
		}
		else cpy[i] = str[i];
	}
	cpy[i] = '\0';
	
	printf("%s", cpy);
	
	return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

string s;
int n;

bool possible( int k ){
	if( n > 2*k ) return true;
	else{
		bool res = true;
		for( int i = n-k; i < k-1; ++i ){
			if( s[i] != s[i+1] ) res = false;
		}
		return res;
	}
}

int main(){
	cin >> s;
 	n = s.l_ength();
  	int ok = 1;
	int ng = n+1;
	while( ng-ok > 1 ){
		int mid = (ok+ng)/2;
		if( possible(mid) ){
			ok = mid;
		} else {
			ng = mid;
		}
	}
	cout << ok << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define dfor(i,a,b) for(int i=(a);i<(b);++i)
#define drfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define drep(i,n) dfor(i,0,n)
#define drrep(i,n) drfor (i,n,0)
#define dump(x)  cout << #x << " = " << (x) << endl;

const double EPS = 1e-10;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

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

	int n, x;
	cin >> n >> x;
	if ((x == 1) || (x == n * 2 - 1)) {
		cout << "No";
		return 0;
	}
	else {
		cout << "Yes\n";
	}
	if (x == n) {
		drep(i, n * 2 - 1) {
			cout << i+1 << "\n";
		}
		return 0;
	}
	if (x > n) {
		drep(i, n - 1) {
			cout << i+1 << "\n";
		}
		drfor(i, n,x + 2) {
			cout << i << "\n";
		}
		drfor(i, x + 2,2*n) {
			cout << i << "\n";
		}
	}
	else {
		x = 2 * n - x;
		drep(i, n - 1) {
			cout << 2*n-i-1 << "\n";
		}
		drfor(i, n,x+2) {
			cout << 2*n-i << "\n";
		}
		drfor(i, x + 2,n*2) {
			cout << 2*n-i << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

void NO(){ cout<<-1<<'\n'; exit(0); }

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	//freopen("C5.in","r",stdin);
	
	int n; cin>>n;
	ll a[n+1]{};
	ll suf[n+1]{};
	forn(i,0,n+1){
		cin>>a[i];
	}
	
	for(int i=n;i>=0;i--){
		suf[i]=a[i];
		if(i<n) suf[i]+=suf[i+1];
	}
	
	ll cur=1;
	ll ans=0;
	
	bool mode=0;
	forn(i,0,n+1){
		if(!mode){
			if(cur>=suf[i]){
				mode=1;
				cur=suf[i];
				ans+=cur;
				cur-=a[i];
			}
			else{
				ans+=cur;
				cur-=a[i];
				if(cur<0) NO();
				cur<<=1;
			}
		}
		
		else{
			ans+=cur;
			cur-=a[i];
		}
		//watch(i); watch(mode); watch(ans); watch(cur); cout<<'\n';
	}
	
	if(!mode) cout<<-1<<'\n';	
	else cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 5176
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
//#include <boost/graph/adjacency_list.hpp>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name) 

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	IN_VW(string, sls, n) { cin >> x; sort(x.begin(), x.end()); };

	map<string, ll> dcount;
	for (auto& s : sls) {
		++dcount[s];
	}

	ll count = 0;
	for (auto& c : dcount) {
		count += (c.second * (c.second - 1)) / 2;
	}

	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_V = 2e5;

struct union_find_tree{
    int par[MAX_V], rank[MAX_V], num[MAX_V];
    //要素数n(0〜n-1)の初期化されたUnion-Find木を構築
    union_find_tree(int N){
        rep(i, N){par[i] = i, rank[i] = 0, num[i] = 1;}
    }
    //ノードxの根を取得
    int find(int x){
        if(par[x] == x) return x;
        else return find(par[x]);
    }
    //xとyの属する集合を併合
    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return;
        elif(rank[x] < rank[y]){par[x] = y, num[y] += num[x];}
        else{
            par[y] = x, num[x] += num[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    //xの属する集合の要素数を取得
    int size(int x){
        return num[find(x)];
    }
    //xとyが同じ集合に属するか判定
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    int A[M], B[M], C[K], D[K];
    union_find_tree uft(N);
    rep(i, M){
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
        uft.unite(A[i], B[i]);
    }
    rep(i, K){
        cin >> C[i] >> D[i];
        C[i]--, D[i]--;
    }
    int ans[N];
    rep(i, N){
        ans[i] = uft.size(i)-1;
    }
    rep(i, M){
        if(uft.same(A[i], B[i])){
            ans[A[i]]--, ans[B[i]]--;
        }
    }
    rep(i, K){
        if(uft.same(C[i], D[i])){
            ans[C[i]]--, ans[D[i]]--;
        }
    }
    rep(i, N){
        cout << ans[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 4480
#include<iostream>
#include<queue>

using namespace std;
static const int N=100;
static const int I=(1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i]=I;
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front(); q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v]==0) continue;
      if(d[v]!=I) continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout << i+1 << " " << ( (d[i]==I) ? (-1) : d[i]) << endl;
  }
}

int main(){
  int u,k,v;

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

  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v]=1;
    }
  }

  bfs(0);

  return 0;
}



Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long N = input[0], K = input[1];

        var bigArray = new SortedDictionary<long, long>();

        for(var i = 0; i < N; ++i)
        {
            var num_times = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long num = num_times[0], times = num_times[1];
            if (!bigArray.ContainsKey(num))
                bigArray.Add(num, 0);
            bigArray[num] += times;
        }

        foreach(KeyValuePair<long, long> num_times in bigArray)
        {
            K -= num_times.Value;
            if (K > 0) continue;
            Console.WriteLine(num_times.Key);
            return;
        }
    }
}

Measured memory_bytes: 23212
s = input()
k = int(input())

change = []
tmp = 1
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        tmp += 1
    else:
        change.append(tmp)
        tmp = 1
change.append(tmp)

#print(change)

ret = 0
if len(change) >= 3:

    for i in range(1, len(change) - 1):
        ret += change[i] // 2 * k
    
    if s[0] == s[-1]:
        ret += (change[0] + change[-1]) // 2 * (k - 1) + change[0] // 2 + change[-1] // 2
    else:
        ret += (change[0] // 2 + change[-1] // 2) * k
elif len(change) == 2:
    ret = (change[0] // 2 + change[1] // 2) * k
else:
    ret = change[0] * k // 2

print(ret)

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  vector<int> occ(128, 0);
  int ch = -1;
  while ((ch = getchar()) != EOF) {
    ++occ[tolower(ch)];
  }
  for (int i = 'a'; i <= 'z'; ++i) {
    fprintf(stdout, "%c : %d\n", i, occ[i]);
  }
  return 0;
}

Measured memory_bytes: 1136
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var n = Read();
            var a = Reads();
            long min =long.MaxValue;
            for (int i = 0; i < n; i++)
            {
                long count = 0;
                while (a[i]%2==0)
                {
                    a[i] /= 2;
                    count++;
                }
                min = Math.Min(min, count);
            }
            Console.WriteLine(min);



            Console.Out.Flush();
        }
    }
}




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

int n,m;
int g[110][110], deg[110];
vector<int> V, use;

int rec(int d, int k){
  if(k==0){
    int res = 0;
    for(int a : use){
      int minv = 1e9;
      for(int b: use){
	if(a!=b)minv = min(minv, g[a][b]);
      }
      res += minv;
    }
    return res;
  }
  if(d==(int)V.size())return 0;

  int res = rec(d+1,k);

  if(k>0){
    for(int a : use){
      if(!g[a][V[d]])return res;
    }

    use.push_back(V[d]);
    res = max(res, rec(d+1,k-1));
    use.pop_back();
  }
  return res;
}

int max_clique(int k){
  V.clear();
  rep(i,n){
    if(deg[i]>=k-1)V.push_back(i);
  }
  return rec(0,k);
}

int main(){
  cin >> n >> m;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c; a--; b--;
    g[a][b] = g[b][a] = c;
    deg[a]++; deg[b]++;
  }

  int res = 0;
  for(int k=2;k*(k-1)/2<=m;k++)res = max(res, max_clique(k));
  cout << res << endl;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

int N, K;

vector<vector<int>> tree(100100);
vector<bool> visited(100100, false);
int ans = 1;

vector<int> cnts(100100, 0);

void search(int sear, int len)
{
  if (visited.at(sear)) {cnts.at(len)--; return;}
  visited.at(sear) = true;
  
  int cnt = cnts.at(len);
  
  if (len == 0) ans *= K;
  else if (len == 1) ans *= max((int)0, K - 1 - cnt);
  else ans *= max((int)0, K - 2 - cnt);
  ans %= MOD;
  
  cnts.at(len + 1) = 0;
  for (int i = 0; i < tree.at(sear).size(); i++)
  {
    search(tree.at(sear).at(i), len + 1);
    cnts.at(len + 1)++;
  }
  return;
}

signed main()
{
  cin >> N >> K;

  for (int i = 0; i < N - 1; i++)
  {
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree.at(a).push_back(b);
    tree.at(b).push_back(a);
  }
  
  search(0, 0);
  cout << ans << endl;
}

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

#define ll long long
const int inf = 1e9+7;
const ll INF = 1e18+7;

using namespace std;

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

  int n;
  cin>>n;
  int M = 0, m = 1e9+7;
  for(int i =0; i < n; ++i){
    int tmp;
    cin >>tmp;
    M = max(M,tmp);
    m = min(m,tmp);
  }
  cout<<M-m<<"\n";
}


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

public class a {
 static void Main(){
   int[] ab = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
   int[] res = new int[3]{ab[0]+ab[1],ab[0]-ab[1],ab[0]*ab[1]};
   Console.WriteLine(res.Max());
   
 }
}


Measured memory_bytes: 27596
# include <bits/stdc++.h>
# define se second
#define fe first
using namespace std;
int main()
{
int n, maximum = 0;
cin >> n;
string s;
map <string, int> mapp;
for (int i = 0 ; i < n ; ++ i) {
    cin >> s;
    mapp[s]++;
    maximum = max(maximum, mapp[s]);
}

for (auto i: mapp) {
    if (i.second == maximum) {
        cout << i.first << '\n';
    }
}
}


Measured memory_bytes: 25216
n=int(input())
a=[0]
for _ in range(n):
    a.append(int(input()))
b=[0]*(n+1)
i=1
ans=0
while b[i]==0 and i!=2:
    b[i]=1
    i=a[i]
    ans+=1
print(ans if i==2 else -1)





Measured memory_bytes: 7884
n = int(input())
G = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append((b, c))
    G[b].append((a, c))

Q, k = tuple(map(int, input().split()))
INF = 10**9*n + 1
dists = [INF] * n
dists[k-1] = 0

from collections import deque
q = deque([k-1])
visited = [0] * n
visited[k-1] = 1

while q:
    node = q.popleft()
    for to, c in G[node]:
        if visited[to] == 1:
            continue

        if dists[to] > dists[node] + c:
            dists[to] = dists[node] + c
            q.append(to)

for _ in range(Q):
    s, g = tuple(map(int, input().split()))
    print(dists[s-1] + dists[g-1])


Measured memory_bytes: 48312
#include <iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n;cin>>n;
	vector<string> w(n);
	for(int i=0;i<n;i++){
		cin>>w[i];
	}
	int flag=1;
	char ex=w[0].back();
	for(int i=1;i<n;i++){
		if(w[i][0]!=ex){
			flag=0;
			break;
		}
		ex=w[i].back();
		for(int j=0;j<i;j++){
			if(w[i].size()==w[j].size()){
				int flag2=0;
				for(int k=0;k<w[i].size();k++){
					if(w[i][k]!=w[j][k])flag2=1;
				}
				if(flag2==0)flag=0;
			}
		}

	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main implements Runnable{
    
    private void solve()throws IOException{
        HashSet<Integer> set=new HashSet<>();
        int n=nextInt();
        for(int i=1;i<=n;i++){
            int a=nextInt();
            if(set.contains(a)){
                out.println("NO");
                return;
            }
            set.add(a);
        }
        out.println("YES");
    }

     
    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    } 
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 54780
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <stack>

#define rep(i, n) for(int i=0;i<n;i++)
#define IOS() ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define INT_MINI -987654321
#define INT_MAXI 987654321
#define ABS(X) ((X) < 0 ? -(X) : (X))


using namespace std;

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

long double a, b, c;


void input() {

    cin >> a >> b >> c;
}

void process() {

    long double aa, bb, cc;
    long double eps = 1.0E-14;
    aa = sqrt(a);
    bb = sqrt(b);
    cc = sqrt(c);


    //if(aa + bb + eps < cc)
    if(sqrt(a) + sqrt(b) + eps < sqrt(c)){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

int main() {

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    input();
    process();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    int d = a / b;
    int r = a % b;
    double f = double(a) / double(b);
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed << setprecision(5) << f;
    cout << endl;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pie  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
} 
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    
    cin>>n;
    a = n%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9)
        cout<<"hon";
    else if(a==0 || a==1 || a==6 || a==8)
        cout<<"pon";
    else
        cout<<"bon";   
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
int a[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    int cnt = 0, mn = (int)1e9;
    LL sum = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &a[i]);
        if (a[i] < 0) {
           a[i] *= -1;
           cnt++;
        }
        sum += a[i];
        mn = min(mn, a[i]);
    }
    if (cnt % 2) printf("%lld\n", sum - 2 * mn);
    else printf("%lld\n", sum);
    return 0;
}


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

const int MAX_N = 1e5 + 6;

int a[MAX_N];

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	while (cin >> n) {
		string s;
		cin >> s;
		s= " "+s;
		s += "   ";
		s[n+1]=s[1];
		s[n+2]=s[2];
		s[n+3]=s[3];
		string ans="  ";
		bool ans_get=0;
		for (int ala=0;2>ala;ala++) {
			for (int ala1=0;2>ala1;ala1++) {
				a[1] = ala;
				a[2] = ala1;
				for (int i=2;n+1>=i;i++) {
					if (s[i]=='o') {
						if (a[i]==0) a[i+1]=a[i-1];
						else a[i+1]=1-a[i-1];
					}
					else if (s[i]=='x') {
						if (a[i]==0) a[i+1]=1-a[i-1];
						else a[i+1]=a[i-1];
					}
				}
				if (a[n+1]==a[1] && a[n+2]==a[2]) {
					ans_get=1;
					for (int i=1;n>=i;i++) {
						if (a[i]) cout<<'W';
						else cout<<'S';
					}
					cout<<endl;
					break;
				}
			}
			if (ans_get) break;
		}
		if (!ans_get) cout<<"-1"<<endl;
	}
}

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

void solve(){
  int n,x,t;
  cin>>n>>x>>t;
  cout<<(n+x-1)/x*t;
}

int32_t main()
{
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  
  if (n == 1)
    cout << 1 << endl;
  else if ( n % 2 == 0 )
    cout << 0.5 << endl;
  else
    cout << double(n + 1) / 2 / n << endl;
  
}

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

#define Int long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

Int N,M,K;
Int X,Y,Z,D;

Int B,C;

const int MOD=(int)(1e9+7);
const int MAXN=500005;


vector<Int> adj[MAXN];
vector<Int> degree;
bool VIS[MAXN];     

void vector_input(){
     vector<Int> A(5);
     for(auto &x:A) cin>>x;
}


int main()
{
       string S,T;cin>>S>>T;
       Int K=T.length();
       Int ans=0;
       Int best=1e9;
       string form="";
       
       for(int i=0;i<K;++i){
           form.pb(S[i]);
       }
       for(int i=0;i<form.length();++i){
           if(form[i]^T[i]) ++ans;
       }
       best=min(best,ans);
       
       for(int i=K;i<S.length();++i){
           form.erase(form.begin());
           form.pb(S[i]);
           ans=0;
           for(int j=0;j<form.length();++j){
               if(form[j]^T[j]) ++ans;
           }
           best=min(best,ans);
       }
       cout<<best<<"\n";
}

Measured memory_bytes: 15352
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 1000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

int n;
double v[MAX_N];
double ans;

int main() {

  cin >> n;
  rep(i, n) cin >> v[i];

  sort(v, v+n);

  ans = (v[0]+v[1])/2;

  for(int i=2; i<n; ++i) {
    ans = (v[i]+ans)/2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    Set<Integer> r = new HashSet<>();
    Set<Integer> g = new HashSet<>();
    Set<Integer> b = new HashSet<>();
    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'R') r.add(i);
      else if (s.charAt(i) == 'G') g.add(i);
      else b.add(i);
    }
    long result = (long) r.size() * (long) g.size() * (long) b.size();
    for (int i : r) {
      for (int j : g) {
        int small = Math.min(i, j);
        int big = Math.max(i, j);
        int diff = big - small;
        if (b.contains(small - diff)) result--;
        if (b.contains(big + diff)) result--;
        if (diff % 2 == 0 && b.contains(small + diff / 2)) result--;
      }
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 44568
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 100000;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 0, s = 0;
    vector<int> v(n);
    for (int i = 0; i < n-1; ++i) {
        int k;
        scanf("%d", &k);
        (s += k) %= MOD;
        v[i+1] = s;
    }
    int cur = 0;
    for (int i = 0; i < m; ++i) {
        int x;
        scanf("%d", &x);
        if(x > 0){
            (ans += v[cur+x]-v[cur]+MOD) %= MOD;
        }else {
            (ans += v[cur]-v[cur+x]+MOD) %= MOD;
        }
        cur += x;
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3396
#include "bits/stdc++.h"
using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    int cnt = 0;
    int ans = 0;
    for (int i = min(A, B); i >= 0; i--) {
        if (A % i == 0 && B % i == 0) cnt++;
        if (cnt == K) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
function main(input) {
  const inputs =input.split('\n')
  const [N] = inputs[0].split(' ').map(Number)
  const X = inputs[1].split(' ').map(Number)

  let min = Number.MAX_SAFE_INTEGER
  for (let i = 1; i <= 100; i++) {
    let sum = 0
    for (let j = 0; j < N; j++) {
      sum += Math.pow(X[j] - i, 2)
    }
    if (sum < min) min = sum
  }
  console.log(min)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29528
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int ans = INF;
	int N, M, X;
	vector<vector<int>> A;
	vector<int> C;
	
	cin>>N>>M>>X;
	
	A.resize(N, vector<int>(M));
	C.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>C[i];
		
		for(int j = 0; j < M; j++){
			cin>>A[i][j];
		}
	}
	
	for(int i = 0; i < 1<<N; i++){
		int sum = 0;
		vector<int> a(N);
		bool flag = true;
		
		for(int j = 0; j < N; j++){
			if(!((i>>j)&1)) continue;
			sum += C[j];
			
			for(int k = 0; k < M; k++){
				a[k] += A[j][k];
			}
		}
		
		for(int k = 0; k < M; k++){
			if(a[k] < X)  {
				flag = false;
				break;
			}
		}
		
		if(flag) ans = min(sum, ans);
	}
	
	if(ans == INF) cout<<-1<<endl;
	else cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

class UnionFind {
private:
    int sz; vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){ if(par[x] == x) return x; else return par[x] = find(par[x]); }
    void unite(int x,int y)
    { x = find(x), y = find(y); if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y); par[y] = x, size_[x] += size_[y]; }
    int size(int x){ x = find(x); return size_[x]; }
    bool same(int x,int y){ return find(x) == find(y); }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int cnt[4] = {};
    UnionFind uf(4);
    rep(i,3){
        int a,b;
        cin >> a >> b;
        uf.unite(a-1, b-1);
        cnt[a-1]++, cnt[b-1]++;
    }
    if(uf.size(0) != 4){
        cout << "NO\n";
        return 0;
    }
    int hoge = 0;
    rep(i,4){
        if(cnt[i]%2 == 1){
            hoge++;
            if(hoge >= 3){
                cout << "NO\n";
                return 0;
            }
        }
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
for i in range(n):
    s = int(raw_input())
    print "Case %d:"%(i+1)
    for j in range(10):
        if len(str(s**2)) < 3:
            s = 0
        else:
            s =int(str(s**2)[-6:-2])
        print s

Measured memory_bytes: 4208
const Main = (input) => {
  const tmp = parseInt(input.trim())
  const FizzBuzzArray = []

  for (let i = 0; i < tmp; i++) {
    if ((i + 1) % 3 === 0 || (i + 1) % 5 === 0) {
      FizzBuzzArray.push('0')
    } else {
      FizzBuzzArray.push(i + 1)
    }
  }

  let result = 0
  FizzBuzzArray.forEach((elem) => {
    result += parseInt(elem)
  })

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

bool checkPalindome(string s) {
    if (s.length() == 1) return true;
    rep(i, s.length() / 2 + 1) {
        if ((char)s[i] != (char)s[s.length() - i -1]) return false;
    }
    return true;
}

int main() {
    string S;
    cin >> S;
    int n = S.length();

    if (
            checkPalindome(S)
            && checkPalindome(S.substr(0, ((n-1)/2)))
            && checkPalindome(S.substr((n+3)/2 - 1, n))
            ) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256