akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<sstream>
#include<stdio.h>
#include <functional>
#include<set>

using namespace std;
int main()
{
	string  n;
	cin >>n;
	long long int nn = n.size();
	long long int ans = 0;
	for(int bit=0;bit<(1<<nn-1);bit++)
	{
		 long long int sum = 0;
		string s;
		s += n[0];
		long long int f = 0;
		for (long long int i = 0; i < nn-1; i++)
		{
			if (bit & (1 << i))
			{
				s += "+";
				f++;
			}
			s += n[i + 1];
		}
		vector<string> h(nn);
		long long int k = 0;
		long long int d = 0;
		
		for (long long int i = 0; i < nn + f; i++)
		{
			
			if (s.at(i) != '+')
			{
				
			h[k]+= s.at(i);
			
			}
			else
			{
		
				
				k++;
			}
			
		}
		for (long long int i = 0; i < k + 1; i++)
		{
			
			long long int g = stoll(h[i]);
			ans += g;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, m, K; cin >> n >> m >> K;
    bool ok = false;
    rep(i, n + 1){
        rep(j, m + 1){
            int cur = i * m + j * n - 2 * i * j;
            if(cur == K){
                ok = true;
            }
        }
    }
    cout << (ok ? "Yes":"No") << endl;

    return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("869121");
            //2511445
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int N = int.Parse(InputList[0]);

        const long Hou = 1000000000 + 7;

        //場合の数[0と9の有無]なDP表
        var PrevDP = new Dictionary<int, long>();
        PrevDP[0] = 1;

        for (int I = 1; I <= N; I++) {
            var CurrDP = new Dictionary<int, long>();
            foreach (var EachPair in PrevDP) {
                for (int J = 1; J <= 3; J++) {
                    int NewKey = EachPair.Key;
                    int BaiSuu = 8; //0と9以外の数で8
                    if (J == 1) {
                        NewKey |= 1;
                        BaiSuu = 1;
                    }
                    if (J == 2) {
                        NewKey |= 2;
                        BaiSuu = 1;
                    }
                    if (CurrDP.ContainsKey(NewKey)) {
                        CurrDP[NewKey] += EachPair.Value * BaiSuu;
                        CurrDP[NewKey] %= Hou;
                    }
                    else {
                        CurrDP[NewKey] = EachPair.Value * BaiSuu;
                        CurrDP[NewKey] %= Hou;
                    }
                }
            }
            PrevDP = CurrDP;
        }
        if (PrevDP.ContainsKey(1 | 2)) {
            Console.WriteLine(PrevDP[1 | 2]);
        }
        else {
            Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 46492
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (int)(n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

namespace mf {
    static const int N = 5e5;
    static const int M = 2e6 + 233;
    static const int inf = 1e9;
    struct E {
		int nxt, to, fl;
    }e[M << 1];
    int d[N], head[N], cur[N], e_cnt = 1;
    int n, s, t;
    inline void init(int _n, int _s, int _t) {
		n = _n; s = _s; t = _t;
		fill(head, head + n + 1, 0);
		e_cnt = 1;
    }
    inline void add(int u, int v, int fl) {
		e[++ e_cnt] = (E) {head[u], v, fl}; head[u] = e_cnt;
    }
    inline void link(int u, int v, int fl) {
		add(u, v, fl); add(v, u, 0);
    }
    inline bool bfs(void) {
		queue<int> q;
		fill(d, d + n + 1, -1);
		d[s] = 0; q.push(s);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for(int i = head[u]; i; i = e[i].nxt) if(e[i].fl) {
					int v = e[i].to;
					if(!~ d[v]) d[v] = d[u] + 1, q.push(v);
				}
		}
		return d[t] != -1;
    }
    inline int dfs(int u, int f) {
		if(u == t || !f) return f;
		int used = 0, t;
		for(int &i = cur[u]; i; i = e[i].nxt) if(e[i].fl) {
				int v = e[i].to;
				if(d[v] != d[u] + 1) continue;
				t = dfs(v, min(f - used, e[i].fl));
				used += t; e[i].fl -= t; e[i ^ 1].fl += t;
				if(used == f) break;
			}
		if(!used) d[u] = -1;
		return used;
    }
    inline int doit(void) {
		int fl = 0;
		while(bfs()) {
			memcpy(cur, head, sizeof (int) * (n + 2));
			fl += dfs(s, inf);
		}
		return fl;
    }
}

#define GG (puts("-1"), exit(0))
const int N = mf::N;
int n, match[N], con[N];
vector <int> adj[N];

int main(void) {
	read(n);
	int S = n + n, T = S + 1;
	mf::init(T, S, T);
	for (int i = 2; i <= n; i++) {
		int E = i + n - 1;
		mf::link(S, i, 1);
		mf::link(E, T, 1);
		int sz, x; read(sz);
		while (sz--) {
			read(x);
			mf::link(x, E, 1);
		}		
	}
	if (mf::doit() != n - 1) GG;
	for (int i = 2; i <= mf::e_cnt; i += 2) {
		int u = mf::e[i ^ 1].to;
		int v = mf::e[i].to;
		if (!mf::e[i].fl && (2 <= u && u <= n)) {
			match[v] = u;
		} else {
			adj[u].push_back(v);
		}
	}
	queue <int> Q;
	Q.push(1);
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		for (int i : adj[u]) {
			if (con[i]) continue;
			con[i] = u;
			Q.push(match[i]);
		}
	}
	for (int i = n + 1; i <= n + n - 1; i++) {
		cout << con[i] << " " << match[i] << "\n";
	}
}


Measured memory_bytes: 42812
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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


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

	VI apple_list(n);
	int flag = 0;
	int last;
	REP(i, n) {
		apple_list[i] = l + i;
		if (l + i == 0) {
			flag = 1;
		}
		if (i == n - 1) {
			last = l + i;
		}
	}
	int ans;
	int sum= accumulate(apple_list.begin(), apple_list.end(), 0);
	if (flag == 1) {
		ans = sum;
		
	}
	else if (l > 0) {
		ans = sum - l;

	}
	else {
		
		ans = sum - last;
	}

	ANS(ans);




	return 0;
}


Measured memory_bytes: 256
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))

