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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define int long long

#define upper(n,m) (n+m-1)/m
#define rounding(n) (int)((double)n+0.5)

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define ALL(a) a.begin(),a.end()

#define coutALL(i,a) {int i=0;for(int e:a) cout<<(i++?" ":"")<<e; cout<<endl;}
#define coutYN(a) cout<<(a?"Yes":"No")<<endl;
#define coutyn(a) cout<<(a?"yes":"no")<<endl;

#define deb cout<<"debug"<<endl
#define debn(n) cout<<"debug: "<<n<<endl

const int INF=INT_MAX;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
//const int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using namespace std;

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

int ncm(int n,int m){

  int r=1;

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

    r*=m-i+1;
    r/=i;

  }

  return r;

}


signed main(){

  ios::sync_with_stdio(false);

  int n,a,b;
  cin>>n>>a>>b;

  vector <int> v(n);
  REP(i,n) cin>>v[i];

  sort(ALL(v),greater <int>());

  long double ave[51]={},max_ave=0;

  REAP(i,a,b+1){

    REP(j,i)  ave[i]+=v[j];
    ave[i]/=i;
    max_ave=max(max_ave,ave[i]);

  }

  int ans=0;

  REP(i,51){

    if(ave[i]!=max_ave) continue;

    vector <int> num;
    set <int> num_list;
    int r=1;

    REP(j,i) num_list.insert(v[j]),num.pb(v[j]);

    for(int e:num_list){

      int x=count(ALL(num),e),y=count(ALL(v),e);
      r*=ncm(x,y);

    }

    ans+=r;

  }

  cout<<setprecision(10)<<fixed<<max_ave<<endl<<ans<<endl;

  return 0;

}


Measured memory_bytes: 256
pri = {'S':0,'H':13,'C':26,'D':39}
total_cards = set()
for pic in pri.keys():
	for rank in range(1,14):
		total_cards.add(pic + ' ' + str(rank))
cards = set()
for _ in range(eval(input())):
	cards.add(input())
no_cards = list(total_cards - cards)
no_cards.sort(key = lambda c: pri[c[0]] + int(c[2:]))
for i in range(len(no_cards)):
	print(no_cards[i])

Measured memory_bytes: 7580
#include <iostream>
using namespace std;
int main() {
    //a<= c && b>= c
    int a,b,c = 0;
    bool yn = false;
    cin >> a >> b >> c;
    if(a <= b){
        if(b >= c){
            yn = true;
        }
    }
    if(yn == false){
        cout << "No";
    }else{
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll q;
  cin >> q;
  multiset<ll, greater<ll>> st1;
  multiset<ll> st2;
  ll ans = 0;
  rep(i, q) {
    ll t;
    cin >> t;
    if(t == 1) {
      ll a, b;
      cin >> a >> b;
      ans += b;
      if(st1.empty()) {
        st1.insert(a);
        st2.insert(a);
      } else {
        ll l = *st1.begin();
        ll r = *st2.begin();
        if(a < l || r < a) ans += min(abs(l - a), abs(r - a));
        if(a < l) {
          st1.erase(st1.begin());
          st2.insert(l);
          st1.insert(a);
          st1.insert(a);
        } else if(a > r) {
          st2.erase(st2.begin());
          st1.insert(r);
          st2.insert(a);
          st2.insert(a);
        } else {
          st1.insert(a);
          st2.insert(a);
        }
      }
    } else {
      cout << *st1.begin() << ' ' << ans << endl;
    }
  }
}

Measured memory_bytes: 18944
//file_name:ABC48_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string a,s,c;
    cin >> a >> s>> c;


    cout << a[0] << s[0] << c[0] << endl;

    return 0;
}



Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;*/
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
typedef long long ll;
typedef pair<ll, ll> Pa;

/*
template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

typedef modint<MOD> m;
m func[400001];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
m comb(m n, m r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}*/

