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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long a_I, long long a_O, long long a_T, long long a_J, long long a_L, long long a_S, long long a_Z){
    i64 ans = (a_I / 2 + a_J / 2 + a_L / 2) * 2 + a_O;
    i64 flag = a_I % 2 + a_J % 2 + a_L % 2;
    if(flag == 3) ans += 3;
    else if(a_I % 2 + a_J % 2 == 2 && a_L != 0) ans += 1;
    else if(a_I % 2 + a_L % 2 == 2 && a_J != 0) ans += 1;
    else if(a_L % 2 + a_J % 2 == 2 && a_I != 0) ans += 1;
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long a_I;
    scanf("%lld",&a_I);
    long long a_O;
    scanf("%lld",&a_O);
    long long a_T;
    scanf("%lld",&a_T);
    long long a_J;
    scanf("%lld",&a_J);
    long long a_L;
    scanf("%lld",&a_L);
    long long a_S;
    scanf("%lld",&a_S);
    long long a_Z;
    scanf("%lld",&a_Z);
    solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int a, b, c, d, e, f, g, h, suma, sumb;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  scanf("%d %d %d %d", &e, &f, &g, &h);

  suma = a + b + c + d;
  sumb = e + f + g + h;

  if( suma > sumb ) printf("%d\n", suma);
  if( suma < sumb ) printf("%d\n", sumb);
  if( suma == sumb ) printf("%d\n", sumb);

  return 0;

}

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

string S_dash, T;

string solve() {
    if (S_dash.length() < T.length()) return "UNRESTORABLE";
    reverse(S_dash.begin(), S_dash.end());
    reverse(T.begin(), T.end());
    int index = -1;
    for (int i = 0; i <= S_dash.length() - T.length(); i++) {
        for (int j = 0; j < T.length(); j++) {
            if (!(T[j] == S_dash[i + j] || S_dash[i + j] == '?')) goto hell;
        }
        index = i;
        break;
    hell:;
    }
    if (index == -1) {
        return "UNRESTORABLE";
    } else {
        for (int i = 0; i < T.length(); i++) {
            S_dash[index + i] = T[i];
        }
        for (int i = 0; i < S_dash.length(); i++) {
            if (S_dash[i] == '?') S_dash[i] = 'a';
        }
        reverse(S_dash.begin(), S_dash.end());
        return S_dash;
    }
}

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

    cin >> S_dash >> T;
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

struct FF{
	struct edge{
		ll to, cap, rev;
	};
	vector<vector<edge>> G;
	vector<bool> used;
	ll n;
	const ll INF = 1<<30;
 
	FF(ll n) : n(n){
		G.resize(n);
		used.resize(n,false);
	}
 
	void add_edge(ll from, ll to, ll cap){
		G[from].push_back({to,cap,(ll)G[to].size()});
		G[to].push_back({from,0,(ll)G[from].size()-1});
	}
 