def checkhalf(n,i,flg):
    if n%2 ==0:
        return n/2,i+1,True
    else:
        return n,i,False

ans = 0
for a in A:
    n = a
    i = 0 
    flg = True
    while flg:
        n,i,flg = checkhalf(n,i,flg)
    ans = ans + i

print(ans)

Measured memory_bytes: 4148
#include <bits/stdc++.h> 
using namespace std;
#define INF INT_MAX
#define N 100005
#define K 3
int n, k;
int arr[N][K];
int dp[N][K];
int solve(int idx, int last_k){
    int res;
    if(idx == n)
        return 0;
    if(~last_k && ~dp[idx][last_k])
        return dp[idx][last_k];
    for(int i=0; i<K; ++i){
        if(last_k != i){
            dp[idx][last_k] = max(dp[idx][last_k], arr[idx][i]+solve(idx+1, i));
        }
    }
    return dp[idx][last_k];
}
int main()
{
    cin >> n;
    memset(dp, -1, sizeof(dp[0][0]) * N * K);
    for(int i=0; i<n; ++i)
        for(int j=0; j<3; ++j)
            cin >> arr[i][j];
    cout << solve(0, -1);
    return 0;
}

Measured memory_bytes: 10368
N = int(input())
S = [int(input()) for k in range(N)]
if sum(S)%10==0:
  ans = 0
else:
  print(sum(S))
  exit()
for k in range(N):
  if sum(S[:k]+S[k+1:])%10==0:
    pass
  else:
    ans = max(ans,sum(S[:k]+S[k+1:]))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  int a,b;
  cin>>a>>b;
  if(a>=1+(2*(b-1))) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define ri register int
#define N 100
char str[N];
int len;
bool hw(int l,int r)
{
	for(ri i=0;i<=(r-l+1)/2;++i)
	{
		if(str[l+i]!=str[r-i])
		{
			return false;
		}
	}
	return true;
}
int main()
{
	scanf("%s",str),len=strlen(str),puts(hw(0,len-1) && hw(0,(len-1)/2-1) && hw((len-1)/2+1,len-1)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
/**********************************************
*   UPDATE CONDITION & OVERFLOW CONDITION     *
**********************************************/

#include<bits/stdc++.h>
using namespace std;

#define pi 3.1415926535
#define endl "\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t; while(t--)
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n-1 ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const long long int inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    string s;
    cin >> s;
    if(s == "ABC")
        cout  << "ARC";
    else
        cout << "ABC";
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string a,b;
    int t=0;
    int h=0;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a==b){t=t+1;h=h+1;}
        else if(a>b){t=t+3;}
        else {h=h+3;}
    }
    cout<<t<<" "<<h<<endl;
    return 0;
}


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