int a[100000], b[100000];
int main() {
	int mina = 100000, minb = 100000;
	cin >> A >> B >> M;
	rep(i, A) {
		cin >> a[i];
		mina = min(mina, a[i]);
	}
	rep(i, B) {
		cin >> b[i];
		minb = min(minb, b[i]);
	}
	ll mv = mina + minb;
	rep(i, M) {
		cin >> x >> y >> C;
		mv = min(mv, a[x - 1] + b[y - 1] - C);
	}
	cout << mv;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	int n;
	cin>>n;
	vector<ll>h(n);
	for(int i=0;i<n;i++)cin>>h[i];
	bool ok = 1;
	h[0]--;
	for(int i=1;i<n;i++){
		if(h[i] > h[i-1])h[i]--;
		if(i < n-1 && h[i] > h[i+1]){ok = 0;break;}
	}
	if(ok)cout<<"Yes"<<'\n';
	else cout<<"No";
	
}


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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> l(n * 2);
	for (int i = 0; i < n * 2; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int sum = 0;
	for (int i = 0; i < n * 2; i += 2) {
		sum += l[i];
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
int main() {
	int n;
	cin >> n;
	int ans = 0;

	rep(i, n) {
		int a;
		cin >> a;
		if ((i + 1) % 2 != 0 && a % 2 != 0) {
			ans += 1;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main(void){
  int n;
  char s[4];
  int c[4]={};

  scanf("%d", &n);

  for (int i = 0; i < n;i++){
    scanf("%s", s);
    if(strcmp(s,"AC")==0){
      c[0]++;
    }else if(strcmp(s,"WA")==0){
      c[1]++;
    }else if(strcmp(s,"TLE")==0){
      c[2]++;
    }else if(strcmp(s,"RE")==0){
      c[3]++;
    }
  }

  printf("AC x %d\n", c[0]);
  printf("WA x %d\n", c[1]);
  printf("TLE x %d\n", c[2]);
  printf("RE x %d\n", c[3]);
  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
//char Input[40*1024*1024+5],*pos;
//#define Read() (strtol(pos,&pos,10))
long long Len[100050];
long long Dis[100050];
long long res[100050];
int fres[100050];
int Hash[100500];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//fread(Input,40*1024*1024,1,stdin);
	//pos=Input;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&Len[i]);
		Dis[i]=Len[i];
	}
	sort(Dis+1,Dis+n+1);
	int cnt=unique(Dis+1,Dis+n+1)-(Dis+1);
	for(int i=1;i<=n;i++){
		res[i]=lower_bound(Dis+1,Dis+cnt+1,Len[i])-Dis;
		fres[ res[i] ]=Len[i];
	}
	for(int i=1;i<=n;i++)
		Hash[ res[i] ]++;
	long long Ans=1;
	int Counter=0;
	for(int i=cnt;i>=1;i--){
		while(Hash[i]>=2){
			Counter++;
			Ans*=fres[i];
			Hash[i]-=2;
			if(Counter==2)
				break;
		} 
		if(Counter==2)
			break;
	}
	if(Counter==2)
		printf("%lld\n",Ans);
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 3328
N,K=map(int,input().split())
A=list(map(int,input().split()))
Mod=10**9+7
ans_first=0
ans_sec=0
for i in range(len(A)-1):
  for j in range(i,len(A)):
    if A[i]>A[j]:
      ans_first+=1
for i in A:
  for j in A:
    if i > j:
      ans_sec+=1
if K%2==0:
  tmp=(2*ans_first+(K-1)*ans_sec)%Mod
  K=K//2
  ans=(tmp*K)%Mod
else:
  tmp=(ans_first+(K-1)//2*ans_sec)%Mod
  ans=(tmp*K)%Mod
print(ans)



Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        const long mod = 998244353;

        // 入力
        long n = long.Parse(Console.ReadLine());
        long[] d = Console.ReadLine().Split().Select(long.Parse).ToArray();


        var max = d.Max();
        var array = new long[max + 1];
        for (int i = 0; i < d.Length; i++)
        {
            array[d[i]]++;
        }

        long ans = 1;
        long count = 0;
        long parent = 0;

        if (d[0] != 0 || array[0] != 1)
        {
            ans = 0;
        }
        else
        {
            for (int i = 1; i < array.Length; i++)
            {
                for (int j = 0; j < array[i]; j++)
                {
                    ans *= array[i - 1];
                    ans %= mod;
                }
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 36620
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long a, b, c;
    scan(a, b, c);
    (a + b).min(b + c).min(a + c).writeln();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n;
cin >> n;
int a;
int cur=1;
rep(i,n){
    cin >> a;
    if(cur==a)cur++;
}
if(cur==1){
    fin(-1);
    return 0;
}
fin(n-cur+1);

//////////////////////////////////////////////////////
return 0;}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N - 1);
	for(auto &x: A) cin >> x;
	for(auto &x: B) cin >> x;
	for(auto &x: C) cin >> x;

	int sum = 0;
	for(int i = 0, prev = INT_MAX; i < N; i++) {
		int j = A[i] - 1;
		sum += B[j];
		if(prev == j - 1) sum += C[prev];
		prev = j;
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

char a[200001];
char b[200001];

int main() {
	int h, w, n;
	scanf("%d %d %d", &h, &w, &n);

	int x, y;
	scanf("%d %d", &x, &y);

	scanf("%s %s", a, b);
	for (int i = 0; i < n; i++) {
		v.push_back(a[i]);
		v.push_back('#');
	}

	for (int i = 0; i < n; i++)
		v[i * 2 + 1] = b[i];

	int lh = 1, uh = h, lw = 1, uw = w;
	for (int i = 2 * n - 1; i >= 0; i--) {
		if (i % 2 == 1) {
			if (v[i] == 'U')
				uh = min(h, uh + 1);
			if (v[i] == 'D')
				lh = max(1, lh - 1);
			if (v[i] == 'L')
				uw = min(w, uw + 1);
			if (v[i] == 'R')
				lw = max(1, lw - 1);
		}
		else {
			if (v[i] == 'U')
				lh++;
			if (v[i] == 'D')
				uh--;
			if (v[i] == 'L')
				lw++;
			if (v[i] == 'R')
				uw--;
		}

		if (lh > uh || lw > uw) return !printf("NO");
	}
	
	if (!(lh <= x && x <= uh && lw <= y && y <= uw)) return !printf("NO");
	printf("YES");
}

Measured memory_bytes: 2804
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) r.begin(),r.end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;



int main(){
	double xa,ya,xb,yb,xc,yc,xd,yd;
	double xab,yab,xcd,ycd;
	while(cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd){
		xab=xb-xa;
		yab=yb-ya;
		xcd=xd-xc;
		ycd=yd-yc;
		if(fabs(xab*xcd+yab*ycd)<EPS)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 1216
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n = i_input()
    a = i_list()

    total = sum(a)

    ans = INF
    trial = 0
    for i in a[:-1]:
        trial += i
        left = total - trial
        ans = min(ans,abs(trial-left))
    print(ans)


if __name__=="__main__":
    main()


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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back
#define K 540001

int n, m;	
vector<int> nxt[K];

int par[K];

int q[K], head, tail;

void BFS(int u, int p) {
	par[u] = p;
	
	head++;
	q[head] = u;
	
	while (head > tail) {
		tail++;
		int v = q[tail];
		
		FOR(i, 0, nxt[v].size()) {
			int nt = nxt[v][i];
			
			if (par[nt] == 0) {
				par[nt] = v;
				head++; q[head] = nt;
			}
		}
	}
}

int main() {
	scanf("%d%d", &n, &m);
	FOE(i, 1, m) {
		int u, v; scanf("%d%d", &u, &v);
		nxt[u].pb(v);
		nxt[v].pb(u);	
	}
	
	BFS(1, -1);
	
	puts("Yes");
	FOE(i, 2, n) printf("%d\n", par[i]);
}

Measured memory_bytes: 21184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static int n;
		static double[] p;

		static double[,] dp;

		static void Main(string[] args)
		{
			n = int.Parse(Console.ReadLine());
			p = Console.ReadLine().Split().Select(double.Parse).ToArray();
			int cnt = n / 2 + 1;

			dp = new double[n + 1, cnt + 1];
			for (int i = 0; i < dp.GetLength(0); i++) {
				for (int j = 0; j < dp.GetLength(1); j++) {
					dp[i, j] = -1;
				}
			}

			double ans = Compute(cnt, 0);

			//System.Diagnostics.Debug.Write($"  ");
			//for (int i = 0; i < dp.GetLength(0); i++) {
			//	System.Diagnostics.Debug.Write($"{i,6} ");
			//}
			//System.Diagnostics.Debug.WriteLine($"");
			//for (int j = 0; j < dp.GetLength(1); j++) {
			//	System.Diagnostics.Debug.Write($"{j}:");
			//	for (int i = 0; i < dp.GetLength(0); i++) {
			//		System.Diagnostics.Debug.Write($"{dp[i, j],6} ");
			//	}
			//	System.Diagnostics.Debug.WriteLine($"");
			//}

			Console.WriteLine(ans);
		}

		static double Compute(int count, int index)
		{
			if (dp[index, count] >= 0) {
				return dp[index, count];
			}
			if (count == 0) {
				return dp[index, count] = 1;
			}
			if (count > n - index) {
				return dp[index, count] = 0;
			}

			double result = 0;
			// 表
			result += p[index] * Compute(count - 1, index + 1);
			// 裏
			result += (1 - p[index]) * Compute(count, index + 1);

			return dp[index, count] = result;
		}

	}
}

Measured memory_bytes: 48468
n = int(input())
# 人の証言の組み合わせ
say=[]
for _ in range(n):
    a = int(input())
    a_say=[]
    for _ in range(a):
        a_say.append(list(map(int,input().split())))
    say.append(a_say)

ans = 0
for hyp in range(2**n):
    # 正直者=1
    s_hyp = format(hyp,'b').zfill(n)
    
    conflict = False
    for i,say_list in enumerate(say):
        if s_hyp[i] == '0':
            continue

        for a,b in say_list:
            if s_hyp[a-1] != str(b):
                conflict = True 
                exit
        if conflict:
            exit
        
    if conflict:
        continue
    ans=max(ans,s_hyp.count('1'))

print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <cstdlib>
#define INF 998244353

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

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}



int main() {
    string s;
    cin >> s;
    if(s == "SAT"){
        cout << 1 << endl;
    }else if(s == "FRI"){
        cout << 2<< endl;
    }else if(s == "THU"){
        cout << 3<< endl;
    }else if(s == "WED"){
        cout << 4<< endl;
    }else if(s == "TUE"){
        cout << 5<< endl;
    }else if(s == "MON"){
        cout << 6<< endl;
    }else if(s == "SUN"){
        cout << 7 << endl;
    }

}








Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i;
  int h , w;
  char b[128][128]={0};
  scanf("%d %d", &h, &w);
  for(i=1; i<=h;++i){
    b[i][0]='#';
    scanf("%s", &b[i][1]);
    b[i][w+1]='#';
  }
  for(i=0;i<=w+1;++i){
    b[0][i]='#';
    b[h+1][i]='#';
  }
  for(i=0;i<=h+1;++i){
    printf("%s\n", b[i]);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int X,Y;
	cin >>X>>Y;
	
	cout <<(X*X)-Y<< endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numX = 0;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numX = scanner.nextInt();
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println((numX - numA) % numB);

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define en "\n"
#define eps 1e-9
#define VECT(v)  vector<int>v
#define SCAN(v)  int temp; for(int i=0; i<n; i++) {cin>>temp; v.push_back(temp);}
#define PRINT(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << en;
#define SORT(v)  sort(v.begin(), v.end());
#define CASEP(v) cout<<"Case "<<c<<": "<<v<<"\n"
#define DEBUG(v) cout << v << " "; cout << en;

int main(void)
{
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	fast_io
	
	string s;
	cin >> s;

	ll sum = 0;
	for(int i =  0; i < s.size(); i++)
	{
		sum += s[i] - '0';
	}	

	if(sum % 9 == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3748
N,*f = map(int, open(0).read().split())
uv = [f[i*2:i*2+2] for i in range(N-1)]
a = 0
for i in range(1,N+1):
    a += i * (N-i+1)
b = 0
for u,v in uv:
    u,v = min(u,v), max(u,v)
    b += u * (N-v+1)
print(a-b)

Measured memory_bytes: 57184
#include <stdio.h>

void bubblesort(int a[],int n);

int main(void){
	int n,length[220]={},i,max=0;
	scanf("%d",&n);
	for(i=0;i<2*n;i++){
		scanf("%d",&length[i]);
	}
	bubblesort(length,n);
	for(i=0;i<2*n;i+=2){
		max+=length[i];
	}
	printf("%d\n",max);
	return 0;
}

void bubblesort(int a[],int n){
	int i,j,t,f=0;
	while(f==0){
		f=1;
		for(i=0;i<2*n-1;i++){
			if(a[i]>a[i+1]){
				t=a[i];
				a[i]=a[i+1];
				a[i+1]=t;
			}
			for(j=0;j<2*n-1;j++){
				if(a[j]>a[j+1]){
					f=0;
				}
			}
		}
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int qmax(int a, int b){
	return (a > b) ? a : b;
}

int n, m, q;
int a[55], b[55], c[55], d[55];
int ans = 0;
int val[55];

void check(){
	int res = 0;
	rep(i, q){
		if(val[b[i]] - val[a[i]] == c[i]) res += d[i];
	}
	ans = qmax(ans, res);
}

void dfs(int now){
	if(now == n){
		check();
		return ;
	}
	for(int i = val[now-1]; i <= m; i++){
		val[now] = i;
		dfs(now+1);
	}
}

int main(){
	scanf("%d%d%d", &n, &m, &q);
	rep(i, q){
		scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
		a[i]--, b[i]--;
	}
	rep(i, m){
		val[0] = i+1;
		dfs(1);
	}
	cout << ans << endl;
	return 0;
} 

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

using namespace std;

const int N = 2e5 + 5;
int n;
long long arr[N];

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

    long long all = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        all = (all ^ arr[i]);
    }

    for(int i = 1; i <= n; i++){
        long long m = all ^ arr[i];
        cout << m << " ";
    }
    cout << '\n';
    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

int n;
int a, b, c;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if(x % 4 == 0) a++;
		else if(x % 2 == 0) b++;
		else c++;
	}

	// cerr << a << " " << b << " " << c << endl;

	if(b == 0) {
		if(c - a > 1) {
			cout << "No\n";
		} else {
			cout << "Yes\n";
		}
	} else {
		if(c - a > 0) {
			cout << "No\n";
		} else {
			cout << "Yes\n";
		}
	}

	return 0;
}

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

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    string ans="No";
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if((i*(m-j)+(n-i)*j)==k){
                ans="Yes";
                break;
            }
        }
        if(ans=="Yes") break;
    }
    cout << ans << endl;
}

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

int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    if (N % X == 0) {
        cout << (N / X) * T << endl;
    } else {
        cout << ((N / X) + 1) * T << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<int>num(N - 1);
  for (int i = 0; i < N - 1; i ++) num[i] = i + 2;
  bool load[10][10];
  for (int i = 1; i <= N; i ++) {
    for (int j = 1; j <= N; j ++) {
      load[i][j] = false;
    }
  }
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    load[a][b] = load[b][a] = true;
  }
  int ans = 0;
  do {
    bool ok = true;
    for (int i = 0; i < N - 1; i ++) {
      int p = 1;
      int n = num[i];
      if (i > 0) p = num[i - 1];
      if (!load[p][n]) ok = false;
    }
    if (ok) ans ++;
  }while(next_permutation(num.begin(), num.end()));
  cout << ans << endl;
}




Measured memory_bytes: 256
n, m = map(int, input().split())

xyz = [list(map(int, input().split())) for _i in range(n)]

r = []
for i in range(2**3):
    checker = []
    num = i
    for _i in range(3):
        if num%2==1:
            checker.append(1)
        else:
            checker.append(-1)
        num >>= 1
    _xyz = []
    for j in range(n):
        _abc = [checker[s]*xyz[j][s] for s in range(3)]
        _xyz.append([sum(_abc)]+_abc)
    _xyz.sort(reverse=True)
    _r = abs(sum(i[1] for i in _xyz[:m]))+ abs(sum(i[2] for i in _xyz[:m]))+abs(sum(i[3] for i in _xyz[:m]))
    r.append(_r)

print(max(r))

Measured memory_bytes: 9508
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
//四方向への移動ベクトル
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
/*
//入力
int H, W;
vector<string> field;

//探索
bool seen[510][510];	// seen[h][w] := マス(h,w)が検知済みかどうか

void dfs(int h, int w)
{
	seen[h][w] = true;

	//四方向を検索
	for (int dir = 0; dir < 4; dir++)
	{
		int nh = h + dx[dir];
		int nw = w + dy[dir];

		//場外アウトしたり、移動先が壁の場合はスルー
		if (nh < 0 || nh >= H || nw < 0 || nw <= W)continue;
		if (field[nh][nw] == '#')continue;

		//移動先が探索済みの場合
		if (seen[nh][nw])continue;

		//再帰的に探索
		dfs(nh, nw);
	}
}

/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}




int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}


vector<bool> seen;
void dfs(const Graph & G, int v)
{
	seen[v] = true;	//v を訪問済みにする

	// vから行ける各頂点 next_vについて
	for (auto next_v : G[v])
	{
		if (seen[next_v])continue;	//next_vが探索済みだったらスルー
		dfs(G, next_v);//再帰的に探索
	}
}


 * 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


void init(int n)
{
	for (int i = 0; i < n; i++) par[i] = i;
	for (int i = 0; i < n; i++) r[i] = 0;
}

int find(int x)
{
	if (par[x] == x)return x;
	else return find(par[x]);
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);

	if (r[x] < r[y])
	{
		par[x] = y;
	}
	else
	{
		par[y] = x;
		if (r[x] == r[y])
		{
			r[x]++;
		}
	}
}

bool same(int x, int y)
{
	return find(x) == find(y);
}

};


string SS, T;
string solve()
{
	
	int N = SS.length();
	int M = T.length();
	set<string> ans;
	for (int R = N; R >= M; R--)
	{
		int L = R - M;

		int ok = 1;
		for (int j = 0; j < M; j++)
		{
			if (SS[L + j] != '?' && SS[L + j] != T[j])
			{
				ok = 0;
			}

			if (ok)
			{
				string S;
				for (int i = 0; i < N;i++) S += SS[i];
				for (int i = 0; i < M; i++) S[L+i] = T[i];
				for (int i = 0; i < N; i++) if (S[i] == '?')S[i] = 'a';
				ans.insert(S);
			}
		}
		
	}
	if (ans.size() == 0)return "UNRESTORABLE";
	return *(ans.begin());

}
*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B;
	cin  >> A >> B;

	if ((A * B) % 2 == 0) {
		cout << "Even" << endl;
	}
	else cout << "Odd" << endl;

}


Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var B = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var C = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int result = B[A[0] - 1];
            for (int i = 1; i < N; i++)
            {
                result += B[A[i]-1];
                if (A[i] - A[i - 1] == 1) result += C[A[i - 1]-1];
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }

vector<int> G[200010];
vector<ll> ans(200010,0);

void dfs(int v, int p) {
  if(p!=-1) ans[v] += ans[p];
  for (auto nx : G[v]) {
    if (nx == p) continue;
    dfs(nx, v);
  }
}

int main(int argc, char const* argv[]) {
  int n, q;
  cin >> n >> q;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b), G[b].pb(a);
  }
  rep(i,q) {
    int p,x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0, -1);
  rep(i, n) cout << ans[i] << (i == n - 1 ? '\n' : ' ');
  return 0;
}

Measured memory_bytes: 24320
n, x, y = gets.split.map(&:to_i)
x -= 1
y -= 1
g = Array.new(n) { [] }
n.times do |i|
  next if i == n - 1
  g[i] << i + 1
  g[i + 1] << i
end
g[x] << y
g[y] << x

ans = Hash.new(0)
n.times do |s|
  bfs_map = Array.new(n, 2000)
  bfs_map[s] = 0
  q = [[s, 0]]
  until q.empty?
    v, d = q.shift

    g[v].each do |u|
      if bfs_map[u] > d + 1
        bfs_map[u] = d + 1
        q << [u, d + 1]
      end
    end
  end
  bfs_map.each do |d|
    ans[d] += 1
  end
end

1.upto(n - 1) do |k|
  p ans[k] / 2
end


Measured memory_bytes: 2684
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    ans = 1
    if 0 in A:
        print(0)
        return
    
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24420
s=input()
s=list(s)
l=[]
ls=len(s)
for i in range (ls):
    if s[i]=='1':
        l.append(1)
    elif s[i]=='0':
        l.append(0)
    else:
        if len(l)==0:
            l=l
        else:
            l.pop()
ans=""
for i in range(len(l)):
    ans=ans+str(l[i])
print(ans)

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

#define _GLIBCXX_DEBUG

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define rep(i, n) for(i = 0; i < n; i++)


int main(){
    int N;
    vector<int> Ls;

    cin >> N;

    Ls.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> Ls[i];
    }

    cout << (*max_element(Ls.begin(), Ls.end()) * 2 < accumulate(Ls.begin(), Ls.end(), 0) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a , b;
    cin >> a >> b;
    a--; b--;
    int x[3] = {};
    x[a]++;
    x[b]++;
    rep(i, 0, 3) if (!x[i]) cout << i + 1 << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    vector<vector<ll>> g(n);
    REP(i, n-1) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    vector<ll> c(n);
    REP(i, n) cin >> c[i];

    ll ma = 0, idx = -1;
    REP(i, n) {
        if(ma < (ll)g[i].size()) {
            ma = g[i].size();
            idx = i;
        }
    }

    vector<PII> dist(n);
    function<void(ll,ll,ll)> dfs = [&](ll v, ll p, ll d) {
        dist[v] = PII(d, v);
        for(auto to: g[v]) {
            if(to == p) continue;
            dfs(to, v, d+1);
        }
    };

    dfs(idx, -1, 0);
    sort(ALL(dist));
    sort(ALL(c), greater<>());
    vector<ll> x(n);
    REP(i, n) x[dist[i].second] = c[i];

    ll ret = 0;
    REP(i, n-1) {
        ret += min(x[a[i]], x[b[i]]);
    }
    cout << ret << endl;
    REP(i, n) {
        cout << x[i] << (i==n-1?"\n":" ");
    }

    return 0;
}


Measured memory_bytes: 1920
# Grid Repainting 2
import numpy as np
h, w = map(int, input().split())
s = np.array([[0]*(w+2) for i in range(h+2)])
for i in range(h):
    t = input()
    for j in range(w):
        if t[j] == '#':
            s[i+1][j+1] = 1

for x in range(h):
    i = x + 1
    for y in range(w):
        j = y + 1
        if s[i][j]:
            if s[i-1][j] or s[i][j-1] or s[i+1][j] or s[i][j+1]:
                continue
            else:
                exit(print('No'))
print('Yes')


Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
int mx,n,x,y,K,z,A,B,a[1005][1005],b[1005][1005],c[1005][1005],d[1005][1005]; char S[5];
int main(){
	scanf("%d%d",&n,&K);
	for (int i=1;i<=n;++i){
		scanf("%d%d%s",&x,&y,S);
		z=S[0]=='B';
		if ((x/K)&1) z^=1;
		if ((y/K)&1) z^=1;
		x%=K; y%=K;
		if (z) ++a[x][y],++c[x][y],++A; else ++b[x][y],++d[x][y],++B;
	}
	for (int i=0;i<K;++i)
	for (int j=0;j<K;++j)
	a[i][j]+=(i?a[i-1][j]:0)+(j?a[i][j-1]:0)-(i&&j?a[i-1][j-1]:0),
	b[i][j]+=(i?b[i-1][j]:0)+(j?b[i][j-1]:0)-(i&&j?b[i-1][j-1]:0);
	for (int i=K-1;~i;--i)
	for (int j=K-1;~j;--j)
	c[i][j]+=(i<K-1?c[i+1][j]:0)+(j<K-1?c[i][j+1]:0)-(i<K-1&&j<K-1?c[i+1][j+1]:0),
	d[i][j]+=(i<K-1?d[i+1][j]:0)+(j<K-1?d[i][j+1]:0)-(i<K-1&&j<K-1?d[i+1][j+1]:0);
	for (int i=0;i<K;++i)
	for (int j=0;j<K;++j){
		mx=max(mx,a[i][j]+c[i+1][j+1]+B-b[i][j]-d[i+1][j+1]);
		mx=max(mx,b[i][j]+d[i+1][j+1]+A-a[i][j]-c[i+1][j+1]);
	}
	printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 16000
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    if(a == b && a != c) ans = 1;
    if(b == c && b != a) ans = 1;
    if(c == a && c != b) ans = 1;

    if(ans == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		s = s.replace("eraser","Q");
		s = s.replace("erase","Q");
		s = s.replace("dreamer","Q");
		s = s.replace("dream","Q");
		for( int i=0; i<s.length(); i++ ){
			if( s.charAt(i)!='Q' ){
				System.out.println("NO");
				break;
			}
			if( i==s.length()-1 ){
				System.out.println("YES");
			}
		}	
	}
}


Measured memory_bytes: 30704
def selection_sort(A):
    count = 0
    for i in range(len(A)):
        minv = 101
        minj = -1
        for j in range(i, len(A)):
            if minv > A[j]:
                minv = A[j]
                minj = j
        if A[i] != A[minj]:
            A[i], A[minj] = A[minj], A[i]
            count += 1

    return count


n = int(input())
A = [int(x) for x in input().split()]

count = selection_sort(A)

print(' '.join([str(x) for x in A]))
print(count)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


int main() {
  int N;
  cin >> N;
  vec<bool> match(N);
  bool judge = false;
  rep(i,N) {
    int d1,d2;
    cin >> d1 >> d2;
    match[i] = (d1 == d2);
  }
  rep(i,N-2) {
    if (match[i] && match[i+1] && match[i+2])
      judge = true;
  }
  print(((judge)?Yes:No));
  return 0;
}

Measured memory_bytes: 3628