	ll dfs(ll u, ll t, ll f){
		if(u == t) return f;
		used[u] = true;
		for(auto &e : G[u]){
			if(!used[e.to] && e.cap > 0){
				ll d = dfs(e.to, t, min(f, e.cap));
				if(d > 0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
 
	ll max_flow(ll s, ll t){
		ll flow = 0;
		while(1){
			for(ll i=0; i<n; i++) used[i] = false;
			ll add_flow = dfs(s,t,INF);
			if(add_flow == 0) return flow;
			flow += add_flow;
		}
	}
};

char a[101][101];

int main(){
	ll h,w; cin >> h >> w;
	rep(i,h) rep(j,w) cin >> a[i][j];
	FF flow(h+w+2);
	P s,t;
	rep(i,h){
		rep(j,w){
			if(a[i][j] == '.') continue;
			if(a[i][j] == 'S') s = P(i,j);
			if(a[i][j] == 'T') t = P(i,j);
			else{
				flow.add_edge(i, h+j, 1);
				flow.add_edge(h+j, i, 1);
			}
		}
	}
	flow.add_edge(h+w, s.first, inf);
	flow.add_edge(h+w, h+s.second, inf);
	flow.add_edge(t.first, h+w+1, inf);
	flow.add_edge(h+t.second, h+w+1, inf);
	int ans = flow.max_flow(h+w, h+w+1);
	if(ans >= h+w) puts("-1");
	else cout << ans << "\n";
}


Measured memory_bytes: 4472
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	string s,t;
	cin >> s>>t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());//降順に並び替え
	if (t > s)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[101],f[100001];
int main()
{
	int i,j,n,k;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<=k;i++)
	{
		f[i]=0;
		for(j=1;j<=n;j++)
		{
			if(i<a[j])
				continue;
			if(f[i-a[j]]==0)
			{
				f[i]=1;
				break;
			}
		}
	}
	if(f[k]==1)
		printf("First");
	else
		printf("Second");
	return 0;
}

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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

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

const int N = 5e1 + 20;

int n;
int adj[N][N], a[N][N];

void mul(int b[N][N]) {
	int c[N][N];
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) c[i][j] = 0;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) for(int k = 0; k < n; k++) c[i][j] = (c[i][j] + ((a[i][k] * b[k][j]) % MOD)) % MOD;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) a[i][j] = c[i][j];
}

void power(int k) {
	if (k == 0) return;
	power(k / 2);
	mul(a);
	if (k & 1) mul(adj);
}

int32_t main(){

    sync;

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

	power(k);
	int ans = 0;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) ans = (ans + a[i][j]) % MOD;
	cout << ans << endl;

    return 0;
}

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