int main(){
    int n,num,cnt=0;cin>>n;
    vector<int> a(100010,0);
    for(int i=0;i<n;i++){
        cin>>num;
        if(a[num]>=1){cnt++;}//2枚以上の時あまりとしてカウント
        a[num]++;
    }

    cout<<n-cnt-cnt%2<<endl;
    //基本的にあまりを除くが、あまりは偶数個のときは、ぴったり除く事ができる
    //奇数個だと1種類減
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using D = double;
using LD = long double;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(){
    ll n,k; cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    sort(ALL(h));
    ll ans = 0;
    rep(i,n-k){
        ans += h[i];
    }
    cout << ans << endl;
}


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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

const ll max_n = 1e3 + 5;

ll h,w,ch,cw,dh,dw;
vs s;
vvb v;

vpll nbr(pll p)
{
	vpll vec;
	if(p.ft > 0 and !v[p.ft-1][p.sc])
		vec.pb({p.ft-1,p.sc});
	if(p.sc > 0 and !v[p.ft][p.sc-1])
		vec.pb({p.ft,p.sc-1});
	if(p.ft < h-1 and !v[p.ft+1][p.sc])
		vec.pb({p.ft+1,p.sc});
	if(p.sc < w-1 and !v[p.ft][p.sc+1])
		vec.pb({p.ft,p.sc+1});
	return vec;
}

vpll sq5(pll p)
{
	vpll vec;
	rep(i,max(p.ft-2,0LL),min(p.ft+3,h),1) rep(j,max(p.sc-2,0LL),min(p.sc+3,w),1) if(s[i][j] == '.') vec.pb({i,j});
	return vec;
}

int main()
{
	io;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	--ch;
	--cw;
	--dh;
	--dw;
	s.resize(h);
	takearr0(s,h);
	v.resize(h);
	rep(i,0,h,1) v[i].resize(w);
	v.assign(h,vb(w,false));
	rep(i,0,h,1) rep(j,0,w,1) if(s[i][j] == '#') v[i][j] = true;
	ll cntr = 1;
	vvll pno(h,vll(w,0));
	rep(i,0,h,1)
	{
		rep(j,0,w,1)
		{
			if(v[i][j])
				continue;
			v[i][j] = true;
			queue<pll> q;
			q.push({i,j});
			while(!q.empty())
			{
				pll p = q.front();
				q.pop();
				vpll nv = nbr(p);
				pno[p.ft][p.sc] = cntr;
				each(x,nv)
				{
					v[x.ft][x.sc] = true;
					q.push(x);
				}
			}
			++cntr;
		}
	}
	ll n = cntr-1;
	vsll g(n);
	vll d(n,-1);
	rep(i,0,h,1)
	{
		rep(j,0,w,1)
		{
			if(s[i][j] == '#')
				continue;
			vpll nv = sq5({i,j});
			ll src = pno[i][j] - 1;
			each(p,nv) g[src].ins(pno[p.ft][p.sc]-1);
		}
	}
	vb vis(n,false);
	ll rt = pno[ch][cw]-1;
	queue<ll> ql;
	vis[rt] = true;
	d[rt] = 0;
	ql.push(rt);
	while(!ql.empty())
	{
		rt = ql.front();
		ql.pop();
		each(ch,g[rt])
		{
			if(!vis[ch])
			{
				d[ch] = d[rt] + 1;
				vis[ch] = true;
				ql.push(ch);
			}
		}
	}
	cout << d[pno[dh][dw]-1] << endl;
	return 0;
}

Measured memory_bytes: 44768
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned 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); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,i,ans=0,x;
       cin>>n;
       for(i=1;i<=n;i++)
       {
           cin>>x;
           if(x%2&&i%2)
            ans++;
       }  
       cout<<ans;
   }
}

Measured memory_bytes: 3600
def solve():
    ans = ["0"]*n
    if not n==1:
        ans[0] = "1"
    for i in range(len(s)):
        a = ((s[i]== 1) and c[i]==0) and (not n == 1)
        b = False
        for j in range(len(s)):
            b = b or (s[i] == s[j] and (not i==j) and not c[i]==c[j])
        if a or b:
            print(-1)
            exit()
        ans[s[i]-1] = str(c[i])
    ans = "".join(ans)
    print(ans)



    return




n, m = [int(s) for s in input().split(" ")]
s = []
c = []
for i in range(m):
    si, ci = [int(s) for s in input().split(" ")]
    s.append(si)
    c.append(ci)
solve()


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(500000)
N = int(input())
E = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append((b, i))
    E[b].append((a, i))
K = max(len(e) for e in E)
print(K)
Ans = [-1] * (N-1)
def dfs(v=1, p=0, p_col=-1):
    col = 1
    for u, idx in E[v]:
        if u!=p:
            if col == p_col:
                col += 1
            Ans[idx] = col
            dfs(u, v, col)
            col += 1