int main() {
	ll n, p;
	cin >> n >> p;

	if ( n == 1 ) {
		cout << p << endl;
		return 0;
	}

	ll ans = 1, lim = sqrt(p) + 1;
	for ( ll i = 2; i <= lim; i++ ) {
		ll cnt = 0;
		while ( p % i == 0 ) {
			p /= i;
			cnt++;
			if ( cnt == n ) {
				ans *= i;
				cnt = 0;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
class CardGameforTwo:
    def __init__(self):
        self.alice_card_list = []
        self.alice_count = 0
        self.bob_card_list =[]
        self.bob_count = 0
        self.total_card_num = 0
        self.card_list = []
    
    def get_card(self, total_card_num, card_list):
        card_list.sort(reverse=True)
        card_num = 0
        for c in card_list:
            if card_num % 2 == 0:
                self.alice_card_list.append(c)
            else:
                self.bob_card_list.append(c)
            card_num +=1
        return self.alice_card_list, self.bob_card_list
    
    def count_result(self, a_card_list, b_card_list):
        for a in a_card_list:
            self.alice_count +=a
        for b in b_card_list:
            self.bob_count +=b
        result = self.alice_count - self.bob_count
        return result

if __name__ == '__main__':
    N = input()
    a =list(map(int, input().split()))
    cgt = CardGameforTwo()
    a_card_list, b_card_list=cgt.get_card(N, a)
    result = cgt.count_result(a_card_list, b_card_list)
    print(result)


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i)=0; (i)<n; ++(i))
#define rep1(i,n) for(int (i)=1; (i)<=n; ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef double db;

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

inline long long Pow(const long long n,long long m,const int mod = MOD){
	long long res = 1,pow = n;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

inline vector<long long> Frac(const int range,const int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

inline long long Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false; 
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;	
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }

inline unsigned long long nextsub(unsigned long long sub){
	unsigned long long tem = sub + (sub & -sub);
	unsigned long long btm = (~(tem) & sub) / (sub & -sub);
	return btm | tem;
}


inline void solve(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1];

	return;
}

inline void input(){

	return;
}

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





Measured memory_bytes: 256
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if (i+j)%2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")
            else:
                print()
        else:
            print()


Measured memory_bytes: 7004
import sys
sys.setrecursionlimit(3000)

N,X = (int(i) for i in input().split(' '))

L = [1]
P = [1]
for i in range(N):
    L.append(2*L[i] + 3) # 総枚数
    P.append(2*P[i] + 1) #　パティ数

# X はなんレベルバーガ内か？
#print(L)
#print(P)
# X はレベルlv バーガのどこにいるのか？
def find_level(lv, x):
    
#    print(lv, x)
    if lv == 0:
        return 1
    
    midlv = L[lv-1] + 2
    
    # 最上層
    if x == L[lv]:
#        print('最上層')
        return  P[lv]
    # 最上層から真ん中
    if x < L[lv] and x > midlv:
#        print('最上層〜真ん中')
        return find_level(lv-1,x - midlv) + 1 + P[lv-1]
    # ちょうど真ん中
    elif x == midlv:
#        print('真ん中')
        return 1 + P[lv-1] 
    # 真ん中〜最下層
    elif x < midlv and x > 1:
#        print('真ん中〜最下層')
        return find_level(lv-1, x - 1)
    # 最下層
    else:
#        print('最下層')
        return 0
        
    return(ret)

r = find_level(N, X)
print(r)


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

#define bound_range(vec, lower, upper) (lower_bound(vec.begin(), vec.end(), upper) - lower_bound(vec.begin(), vec.end(), lower))

typedef long long ll;

using namespace std;

int main() {
    int n;
    ll ans = 0;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    for (int i = 0; i < n; ++i) cin >> b.at(i);
    for (int i = 0; i < 30; ++i) {
        ll digit = 1ll << i;
        vector<ll> m(b);
        for (vector<ll>::size_type j = 0; j < m.size(); ++j) m.at(j) %= digit * 2;
        sort(m.begin(), m.end());
        int cnt = 0;
        for (vector<ll>::size_type j = 0; j < m.size(); ++j) {
            ll da = a.at(j) % (digit * 2);
            cnt += bound_range(m, digit - da, digit * 2 - da) + bound_range(m, digit * 3 - da, digit * 4 - da);
        }
        if (cnt % 2) ans += digit;
    }

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


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

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    ans += n*(n-1)/2;
    ans += m*(m-1)/2;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int kind[31];
int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
   int n,m;
  cin >> n >> m;
  for(int i=0;i<n;i++){
    int sur; cin >> sur;
    while(sur--){
      int tmp; cin >> tmp;
      kind[tmp]++;
    }
  }
  int ans=0;
  for(int i=1;i<=m;i++) if(kind[i] == n) ans++;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	string S; cin >> S;

	int count = 0;

	for (int i = 0; i < 10; i++) {
		int x = 0; while (x < N && S[x] - '0' != i) { x++; }
		for (int j = 0; j < 10; j++) {
			int y = x + 1; while (y < N && S[y] - '0' != j) { y++; }
			for (int k = 0; k < 10; k++) {
				int z = y + 1; while (z < N && S[z] - '0' != k) { z++; }
				if (z < N) { count++; }
			}
		}
	}

	cout << count << endl;

	return 0;
}

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

ans = 0
s = s + 'E'

if s[0] == '0':
    order = 1
else:
    order = 0

l, r = 0, 0

while r < n:
    if order <= k:
        if (s[r] == '1' and s[r+1] == '0'):
            order += 1
        ans = max(ans, r - l + 1)
        r += 1
    elif l == r:
        l += 1
        r += 1
    else:
        if s[l] == '0' and s[l+1] == '1':
            order -= 1
        l += 1

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<#x<<"="<<x<<endl;
#define LL long long 
using namespace std;

int main(void)
{
	int n;
	scanf("%d",&n);
	LL res=0;
	rep(i,0,n)
	{
		LL l,r;
		scanf("%lld%lld",&l,&r);
		res+=(r-l+1);
	}
	printf("%lld",res);
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    k = I()
    s = S()
    if len(s) > k:
        return s[:k] + "..."

    return s

print(main())





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

class StronglyConnectedComponents {
private:
  int n;
  vector<vector<int>> dag,rdag,st;
  vector<int> comp,order;
  vector<bool> used;
public:
  StronglyConnectedComponents(const vector<vector<int>>& adj){
    n = adj.size();
    comp.resize(n);
    used.resize(n);
    dag.resize(n);
    rdag.resize(n);
    for(int i=0;i<n;++i){
      for(const auto& x:adj[i]){
        dag[i].emplace_back(x);
        rdag[x].emplace_back(i);
      }
    }
  }

  inline auto operator[](int idx)const{
    return comp[idx];
  }
  void dfs(int now_v){
    if(used[now_v])return;
    used[now_v]=true;
    for(const auto& next_v:dag[now_v]) dfs(next_v);
    order.push_back(now_v);
  }
  auto rdfs(int now_v,int num){
    if(comp[now_v])return false;
    comp[now_v]=num;
    for(const auto& next_v:rdag[now_v]) rdfs(next_v,num);
    return true;
  }
  vector<vector<int>> build(){
    for(int i=0;i<n;++i) dfs(i);
    reverse(order.begin(),order.end());
    int num=1;
    for(const auto& v:order) num+=rdfs(v,num);
    st.resize(num);
    for(int i=0;i<n;++i){
      st[comp[i]].emplace_back(i);
    }
    return st;
  }
  void dump(){
    rep(i,n)cout<<i<<" ";cout<<endl;
    rep(i,n)cout<<comp[i]<<" ";cout<<endl;
  }
};

int main(){

  int n,m;
  cin>>n>>m;
  vector<vector<int>> adj(n);
  vector<int> indeg(n);
  rep(i,m){
    int u,v;
    cin>>u>>v;
    adj[u].emplace_back(v);
    indeg[v]++;
  }

  StronglyConnectedComponents scc(adj);
  auto res = scc.build();
  res.erase(begin(res));
  for(auto& comp:res){
    //sort(begin(comp),end(comp),[&indeg](int u,int v){return indeg[u]<indeg[v];});
  }

  cout<<size(res)<<endl;
  for(auto& comp:res){
    cout<<size(comp);
    for(auto& v:comp)cout<<" "<<v;
    cout<<'\n';
  }

}

Measured memory_bytes: 130592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
vector<vector<pii>> adj;
vb color;
void dfs(int u, int p, int sum){
    for(auto s : adj[u]){
        int v = s.f;
        int w = s.s;
        if(v == p) continue;
        if((sum + w) % 2 == 0) color[v] = true;
        dfs(v, u, sum + w);
    }
}
int main(){
    int n;
    cin >> n;
    color.resize(n+1, false);
    adj.resize(n+1, vector<pii>());
    for(int i = 1; i < n; i++){
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].pb(mp(v, w));
        adj[v].pb(mp(u, w));
    }
    color[1] = true;
    dfs(1, -1, 0);
    for(int i = 1; i <= n; i++) cout << color[i] << '\n';
    return 0;
}

Measured memory_bytes: 8576
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a>b) {
            System.out.println("a > b");
            
        } else if (a<b){
            System.out.println("a < b");
            
        } else {
            System.out.println("a == b");
        }
    }
    
}



Measured memory_bytes: 26288
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextIntSlice(size int) []int {
	re := make([]int, size)
	for i := 0; i < size; i++ {
		re[i] = nextInt()
	}
	return re
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextIntSlice(n)

	i := 1
	cnt := 0
	for k := 0; k < n; k++ {
		cnt++
		j := a[i-1]
		if j == 2 {
			fmt.Println(cnt)
			return
		}
		i = j
	}
	fmt.Println(-1)
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++){
      cin >> a.at(i).at(j);
    }
  }
  
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < W; j++){
      if(a.at(i).at(j)=='#'){
        break;
      }else{
        if (j == W-1){
          a.erase(a.begin()+i);
          i--;
        }
      }
    }
  }
  for (int j = 0; j < a.at(0).size(); j++) {
    for (int i = 0; i < a.size(); i++){
      if(a.at(i).at(j)=='#'){
        break;
      }else{
        if (i == a.size()-1){
          for(int k = 0; k < a.size(); k++)  a.at(k).erase(a.at(k).begin()+j);
          j--;
        }
      }
    }
  }
  
  for(int i = 0; i<a.size(); i++){
    for(int j=0; j<a.at(0).size(); j++){
      cout << a.at(i).at(j);
      if(j == a.at(0).size()-1) cout << endl;
    }
  }
}



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