dfs()
print("\n".join(map(str, Ans)))


Measured memory_bytes: 85652
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  string t;cin>>t;
  rep(i,t.size()){
    if(t[i] == '?'){
      t[i] = 'D';
    }
  }
  cout<<t<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, ans, prev=0, now=0, last=0;
	cin >> N;
	REP(i, 0, N-1) {
		if(i == 0){
			cin >> prev;
			ans += prev;
			last = prev;
		}
		else{
			if(i % 2 == 0) {
				cin >> prev;
				last = prev;
			}
			else {
				cin >> now;
				last = now;
			}
			ans += min(prev, now);
		}
	}
	ans += last;
	cout << ans;
	
			

}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n;
	cin >> n;

	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(a, a+n, greater<int>());

	priority_queue<int> pq;
	pq.push(a[0]);

	ll comfort = 0;

	for (int i = 1; i < n; i++) {
		int popped = pq.top();
		pq.pop();

		comfort += popped;

		pq.push(a[i]);
		pq.push(a[i]);
	}

	cout << comfort << endl;

	return 0;
}

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


int main() {

  int N, K;
  cin >> N >> K;

  vector<int> x(N);
  vector<int> y(N);
  vector<char> c(N);

  // 黒か否か
  vector<bool> black(N);
  
  // 2 * K
  int KK = 2 * K;

  // 二次元累積和
  vector<vector<int>> table(KK + 1, vector<int>(KK + 1));
  
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> c[i];
    
    // x を x % 2K、y を y % 2K に置き換える
    x[i] %= KK;
    y[i] %= KK;

    if (c[i] == 'B') {
      black[i] = true;
    } else {
      black[i] = false;
    }

    // 0 から K の間に (x, y) を集約させる
    if (K <= x[i]) {
      x[i] -= K;
      black[i] = !black[i];
    }
    if (K <= y[i]) {
      y[i] -= K;
      black[i] = !black[i];
    }

    // 二次元累積和の準備
    // K * k の左下を調査点とする
    if (black[i]) {
      table[0][0]++;
      table[0][y[i] + 1]--;
      table[x[i] + 1][0]--;
      table[x[i] + 1][y[i] + 1] += 2;
    } else {
      table[0][y[i] + 1]++;
      table[x[i] + 1][0]++;
      table[x[i] + 1][y[i] + 1] -= 2;
    }

  }

  // 二次元累積和（横の集計）
  for (int i = 0; i < K; i++) {
    for (int j = 1; j < K; j++) {
      table[i][j] += table[i][j - 1];
    }
  }

  // 二次元累積和（縦の集計）
  for (int i = 0; i < K; i++) {
    for (int j = 1; j < K; j++) {
      table[j][i] += table[j - 1][i];
    }
  }

  
  int answer = 0;
  
  // 答えを探す
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < K; j++) {
      // 正しいマスの個数は、W が多い場合もある
      table[i][j] = max(table[i][j], N - table[i][j]);
      answer = max(answer, table[i][j]);
    }
  }

  cout << answer << endl;

  return 0;

}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

#define int ll

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  vvi x(n, vi(3));
  rep(i, n) rep(j, 3) cin >> x[i][j];

  int ans = 0;
  rep(k, 8){
    vi v(n, 0);
    rep(i, n){
      rep(j, 3){
        v[i] += x[i][j] * (k>>j & 1 ? -1 : 1);
      }
    }
    sort(all(v), greater<int>());
    int cnt = 0;
    rep(i, m){
      cnt += v[i]; 
    }
    ans = max(ans, cnt);
  }

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


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

int main(){
  	int K;
  	string S;
  	cin >> K >> S;
  	if(S.length()<=K){
    	cout << S << endl;
    }else{
    	for(int i=0; i<K; i++){
        	cout << S[i];
        }
      	cout << "..." << endl;
    }
  	
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	ll N;
	cin >> N;
	N--;
	if (N % 2 == 0)
		cout << (1 + N) * N / 2 << endl;
	else
	{
		N--;
		cout << (1 + N) * N / 2 + N + 1 << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s.at(i);
  }
  ll ans=0;
  rep(i,n){
    rep(j,s.at(i).size()-1){
      if(s.at(i).at(j)=='A' && s.at(i).at(j+1)=='B'){
        ans++;
      }
    }
  }
  ll p=0,q=0,r=0;
  rep(i,n){
    ll l=s.at(i).size();
    if(s.at(i).at(0)== 'B' &&s.at(i).at(l-1)=='A'){
      p++;
    }else if(s.at(i).at(0)=='B'){
      q++;
    }else if(s.at(i).at(l-1)=='A'){
      r++;
    }
  }
  ll cp=0;
  ll x=max(p-1,cp);
  if(p>0&&q>0){
    ans++;
    q--;
  }
  if(p>0&&r>0){
    ans++;
    r--;
  }
  x+=min(q,r);
  cout << ans+x;
}