int main(){
  int d;
  cin >> d;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[d][26];
  rep(i,d) rep(j,26) cin >> s[i][j];
  int t[d];
  rep(i,d) {
    cin >> t[i];
    t[i]--;
  }
  int last[26] = {};
  int content = 0;
  rep(i,d) {
    content += s[i][t[i]];
    last[t[i]] = i+1;
    rep(kind,26) {
      content -= c[kind] * (i+1 - last[kind]);
    }
    cout << content << endl;
  }
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

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

    ll A,B,C;
    string S;
    cin >> A>>B>>C;

    ll tmp = 0;
    ll tmp1 = 0;
    ll min_tmp1 = INF;
    bool flag = true;
    if(A==1){
        cout << "YES" << endl;
    }
    else{
        REP(i, B)
        {
            tmp += A;
            tmp1 = tmp % B;
            if(tmp1>0){
                min_tmp1 = min(min_tmp1, tmp1);
            }
        }
        ll ans = 0;

        while(ans<=C){
            ans += min_tmp1;
            if(ans==C){
                cout << "YES" << endl;
                flag = false;
                break;
            }
        }

        if (flag == true)
        {
            cout << "NO" << endl;
        }
    }

}


Measured memory_bytes: 256
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        _n: usize,
        s: chars,
    );
    let mut sum = 0usize;
    let mut pre: char = '_';
    for c in s {
        if c == pre {
            // println!("{} onazi", c);
        } else{
            // println!("{}", c);
            sum += 1;
        }
        pre = c;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int n,q;
vector<int> con[200005];
int dist[200005];
bool reached[200005] = {0};
vector<int> son[200005];
int numbox[200005] = {0};
int ansbox[200005];

void solve(int r,int value)
{
    ansbox[r] = numbox[r] + value;
    if (son[r].size() != 0){
        for (int i = 0;i < son[r].size();i++){
            solve(son[r][i],ansbox[r]);
        }
    }
    else {
        return;
    }
}

void setpar(int r)
{
    reached[r]  = true;
    if (con[r].size() == 0){
        return;
    }
    for (int i = 0;i < con[r].size();i++){
        if (reached[con[r][i]] == true){
            continue;
        }
        else {
            son[r].push_back(con[r][i]);
            setpar(con[r][i]);
        }
    }
}

int main()
{
    scanf("%d %d",&n,&q);
    
    
    for (int i = 1;i < n;i++){
        int a,b;
        cin >> a >> b;
        con[a].push_back(b);
        con[b].push_back(a);
    }
    
    setpar(1);
    
    for (int i = 0;i < q;i++){
        int a,b;
        cin >> a >> b;
        numbox[a] += b;
    }
    
    solve(1,0);

    for (int i = 1;i <= n;i++){
        cout << ansbox[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

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

using namespace std;
typedef long long ll;

int main(){
    ll K,X;
    cin >> K >> X;
    if(500 * K >= X)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
} 

Measured memory_bytes: 3580
#include <iostream>
#include <string>

using namespace std;
int main()
{
    int a,b;
	cin>>a>>b;
	if(a>b)
		cout<<"a > b"<<endl;
	if(a==b)
		cout<<"a == b"<<endl;
	if(a<b)
		cout<<"a < b"<<endl;
	return 0;
}

Measured memory_bytes: 1156
def bisect_left(arr, target, left = 0, hi = arr.size)
  right = hi - 1

  while left <= right
    middle = (left + right)/2;

    if arr[middle] < target
      left = middle + 1;
    elsif arr[middle] > target
      right = middle - 1;
    else
      i = middle
      while i > 0 && arr[i-1] == arr[middle]
        i -= 1
      end
      return i
    end
  end
  return left
end

n = gets.to_i
ls = gets.split.map(&:to_i)
ls.sort!
last = nil
count = 0

i = 0
while i < ls.size - 2
  j = i + 1
  while j < ls.size - 1
    k = j + 1

    x = bisect_left(ls, ls[i] + ls[j], k)
    count += x - k

    j += 1
  end
  i += 1
end

puts count


Measured memory_bytes: 1916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.print(Math.min(a, b)+" ");
		if(a+b > n)
			System.out.print((a+b)-n+" ");
		if(a+b <= n)
			System.out.print(0+" ");
		
		out.flush();

	}


}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

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

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

	public char nextChar() throws IOException {
		return next().charAt(0);
	}

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

	public boolean ready() throws IOException {
		return br.ready();
	}

	public void waitForInput() throws InterruptedException {
		Thread.sleep(3000);
	}

}


Measured memory_bytes: 21972
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, N) for(i = 0; i < N; i++)
#define ll long long
ll i, j, k;
int main() {
  ll N;
  cin >> N;
  unsigned long long ans = 1;

  bool flag = false;
  rep(i, N) {
    unsigned ll A;
    cin >> A;
    // 0だったら終了
    if(A == 0) {
      cout << 0;
      return 0;
    }
    // 0でなくまだフラグが立っていなければ
    else if(flag == false) {
      if(A > 1000000000000000000 / ans)
        flag = true;
      else
        ans *= A;
    }
  }

  if(flag) {
    cout << -1;
  } else {
    cout << ans;
  }
  return 0;
}


Measured memory_bytes: 3628
import copy
s = list(input())
n = len(s)
k = copy.deepcopy(s)
k.reverse()
if k != s:
    print("No")
    exit()
formar = copy.deepcopy(s[:(n-1)//2])
q = copy.deepcopy(formar)
q.reverse()
if q != formar:
    print("No")
    exit()
last = copy.deepcopy(s[(n+3)//2 - 1:])
k = copy.deepcopy(last)
k.reverse()
if last != k:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 3444
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N + 1);
	vector<string> s(N);
	cin >> v[0];
	s[0] = "+";
	for (int i = 1; i < N; i++) {
		cin >> s[i] >> v[i];
	}
	vector<long long int>sum = v;
	for (int i = N - 1; i >= 0; i--) {
		sum[i] += sum[i + 1];
	}

	vector<long long int>Mdp(N + 1, -MOD * MOD);
	vector<long long int>mdp(N + 1, MOD*MOD);
	Mdp[N] = 0;
	mdp[N] = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (s[i] == "+") {
			Mdp[i] = Mdp[i + 1] + v[i];
			mdp[i] = mdp[i + 1] + v[i];
		}
		else {
			Mdp[i] = max(Mdp[i + 1] - v[i], -mdp[i + 1] - v[i]);
			mdp[i] = -sum[i];
		}
	}
	cout << Mdp[0] << endl;
	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
const int N = 2e5+5;

int main()
{
	int n, d; scanf("%d%d", &n, &d);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		ll x, y; scanf("%lld%lld", &x, &y);
		if (sqrt(sqr(x)+sqr(y)) <= d) cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3804
// https://beta.atcoder.jp/contests/abc031/submissions/3335125

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int x[105];
int y[105];
int h[105];

int main(){
  int n;
  int s = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i] > 0) s = i;
  }

  for(int i = 0; i <= 100; i++){
    for(int k = 0; k <= 100; k++){
      
      int ans = abs(x[s] - k) + abs(y[s] - i) + h[s];
      bool flg = true;
      for(int m = 0; m < n; m++){
        if(max(ans - abs(x[m] - k) - abs(y[m] - i), 0) != h[m]){
          flg = false;
          //cout << "x:" << k << " y:" << i << " ans:" << ans  << " h[m]:" << h[m] << endl;
          break;
        }
        else continue;
      }
      if(flg){
        cout << k << " " << i << " " << ans << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,k;
set<int> s;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>k>>n;
	rep(x,0,n){
		int t;
		cin>>t;
		s.insert(t);
	}
	
	rep(x,0,200){
		if (!s.count(k-x)){
			cout<<k-x;
			return 0;
		}	
		if (!s.count(k+x)){
			cout<<k+x;
			return 0;
		}	
	}

}


Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>


using namespace std;

#define Max INT_MAX
#define Inf (INT_MAX/2)
#define Min INT_MIN


#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
// s <= x < g ?
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
// 0 <= x < w && 0 <= y < h ?
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

typedef pair<int, int> P;

int main()
{
    int n;
    while( cin >> n ){
        vector<int> vec;
        if( n == 0) {break;}
        rep(i,n){
            int tmp;
            cin >> tmp;
            vec.push_back(tmp);
        }
        sort(vec.begin(), vec.end());
        double sum = 0.0;
        for( int i = 1; i<vec.size() - 1; i++ ){
            //cout << "add" << i << endl;
            sum += double(vec[i]);
        }
        cout << floor(sum/double(vec.size()-2) ) << endl;
    }
    return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#define INF 1000000007
using namespace std;
signed main(){
    int n;
    cin>>n;
    int cost[3][114514];
    for(int i=0;i<n;i++){
        cin>>cost[0][i]>>cost[1][i]>>cost[2][i];
    }
    int dp[3][114514];
    dp[0][0]=cost[0][0];
    dp[1][0]=cost[1][0];
    dp[2][0]=cost[2][0];
    for(int i=1;i<n;i++){
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+cost[0][i];
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+cost[1][i];
        dp[2][i]=max(dp[0][i-1],dp[1][i-1])+cost[2][i];
    }
    cout<<max({dp[0][n-1],dp[1][n-1],dp[2][n-1]})<<endl;
    return 0;
}





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

int main() {
  int n;
  cin >> n;
  vector<int> slimes(n, 0);
  
  int ans = 0;
  cin >> slimes[0];
  for (int i = 1; i < n; i++) {
    cin >> slimes[i];
    if (slimes[i] == slimes[i - 1]) {
      slimes[i] -= 1000000;
      ans++;
    }
  }
  
  cout << ans;
  return 0;
}

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

int main(){
	ll H,N,A,ans=0;cin >>H >> N;
	for(ll i=0;i<N;i++){
		cin >> A;
		ans += A;
	}
	if(H > ans){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n, len, max_len = 0, max, start = 0;
    int a[100005], b[100005];
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; ++i) {
        b[i] = a[n-i-1];
    }
    for (int i = 0; i < n; ++i) {
        if (i != 0){
            if (b[i] >= max) {
                max = b[i];
                ++len;

            } else {
                len = 0;
                max = b[i];
            }
            if (len > max_len) {
                max_len = len;
            }
        } else {
            max = b[i];
            len = 0;
        }
    }
    printf("%d\n",max_len);
    return 0;
}



Measured memory_bytes: 896
n = int(input())
r_list = list(map(int, input().split()))
ans_list = []

for i in range(len(r_list)):
    if i == 0:
        a = sum(r_list)
        for j in range(1, len(r_list)):
            if j % 2 == 1:
                a -= r_list[j] * 2
    else:
        a = (2 * r_list[i-1]) - ans_list[i-1]
    ans_list.append(a)

print(' '.join(map(str, ans_list)))


Measured memory_bytes: 19096
B = [[0]*30,[0]*30,[0]*30,[0]*30]
n = int(input())

for i in range(n):
    b,f,r,v = map(int,input().split())
    B[b-1][10*(f-1)+(r-1)] += v

for i in [0,1,2,3]:
    print('',*B[i][:10])
    print('',*B[i][10:20])
    print('',*B[i][20:30])
    if i == 3:
        break
    print('#'*20)


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int a[100005][3],dp[100005][3];
void solve(){
	int n;
	cin>>n;
	rep(i,0,n) rep(j,0,3) cin>>a[i][j];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	rep(i,1,n){
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
    // cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 8340
n=int(input())
m=[]
for i in range(1,n+1):
 a=i
 if a%3==0:
  m.append(i)
  continue
 while a>0:
  if a%10==3:
   m.append(i)
   break
  a//=10
print(' ',end='')
print(*m)

Measured memory_bytes: 6124
/* ex 9_1
   アカウント名 */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 11


typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

void push(stack *stk, char x){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", x);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = x;
        stk->count++;
    }
}

char pop(stack *stk){
    char x;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        x = *(stk->top);
        stk->top++;
        stk->count--;
        return x;
    }
}


int main(void){
    stack stk;
    int i;
    char input_seq[SIZE];
    char tmp, *ptr;
    scanf("%s", input_seq);
    ptr = input_seq;
    initialize_stack(&stk);
    while(*ptr != '\0'){
        if(*ptr != 'B'){
            push(&stk, *ptr);
        }
        else if(stk.count > 0){
            tmp = pop(&stk);
        }
        ptr++;
    }
    for(i = 0; i < stk.count+1; i++){
        if(stk.data[SIZE - i] != '\0'){
            printf("%c", stk.data[SIZE - i]);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1624
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int cnt[N];
int main(){
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x;scanf("%d",&x);
		cnt[x]++;
	}
	int ans=0;
	for(int i=1;i<N-1;i++){
		ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,m;cin>>n>>m;
    int a=sqrt(m);
    vector<int> divisor(0);
    for(int i=a;i>=1;i--){
        if(m%i==0){divisor.pb(i);divisor.pb(m/i);}
    }
    sort(all(divisor));
    for(int x:divisor){
        if(x>=n){
            cout<<m/x<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

bool palindrome(string S) {
    int N = S.length();
    rep(i,N) rep(i,N) if (S[i] != S[N - i - 1]) {
        return false;
    }
    return true;
}

int main() {

    string S;
    cin >> S;
    int N = S.length();

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

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

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var M = int.Parse(Console.ReadLine());
            Console.WriteLine(24 + 24 - M);
        }
    }
}


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

int main()
{

	char c; int f=0;
	double s,x,y,x0,y0,vx[2],vy[2];

	cin >> x0 >> c >> y0;
	cin >> x  >> c >> y ;

	vx[1] = x-x0;
	vy[1] = y-y0;

	s=0;
	while(cin >> x >> c >> y)
	{
		vx[f] = x-x0;
		vy[f] = y-y0;
		
		s+= fabs(vx[f]*vy[1-f] - vx[1-f]*vy[f]);
		
		f=1-f;
	}

	cout << s/2.0 << endl;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  int K, T;
  cin >> K >> T;
  vector<int> a(T);
  for (int i = 0; i < T; i++) cin >> a[i];
  sort(ALL(a));

  int n = a[T - 1];
  int res = K - n;

  if (n - 1 <= res) {
    cout << 0 << endl;
  } else {
    cout << n - 1 - res << endl;
  }
  return 0;
}


Measured memory_bytes: 256