Measured memory_bytes: 3672
def flog(heights,n):
    #height:足場の高さのリスト
    #n:heightsの長さ
    dp = [0 for _ in heights]
    dp [0] = 0
    dp [1] = abs(heights[1]-heights[0])
    for i in range(2,n):
        from_one_before = dp[i-1] + abs(heights[i] - heights[i-1])
        from_two_before = dp[i-2] + abs(heights[i] - heights[i-2])
        dp[i] = min(from_one_before,from_two_before)
    #print(dp)
    return dp[n-1]

def main():
    n = int(input())
    heights = list(map(int,input().split()))
    print(flog(heights,n))

if __name__ == '__main__':
    main()


Measured memory_bytes: 13976
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

ll dp[105][2][105];

void solve()
{
    string n; cin >> n;
    V<int> N;
    rep(i, n.size())
    {
        N.push_back(n[i] - '0');
    }
    IN(k);

    dp[0][0][0] = 1;
    dp[0][0][1] = 0;
    dp[0][1][0] = 0;
    dp[0][1][1] = 0;
    rep(i, n.size())
    {
        for(int smaller = 0; smaller < 2; smaller++)
        {
            rep(j, 5)
            {
                for(int x = 0; x <= (smaller ? 9 : N[i]); x++)
                {
                    dp[i + 1][smaller || x < N[i]][j + (x != 0)] += dp[i][smaller][j];
                }
            }
        }
    }
    cout << dp[n.size()][0][k] + dp[n.size()][1][k] << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int k;
	string s;
	cin >> k >> s;
	if(s.size() > k){
		rep(i,k){
			cout << (char)s[i];
		}
		cout << "..." << endl;
	}else cout << s << endl;
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}



    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	long N;
	long X, M;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Long.parseLong(tokens[0]);
		X = Long.parseLong(tokens[1]);
		M = Long.parseLong(tokens[2]);
	}

	void calc() {
		Set<Long> set = new HashSet<>();
		List<Long> list = new ArrayList<>();
		set.add(X);
		list.add(X);

		long loopFirst = -1L;
		int count = 1;
		long val = X;
		while (true) {
			if (count >= N) {
				break;
			}
			val = (val * val) % M;
			if (set.contains(val)) {
				loopFirst = val;
				break;
			}
			set.add(val);
			list.add(val);
			++count;
		}

		if (loopFirst < 0) {
			// loopが始まる前に終了
			long result = 0;
			for (int i = 0; i < list.size(); ++i) {
				result += list.get(i);
			}
			System.out.println(result);
		} else {
			// loopが始まるまでの数
			int preNum = 0;
			for (int i = 0; i < list.size(); ++i) {
				if (list.get(i) == loopFirst) {
					preNum = i;
					break;
				}
			}
			int loopNum = list.size() - preNum;
			// loop中のsum
			long loopSum = 0;
			for (int i = preNum; i < list.size(); ++i) {
				loopSum += list.get(i);
			}
			long result = 0;
			// loopが始まるまでcount
			for (int i = 0; i < preNum; ++i) {
				result += list.get(i);
			}
			long afterLoopCount = (N - (long) preNum) / (long) loopNum;
			result += loopSum * afterLoopCount;
			for (int i = 0; i < (N-(long)preNum) % (long) loopNum; ++i) {
				result += list.get(preNum + i);
			}
			System.out.println(result);
		}

	}

	void showResult() {
	}
}

Measured memory_bytes: 33824
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	double count = 1 ;
	for (int i = 2; i <= n; i++){
		if( i % 2 != 0 ){
			count++;
		}
	}
	double ans;
	ans = (count/n);
	cout<< fixed <<setprecision(10) <<ans<<endl;

}

Measured memory_bytes: 3792
n = int(input())
h = list(reversed(list(map(int, input().split()))))
ans = "Yes"
for i in range(n-1):
    m = h[i]-h[i+1]
    if m < -1:
        ans = "No"
    elif m == -1:
        h[i+1] -= 1
print(ans)

Measured memory_bytes: 15020
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def C(n,r):
    return fact[n]*pow(fact[n-r],mod-2,mod)*pow(fact[r],mod-2,mod) % mod

x,y = LI()

fact = [1]*(x+y)
for i in range(1,x+y):
    fact[i] = i*fact[i-1]
    fact[i] %= mod

if (x+y) % 3 != 0:
    print(0)
else:
    if 2*y-x < 0 or (2*y-x) % 3 != 0:
        print(0)
    elif 2*x-y < 0 or (2*x-y) % 3 != 0:
        print(0)
    else:
        print(C((x+y)//3,(2*x-y)//3))

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

int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  for(int i = 0;i < m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<int> cnt(n,0);
  for(int i = 0;i < n;i++){
    for(int j = 0;j < m;j++){
      if(i == a[j] || i == b[j]){
        cnt[i]++;
      }
    }
  }
  for(int i = 0;i < n;i++){
    cout << cnt[i] << endl;
  }
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,k;cin>>n>>k;
  res=k;
  for(i=1;i<n;i++)res*=k-1;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
open System

let rec calc i req = match i, req with
    | _, [] -> 0
    | i, [|a; b|] :: rs ->
        if i < a
        then 1 + calc (b-1) rs
        else calc i rs
 
let [|n; m|] = stdin.ReadLine().Split() |> Array.map int
let req =
    [ for _ in [1..m] -> stdin.ReadLine().Split() |> Array.map int ]
    |> List.sortBy (fun [|_; b|] -> b)

printfn "%d" <| calc 0 req
 

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

int main(){
int n = 9;
int c[10];
for(int i = 0; i < n; i++){
    cin >> c[i];
}
string ans = "Yes";

if(c[1]-c[0] != c[4]-c[3] || c[4]-c[3] != c[7]-c[6]) ans = "No";
if(c[2]-c[1] != c[5]-c[4] || c[5]-c[4] != c[8]-c[7]) ans = "No";
if(c[3]-c[0] != c[4]-c[1] || c[4]-c[1] != c[5]-c[2]) ans = "No";
if(c[6]-c[3] != c[7]-c[4] || c[7]-c[4] != c[8]-c[5]) ans = "No";

cout << ans << endl;

return 0;
}


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

int main(){
  ll n; cin>>n;
  ll c1,h1,c2,h2,h3,c3; cin>>h1>>h2;
  c1=0;c2=abs(h2-h1);
  if(n>2){
  	for(int i=2;i<n;i++){
    	cin>>h3;
    	c3=min(c1+abs(h3-h1),c2+abs(h3-h2));
    	h1=h2; c1=c2;
    	h2=h3; c2=c3;
  	}
    cout<<c3;
  }
  else{cout<<c2;}
                        
  return 0;
}

Measured memory_bytes: 384
def solve(n, k, t, d):
    que = []
    used = set()
    base_score = 0
    for ti, di in sorted(zip(t, d), key=lambda _:-_[1])[:k]:
        if ti in used:
            que.append(di)
        else:
            used.add(ti)
        base_score += di
    num = len(used)
    best = base_score + num**2

    M = {}
    for ti, di in zip(t, d):
        if not ti in used:
            if not ti in M:
                M[ti] = 0
            M[ti] = max(M[ti], di)

    que = sorted(que)
    for i, p in enumerate(sorted(M.values())[::-1][:len(que)]):
        base_score += p - que[i]
        num += 1
        best = max(best, base_score + num**2)
    return best

n, k = map(int, input().split())
t = [0] * n
d = [0] * n
for i in range(n):
    t[i], d[i] = map(int, input().split())
print(solve(n, k, t, d))

Measured memory_bytes: 25512
'use strict'

function main(inp) {
  inp = inp.trim().split('\n')
  const N = inp.shift()
  inp = inp.sort()
  
  let ans = []
  let num = 0
  let count = 0
  for (let i = 0; i < inp.length; i++) {
    count++;
    if ((i + 1 === N) || inp[i] !== inp[i+1]) {
      if (count === num) {
        ans.push(inp[i])
      } else if (count > num) {
        num = count
        ans = [inp[i]]
      }
      count = 0
    }
  }

  console.log(ans.join('\n'))
}

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


Measured memory_bytes: 52332
#include <bits/stdc++.h>
using namespace std;
string n;
int main() {
    cin >> n;
    for(int i = 0; i < 3; ++i) {
        if(n.at(i) == '1') {
            cout << '9';
        }else {
            cout << '1';
        }
    }
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

int N, n;
int x[16], y[16];
int a[16];

bool parallel(int x1, int y1, int x2, int y2) {
	return !(x1 * y2 - y1 * x2);
}

int f(vector<int> p, vector<int> q) {
	int ans = 0;
	rep(k, n) rep(l, k) {
		int i1 = p[k], i2 = q[k];
		int j1 = p[l], j2 = q[l];
		if (parallel(x[i1] - x[i2], y[i1] - y[i2], x[j1] - x[j2], y[j1] - y[j2]))
			ans++;
	}
	return ans;
}

int ma = 0;

void dfs(int i, int k) {
	if (i == N) {
		vector<int> p(n, -1), q(n, -1);
		rep(i, N) {
			int k = a[i];
			if (p[k] == -1) p[k] = i;
			else q[k] = i;
		}
		ma = max(ma, f(p, q));
		return;
	}
	if (a[i] == -1) {
		a[i] = k;
		for (int j = i + 1; j < N; j++) if (a[j] == -1) {
			a[j] = k;
			dfs(i + 1, k + 1);
			a[j] = -1;
		}
		a[i] = -1;
	}
	else dfs(i + 1, k);
}

int main() {
	cin >> N; n = N / 2;
	rep(i, N) cin >> x[i] >> y[i];
	rep(i, N) a[i] = -1;
	dfs(0, 0);
	cout << ma << endl;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x","<<#y":"<<x<<","<<y<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

int main(){
    int N;
    while(cin>>N){
        if(N==0) break;
        vector<pii> sq(N);
        sq[0].first=0;
        sq[0].second=0;
        for(int i=1;i<N;i++){
            int n,d;cin>>n>>d;
            sq[i].first = sq[n].first+dx[d];
            sq[i].second = sq[n].second+dy[d];
        }


        int l=INF,r=-INF,u=INF,d=-INF;
        for(int i=0;i<N;i++){
            l = min(l,sq[i].second);
            r = max(r,sq[i].second);
            u = min(u,sq[i].first);
            d = max(d,sq[i].first);
        }
        cout << r-l+1 << " " << d-u+1 << endl;
    }
}

Measured memory_bytes: 1196
#include <cstdio>
#include <cstdlib>

int X, K;
int r[100010];
int Q;
int t[100010], a[100010];
int idxt[100010], idxa[100010];
long long res[100010];
int left, right;
int aia[100010];

int cmpt(const void *aa, const void *bb)
{
	int i1 = *((int*)aa);
	int i2 = *((int*)bb);
	return t[i1] - t[i2];
}

int cmpa(const void *aa, const void *bb)
{
	int i1 = *((int*)aa);
	int i2 = *((int*)bb);
	return a[i1] - a[i2];
}

int bsrch_l(int ll, int rr, int val)
{
	int mm;
	while(ll<rr){
		mm = (ll+rr)/2;
		if(a[idxa[mm]] >= val)
			rr = mm;
		else
			ll=mm+1;
	}
	return ll;
}

void solve()
{
	int i, j;
	for(i=0; i<Q; i++)
		idxt[i] = i;
	qsort(idxt, Q, sizeof(int), cmpt);
	for(i=0; i<Q; i++)
		idxa[i] = i;
	qsort(idxa, Q, sizeof(int), cmpa);
	for(i=0; i<Q; i++){
		aia[idxa[i]] = i;
	}
	long long addv = 0;
	left = 0;
	right = X;
	int l2=0, r2=Q;
	j = 0;
	while(j<Q && r[0] >= t[idxt[j]]){
		//if(a[idxt[j]] <= r[0])
		if(a[idxt[j]] <= t[idxt[j]])
			res[idxt[j]] = 0;
		else
			res[idxt[j]] = a[idxt[j]] - t[idxt[j]];
		j ++;
	}
	l2 = bsrch_l(l2, r2, r[0]+1);
	addv -= r[0];
	//if(addv < 0)
	//	addv = 0;
	left -= r[0];
	if(left < 0)
		left = 0;
	right -= r[0];
	if(right < 0)
		right = 0;
	for(i=1; i<K+1; i++){
		while(j<Q && ( (i<K&&r[i] >= t[idxt[j]]) || (i==K) )  ){
			if(i%2 == 0){
				if(aia[idxt[j]] < l2){
					//res[idxt[j]] = left - (r[i]-r[i-1]);
					res[idxt[j]] = left - (t[idxt[j]]-r[i-1]);
				}
				else if(aia[idxt[j]] >= r2){
					res[idxt[j]] = right - (t[idxt[j]]-r[i-1]);
				}
				else{
					res[idxt[j]] = a[idxt[j]] + addv - (t[idxt[j]]-r[i-1]);
				}
				if(res[idxt[j]] < 0)
					res[idxt[j]] = 0;
			}
			else{
				if(aia[idxt[j]] < l2){
					res[idxt[j]] = left + (t[idxt[j]]-r[i-1]);
				}
				else if(aia[idxt[j]] >= r2){
					res[idxt[j]] = right + (t[idxt[j]]-r[i-1]);
				}
				else{
					res[idxt[j]] = a[idxt[j]] + addv + (t[idxt[j]]-r[i-1]);
				}
				if(res[idxt[j]] > X)
					res[idxt[j]] = X;
			}
			j ++;
		}
		if(i == K)
			break;
		if(i%2==0){
			l2 = bsrch_l(l2, r2, r[i]-r[i-1]+1-addv);
			right -= r[i]-r[i-1];
			if(right < 0)
				right = 0;
			left -= r[i]-r[i-1];
			if(left < 0)
				left = 0;
			addv -= r[i]-r[i-1];
			//if(addv < 0)
			//	addv = 0;
		}
		else{
			r2 = bsrch_l(l2, r2, X-(r[i]-r[i-1])-addv);
			left += r[i]-r[i-1];
			if(left > X)
				left = X;
			right += r[i]-r[i-1];
			if(right > X)
				right = X;
			addv += r[i]-r[i-1];
			//if(addv > X)
			//	addv = X;
		}
	}
	for(i=0; i<Q; i++)
		printf("%d\n", res[i]);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d", &X, &K);
	for(i=0; i<K; i++)
		scanf("%d", &r[i]);
	scanf("%d", &Q);
	for(i=0; i<Q; i++){
		scanf("%d%d", &t[i], &a[i]);
	}
	//test();
	solve();
	//solve2();
	return 0;
}

Measured memory_bytes: 4664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const ll M = 1000000007;
 
int main(void){
   ll n;
   cin >> n;
   ll a[n];
   ll b[n];
   ll s=0;
   for(ll i=0;i<n;i++){
       std::cin >> a[i];
       if(i%2==0){s+=a[i];}
       else {s-=a[i];}
   }
   b[0]=s;
   std::cout << b[0]<<" ";
   for(ll i=1;i<n;i++){
        b[i]=a[i-1]*2-b[i-1];
        std::cout << b[i]<<" ";
   }
    std::cout <<endl;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, k; cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    cout << accumulate(p.begin(), p.begin() + k, 0) << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    string s;
    cin >> s;
    lint res1=0;
    lint res2=0;
    lint n = (lint)s.size();
    //101...
    REP(i, n){
        if(i%2==0 and s[i]=='0') res1++;
        if(i%2==1 and s[i]=='1') res1++;
    }
    //01010
    REP(i, n){
        if(i%2==0 and s[i]=='1') res2++;
        if(i%2==1 and s[i]=='0') res2++;
    }
    cout << min(res1, res2) << endl;
    return 0;
}

Measured memory_bytes: 512
//package Dynamic_Programming;
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class Main{
	static FastReader scn = new FastReader();
	static OutputStream out = new BufferedOutputStream ( System.out );
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int t = 1;
		while(t-->0) {
			int n =scn.nextInt();
			long[] arr = new long[n];
			long s = 0;
			for(int i  =0;i<n;i++) {
				arr[i]=scn.nextInt();
				s+=arr[i];
			}
			long x = find_optimal_sum(arr);
			x = 2*x-s;
			out.write((x+"\n").getBytes());
//			System.out.println(find_optimal_sum(arr));
		}
		out.close();
	}
	private static long find_optimal_sum(long[] arr) {
		// TODO Auto-generated method stub
		int n = arr.length;
		long[][] dp = new long[n][n];
		for(int gap = 0;gap<n;gap++) {
			for(int i = 0,j=gap;j<n;i++,j++) {
				long c1 = ((i+2)<=j)?dp[i+2][j]:0;
				long c2 = ((i+1)<=(j-1))?dp[i+1][j-1]:0;
				long c3 = (i<=(j-2))?dp[i][j-2]:0;
				
				dp[i][j] = Math.max(arr[i]+Math.min(c2,c1), arr[j]+Math.min(c3,c2));
			}
		}
		return dp[0][n-1];
	}
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }

}


Measured memory_bytes: 130004
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

N, X = map(int, input().split())
A =sorted(list(map(int, input().split())))
len_A=len(A)-1
A_dif=[]

for i in range(len_A):
    A_dif.append(A[i+1]-A[i])

A_X=[abs(X-i) for i in A]
A_dif=A_dif+A_X
print(gcd(*A_dif))

Measured memory_bytes: 23344