akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int A,B; cin >> A >> B;
    string x(B,'0'+A);
    string y(A,'0'+B);
    string ans = min(x,y);
    cout << ans << endl;


}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    int sum[2010]={};
    for(int a=0;a<=1000;a++){
        for(int b=0;b<=1000;b++){
            sum[a+b]++;
        }
    }
    
    while(cin >> n){
        int ans = 0;
        for(int i=0;i<=2000;i++){
            if(n-i < 0 || n-i > 2000) continue;
            ans += sum[i]*sum[n-i];
        }
        cout << ans << endl;
    }
    
    return(0);
}


Measured memory_bytes: 3100
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
int be[100005]={};
int num[100005];
int n,m;
int me(int r){
	if(num[r]==0) return 0;
	if(be[r]) return be[r];
	if(r==0){
		if(num[1]<num[0]){
			be[0]=m-num[0];
			return m-num[0];
		}else{
			be[0]=me(1)+m-num[0];
			return me(1)+m-num[0];
		}
	}else if(r==n-1){
		if(num[n-2]<num[n-1]){
			be[n-1]=m-num[n-1];
			return m-num[n-1];
		}else{
			be[n-1]=me(n-2)+m-num[n-1];
			return me(n-2)+m-num[n-1];
		}
	}else{
		if(num[r]>num[r-1] && num[r]>num[r+1]){
			be[r]=m-num[r];
			return m-num[r];
		}else if(num[r]<num[r-1] && num[r]<num[r+1]){
			be[r]=max(me(r-1),me(r+1))+m-num[r];
			return max(me(r-1),me(r+1))+m-num[r];
		}else{
			if(num[r]>num[r-1]){
				be[r]=me(r+1)+m-num[r];
				return me(r+1)+m-num[r];
			}else{
				be[r]=me(r-1)+m-num[r];
				return me(r-1)+m-num[r];
			}
		}
	}
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	int res=0;
	for(int i=0;i<n;i++){
		res=max(res,me(i));
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3756
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
b_next = 0
ans = 0
for i in range(n):
    if b_next >= a[i]:
        ans += a[i]
        b_next = b[i]
    elif b_next < a[i]:
        if b[i] < a[i] - b_next:
            ans += b_next + b[i]
            b_next = 0
        elif b[i] >= a[i] - b_next:
            ans += a[i]
            b_next = b[i] - (a[i] - b_next)
ans += min(a[n], b_next)
print(ans)

Measured memory_bytes: 25620
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int n;
    cin >> n;
    int num = 0; 
    int a = n;
    while(a > 0){
        num += a % 10;
        a /= 10;
    }
    if(n % num == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
A, B, K = map(int,input().split())

for k in range(K):
    if k%2 == 0:
        if A%2 == 0:
            A //= 2
            B += A
        else:
            A -= 1
            A //= 2
            B += A
    else:
        if B%2 == 0:
            B //= 2
            A += B
        else:
            B -= 1
            B //= 2
            A += B
print(A,B)

Measured memory_bytes: 40024
#include <stdio.h>
int main() {
	char s[3][11];
	scanf("%s%s%s", s[0], s[1], s[2]);
	for (int i = 0; i < 3; i++)
	{
		if		(s[i][0] == 'a') printf("A");
		else if (s[i][0] == 'b') printf("B");
		else if (s[i][0] == 'c') printf("C");
		else if (s[i][0] == 'd') printf("D");
		else if (s[i][0] == 'e') printf("E");
		else if (s[i][0] == 'f') printf("F");
		else if (s[i][0] == 'g') printf("G");
		else if (s[i][0] == 'h') printf("H");
		else if (s[i][0] == 'i') printf("I");
		else if (s[i][0] == 'j') printf("J");
		else if (s[i][0] == 'k') printf("K");
		else if (s[i][0] == 'l') printf("L");
		else if (s[i][0] == 'm') printf("M");
		else if (s[i][0] == 'n') printf("N");
		else if (s[i][0] == 'o') printf("O");
		else if (s[i][0] == 'p') printf("P");
		else if (s[i][0] == 'q') printf("Q");
		else if (s[i][0] == 'r') printf("R");
		else if (s[i][0] == 's') printf("S");
		else if (s[i][0] == 't') printf("T");
		else if (s[i][0] == 'u') printf("U");
		else if (s[i][0] == 'v') printf("V");
		else if (s[i][0] == 'w') printf("W");
		else if (s[i][0] == 'x') printf("X");
		else if (s[i][0] == 'y') printf("Y");
		else if (s[i][0] == 'z') printf("Z");
		else	printf("%c",s[i][0]);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
        public static void main(String args[]) throws Exception
        {
                Scanner cin=new Scanner(System.in);
                int a=cin.nextInt();
                String c=cin.next();
                int b=cin.nextInt();
                if(c.charAt(0)=='+') 
                       System.out.println(a+b);
                else 
                       System.out.println(a-b);
                cin.close();
        }
}

Measured memory_bytes: 22868
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		ll ans = 0;
		RANGE(i, 1, N+1) {
			string s = to_string(i);
			if(s.size()%2==1) ans++;
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int M; cin >> M;
	vector<int>d(M), c(M); rep(i, 0, M) { cin >> d[i] >> c[i]; }

	vector<vector<vector<pii>>>hoge(10);

	rep(k, 0, 10) {
		vector<vector<pii>>dp(10, vector<pii>(60));
		rep(i, 0, 10) {
			int nxt = i + k;
			int cost = 1;
			if (nxt >= 10) {
				cost++;
				nxt %= 10;
				nxt++;
			}
			dp[i][0] = pii(nxt, cost);
		}
		rep(i, 1, 60) {
			rep(d, 0, 10) {
				auto x = dp[d][i - 1];
				auto y = dp[x.first][i - 1];
				dp[d][i].first = y.first;
				dp[d][i].second = x.second + y.second;
			}
		}
		hoge[k] = dp;
	}


	int ans = 0;
	int cur = 0;
	rep(i, 0, M) {
		rrep(a, 0, 60) {
			if ((c[i] >> a) & 1) {
				auto p = hoge[d[i]][cur][a];
				ans += p.second;
				cur = p.first;
				dump(i,cur, a);
			}
		}
	}
	cout << ans-1 << endl;


	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

vector<ll> par(100000); //親
vector<ll> siz(100000); 

//初期化
void init(int n){
    for(int i=0;i<n;i++) par[i]=i;
    fill(siz.begin(),siz.end(),1);
}

//親を求める
int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]); //検索毎に根を親に組み替える
}

//統合 xの根とyの根を繋ぐ
void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y) return;  //すでに統合済み

    if(siz[x]<siz[y]) swap(x,y); //大きい集合(X)に小さい集合(Y)を接続
    siz[x]+=siz[y]; //サイズ増加
    par[y]=x; //根の組み替え
    return;
}

int main(){
	int N,M,ans=0;
	cin>>N>>M;
	init(100000);
	vector<int> p(N);
	for(int i=0;i<N;i++){
		cin>>p[i];
		p[i]--;
	}
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--; b--;
		unite(a,b);
	}
	for(int i=0;i<N;i++){
		if(root(i)==root(p[i])) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mt make_tuple
#define mod 1000000007
#define pi 3.14159265358979
#define float double
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
int main()
{
    fastio;
    ll i,j,k,n,m,t;
    cin>>n;
    ll dig=n%10;
    if(dig==2||dig==4||dig==5||dig==7||dig==9)
    {
        cout<<"hon"<<endl;
    }
    else if(dig==3)
    {
        cout<<"bon"<<endl;
    }
    else
    {
        cout<<"pon"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int n, h ,w; cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;

    return 0;
}


Measured memory_bytes: 3532
#include<bits/stdc++.h>
#define reg register
#define inf 9982443530000000
#define maxn 5001
#define int long long
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int n, A, B, a[maxn], b[maxn], pos[maxn], ans = inf, dp[maxn][maxn];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n = read(); A = read(); B = read();
	for(int i = 1; i <= n; i++) a[i] = read(), pos[a[i]] = i;
	memset(dp, 0x3f3f3f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < i; j++)
		{
			if(pos[i] > pos[j]) {
				dp[i][i] = min(dp[i - 1][j], dp[i][i]);
				dp[i][j] = dp[i - 1][j] + B;
			}
			else dp[i][j] = dp[i - 1][j] + A;
		}
	}
	for(int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
	cout << ans << endl;
	return 0;
}


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

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

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

inline void read() {}

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

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

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

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

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

    int N;
    read(N);

    vector<int> a(N+1);
    reps(i, 1, N) read(a[i]);

    vector<int> b(N+1);
    repr(i, N, 1) {
        int cnt = 0;
        for (int k = i; k <= N; k += i) {
            cnt += b[k];
        }
        if ((cnt & 1) != a[i]) {
            b[i] = 1;
        }
    }

    trace(b);
    print(count(all(b), 1));
    reps(i, 1, N) {
        if (b[i]) print(i);
    }
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const int N=1e5+1, V=2e5, E=8e5;
int n, m, to[E], cap[E], head[V], next[E], cur[V], queue[V], dis[V], u[N], v[N], tot;
bool vis[N];
std::vector<int> in[N];
void add_edge(int u, int v, int w) {
	to[m]=v, cap[m]=w, next[m]=head[u], head[u]=m++;
	to[m]=u, cap[m]=0, next[m]=head[v], head[v]=m++;
}
bool bfs() {
	int *qhead=queue, *qtail=queue;
	memset(dis, -1, 2*n*sizeof(int));
	dis[*qtail++=n]=true;
	while(qhead!=qtail) {
		int u=*qhead++;
		for(int i=head[u]; ~i; i=next[i])
			if(dis[to[i]]==-1&&cap[i^1]) {
				dis[*qtail++=to[i]]=dis[u]+1;
				if(to[i]==0) return true;
			}
	}
	return false;
}
int dfs(int x, int lim) {
	if(x==n) return lim;
	int rem=lim;
	for(int &i=cur[x]; ~i; i=next[i])
		if(cap[i]&&dis[to[i]]==dis[x]-1) {
			int t=dfs(to[i], std::min(lim, cap[i]));
			cap[i]-=t, cap[i^1]+=t;
			if((rem-=t)==0) return lim;
		}
	return lim-rem;
}
void sol(int x) {
	vis[x]=true;
	++tot;
	for(int y: in[x]) {
		int z=u[y];
		if(z!=x&&!vis[z]) v[y]=x, sol(z);
	}
}
int main() {
	n=rd();
	memset(head, -1, 2*n*sizeof(int));
	for(int i=1; i<n; ++i) add_edge(0, i, 1), add_edge(n+i, n, 1);
	for(int i=1; i<n; ++i) {
		int c=rd();
		while(c--) {
			int j=rd();
			in[j].emplace_back(i);
			if(j!=n) add_edge(j, n+i, 1);
		}
	}
	int flow=0;
	while(bfs()) {
		memcpy(cur, head, 2*n*sizeof(int));
		flow+=dfs(0, 1e9);
	}
	if(flow!=n-1) {
		puts("-1");
		return 0;
	}
	for(int i=1; i<n; ++i)
		for(int j=head[n+i]; ~j; j=next[j])
			if(cap[j]) u[i]=to[j];
	sol(n);
	if(tot<n) {
		puts("-1");
		return 0;
	}
	for(int i=1; i<n; ++i) printf("%d %d\n", u[i], v[i]);
	return 0;
}


Measured memory_bytes: 23296
#include<iostream>


using namespace std;


int a[2005];
bool solve(int i, int m,int n) {

	if (m == 0)return true;

	if (i >= n)return false;

	bool res = solve(i + 1, m, n) || solve(i + 1, m - a[i],n);

	return res;

}

int main(){

	int n;
	int q,m;


	cin >> n;

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

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> m;
		bool ans = solve(0, m, n);
		if (ans) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}

	return 0;

}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<map>
int main(void){
    int n;
    std::cin >> n;
    std::map<std::string, int> m;
    for(int i = 0; i < n; i++){
	std::string s;
	std::cin >> s;
	m[s]++;
    }
    int max = 0;
    for(auto i : m){
	max = std::max(max, i.second);
    }
    for(auto i : m){
	if(i.second == max){
	    std::cout << i.first << std::endl;
	}
    }
    return 0;
}



Measured memory_bytes: 19244
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1],b[n+1],c[n+1];
	int dp[n+1][4];
	for(int i=1;i<=n;i++)
	cin>>a[i]>>b[i]>>c[i];
	dp[1][1]=a[1];
	dp[1][2]=b[1];
	dp[1][3]=c[1];
	for(int i=2;i<=n;i++)
	{
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c[i];
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));

}

Measured memory_bytes: 6368
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll gcd(ll a,ll b){
  if(a < b) return gcd(b, a);
    int r;
    while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){

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

  ll dp1[n]={};//a[0]~a[i]までの最大公約数
  ll dp2[n]={};//a[i]~a[n-1]までの最大公約数

  dp1[0]=a[0];
  for(int i=1;i<n;i++)dp1[i]=gcd(dp1[i-1],a[i]);

  dp2[n-1]=a[n-1];
  for(int i=n-2;i>=0;i--)dp2[i]=gcd(dp2[i+1],a[i]);

  ll s=0;
  s=dp2[1];
  for(int i=1;i<n-1;i++){
    s=max(s,gcd(dp1[i-1],dp2[i+1]));
  }
  s=max(s,dp1[n-2]);

  cout << s << endl;

}

Measured memory_bytes: 5948
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
#include <iomanip>
#include <queue>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<int> A(N);
    vector<pair<int,int>> CB(M);

    
    rep(i,N) {
        cin >> A.at(i);
    }
    rep(i,M) {
        int b,c;
        cin >> b >> c;
        CB.at(i) = make_pair(c,b);
    }

    sort(A.begin(),A.end());
    sort(CB.begin(),CB.end(), std::greater<pair<int,int>>());

    ll ret = 0;
    auto itrA = A.begin();
    auto itrC = CB.begin();
    while(itrA != A.end()) {
        if (itrC != CB.end() && *itrA < itrC->first) {
            ret += itrC->first;
            itrC->second--;
            if(itrC->second <= 0) itrC++;
        } else {
            ret += *itrA;
        }
        itrA++;
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

bool solve() {

  int n, k; cin >> n >> k;
  if (n == 0 and k == 0) return false;

  vector<int> a(n + 1, 0);
  for (int i = 0; i < k; i++) {
    int in; cin >> in;
    a[in] = 1;
  }

  vector<vector<int>> dp(n + 1, vector<int> (2, 0));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 2; j++) {
      if (a[i]) {
        dp[i][j] = max(dp[i][j], dp[i - 1][j] + 1);
      } else {
        if (j == 0) {
          dp[i][1] = max(dp[i][1], dp[i - 1][0] + 1);
        }
      }
    }
  }
  
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp[i][0]);
    if (a[0]) {
      ans = max(ans, dp[i][1]);
    }
  }

  cout << ans << endl;
  return true;
}

int main() {
  
  while (solve()) {
  }
  return 0;
}



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

void solve(){
  int n; cin >> n;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    int t = sqrt(x) + 1;
    bool prime = true;
    for(int i = 2; i <= min(t, x - 1); i++){
      if(x % i == 0) prime = false;
    }
    if(prime == true) ans++;
  }
  cout << ans << endl;
  return;
}
int main(){
  solve();
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(30);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, p;
    cin >> a >> p;
    cout << (3 * a + p) / 2;



}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int c[3];

int main()
{
  char s[100001];
  scanf("%s", s);
  for (char *p = s; *p; ++p)
  {
    c[*p - 'a']++;
  }
  std::sort(c, c + 3);
  puts(c[2] - c[0] <= 1 ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 256
/*
    Washief Hossain Mugdho
    21 September 2020
    Educational DP DigitSum
*/

#ifndef DEBUG
#pragma GCC optimize("-O2")
#endif

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define fastio ios_base::sync_with_stdio(0)
#define untie cin.tie(0)
#define ms(a, b) memset(a, b, sizeof a)
#define mod 1000000007
using namespace std;
string s;
int d;
int memo[10009][105][2];

int dp(int n, int sofar, int small)
{
    if (n >= s.size())
        return (sofar == 0);
    if (memo[n][sofar][small] != -1)
        return memo[n][sofar][small];
    if (small)
    {
        int res = 0;
        for (int i = 0; i < 10; i++)
            res = (res + dp(n + 1, (sofar + i) % d, 1)) % mod;
        return memo[n][sofar][small] = res;
    }
    int digit = s[n] - '0';
    int res = dp(n + 1, (sofar + digit) % d, 0);
    for (int i = 0; i < digit; i++)
        res = (res + dp(n + 1, (sofar + i) % d, 1)) % mod;

    return memo[n][sofar][small] = res;
}

int main()
{
#ifdef LOCAL_OUTPUT
    freopen(LOCAL_OUTPUT, "w", stdout);
#endif
#ifdef LOCAL_INPUT
    freopen(LOCAL_INPUT, "r", stdin);
#endif
    ms(memo, -1);
    cin >> s >> d;
    cout << (dp(0, 0, 0) - 1 + mod) % mod << endl;
}


Measured memory_bytes: 12576
#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(){
    ll n;
    cin >> n;
    ll x = 1000000007;
    ll j = 1;
    ll k = 1;
    ll l = 1;
    ll ans;
    rep(i,n){
        j = j*10;
        if (j >= x){
            j = j%x;
        }
    }
    rep(i,n){
        k = k*9;
        if (k>=x) k = k%x;
    }
    rep(i,n){
        l = l*8;
        if(l>=x) l = l%x;
    }
    ans = j - k - k + l;
    if (ans >= 0){
        cout << ans % x << endl;
    }
    else{
        while (ans < 0){
            ans += x;
        }
        cout << ans % x << endl;
    }



}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int N, X, Y, Z, ans = 0, bjur = 0, cjur = 0;
	cin >> N >> X;
	vint a(X);
	for (int i = 0; i < X; i++)cin >> a[i];
	cin >> Y;
	vint b(Y);
	for (int i = 0; i < Y; i++)cin >> b[i];
	cin >> Z;
	vint c(Z);
	for (int i = 0; i < Z; i++)cin >> c[i];

	for (int i = 0; i < Z; i++) {
		bjur = 0;
		cjur = 0;
		for (int j = 0; j < Y; j++) {
			if (c[i] == b[j])bjur = 1;
		}
		
		for (int j = 0; j < X; j++) {
			if (a[j] == c[i])cjur = 1;
		}
		if (bjur == 1 || cjur == 0)ans++;
	}
cout<<ans<<endl;
	

}



Measured memory_bytes: 3120
import numpy as np
a,b,x=map(int,input().split())

if x <= a**2 * b / 2:
    print(90. - np.rad2deg(np.arctan(2*x/(a*b**2))))
else:
    print(np.rad2deg(np.arctan(2*(b-x/(a**2))/a)))

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  string S, T;
  cin >> S;
  cin >> T;
  int ans = 0;
  REP(n,S.size()) {
    if(S[n] == T[n]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, m);
    
    int np = 1 << n;
    constexpr int inf = 1e9;
    vc<vc<int>> dp(m+1, vc<int>(np, inf));
    dp[0][0] = 0;
    For(i, m){
        Cin(int, a, b);
        Cinm(int, b, m);
        int bits = 0;
        for(int j = n; j >= 1; j --) bits = ((bits << 1) + m[j]);
        // Cout("[", a, ", ", bits, "]");
        For(j, np){
            dp[i+1][j] = dp[i][j];
            // if(~j & bits) continue;
            Mini(dp[i+1][j], dp[i][j & ~bits] + a);
        }
    }
    // For(i, m+1) Couts(dp[i]);
    Cout((dp[m][np-1] == inf) ? -1 : dp[m][np-1]);
}




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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var k = p[1];
		var a = Input().ToInt();
		
		var dp = new bool[k+1];	//残りiつの時の勝敗。
		
		for(int i = 1; i <= k; i++)
		{
			for(int j = 0; j < n; j++)
			{
				if(i - a[j] >= 0)
				{
					dp[i] |= !dp[i - a[j]];
				}
			}
		}
		if(dp[k])
		{
			Console.WriteLine("First");
		}
		else
		{
			Console.WriteLine("Second");
		}
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13160
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
const int inf=INT64_MAX;
int factt(int n){
    int ans=1;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c){
    return max(a,max(b,c));
}
int min(int a,int b,int c){
    return min(a,min(b,c));
}
int fspow(int x,int y){
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans);
    return x*ans*ans;
}
int gcd(int x,int y){
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x){
    int ans=0;
    while(x>=1){
        ans++;
        x/=2;
    }
    return ans;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
   //  cin>>t;
    //int tmp=t;
    while(t--){
        int x;
        cin>>x;
        if(x) cout<<0<<'\n';
        else cout<<1<<'\n';
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    string s;
    cin>>s;
    int l=s.size(),ans=0;
    rep(i,l/2){
        if(s[i]!=s[l-1-i])ans++;
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>                                                                  #include <algorithm>
                                                                                using namespace std;
                                                                                int main()
{
  int N;
  cin >> N;
  long sum = 0; 
  for (int i = 0; i < N; ++i) {
    int n;
    cin >> n;
    sum += n;
  }
  cout << (sum - N) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;
ll dp[110][8];

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    k--;

    dp[0][0] = 1;
    REP(i,h) REP(j,w){
        REP(x,1<<(w-1)){
            bool ok = true;
            REP(y,w-2){
                if (((x >> y) & 1) && ((x >> (y + 1)) & 1)) ok = false;
            }
            if (!ok) continue;
            int next = j;
            if ((x >> j) & 1) next++;
            if ((x >> (j - 1)) & 1) next--;
            dp[i+1][next] = (dp[i+1][next] + dp[i][j]) % mod;
        }
    }

    ll ans = dp[h][k];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
from collections import defaultdict
N = int(input())
A = [int(v) for v in input().split()]
cnt = 0
left_list = [i + a for i, a in enumerate(A, 1)]
right_list = [i - a for i, a in enumerate(A, 1)]
right_dict = defaultdict(set)
for i, right in enumerate(right_list, 1):
    right_dict[right].add(i)
for i, left in enumerate(left_list, 1):
    pair_num = len(right_dict[left])
    cnt += pair_num
print(cnt)

Measured memory_bytes: 150288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt(), nQ=fs.nextInt();
		
		int[] a=fs.readArray(n);
		int[] lastSeen=new int[n+10];
		Arrays.fill(lastSeen, n);
		BIT bit=new BIT(n+100);
		
		Query[] queries=new Query[nQ];
		ArrayList<Query>[] queriesAt=new ArrayList[n];
		for (int i=0; i<n; i++) queriesAt[i]=new ArrayList<>();
		for (int qq=0; qq<nQ; qq++) {
			int l=fs.nextInt()-1, r=fs.nextInt()-1;
			Query q=new Query(l, r);
			queries[qq]=q;
			queriesAt[l].add(q);
		}
		
		for (int l=n-1; l>=0; l--) {
			bit.update(lastSeen[a[l]], -1);
			bit.update(l, 1);
			lastSeen[a[l]]=l;
			
			for (Query qq: queriesAt[l]) {
				qq.ans=bit.read(qq.r);
			}
		}
		PrintWriter out=new PrintWriter(System.out);
		for (Query qq:queries)
			out.println(qq.ans);
		out.close();
	}
	
	static class Query {
		int l, r, ans;
		public Query(int l, int r) {
			this.l=l;
			this.r=r;
		}
	}
	
	static class BIT {
		int n;
		int[] tree;
		
		public BIT(int n) {
			this.n = n;
			tree = new int[n + 2];
		}
		
		int read(int i) {
			i++;
			int sum = 0;
			while (i > 0) {
				sum += tree[i];
				i -= i & -i;
			}
			return sum;
		}
		
		void update(int i, int val) {
			i++;
			while (i <= n) {
				tree[i] += val;
				i += i & -i;
			}
		}

		// if the BIT is a freq array, returns the
		// index of the kth item, or n if there are fewer
		// than k items.
		int getKth(int k) {
			int e=Integer.highestOneBit(n), o=0;
			for (; e!=0; e>>=1) {
				if (e+o<=n && tree[e+o]<=k) {
					k-=tree[e+o];
					o+=e;
				}
			}
			return o;
		}
		
	}

	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}

}


Measured memory_bytes: 125444
n = int(input())
a = list(map(int, input().split()))
front_b = []
b = []
index = []
if n == 1:
    print(a[0])
    exit()
if n % 2 == 0:
    b.append(a[1])
    b.append(a[0])
    index.append(1)
    index.append(0)
else:
    b.append(a[0])
    b.append(a[1])
    index.append(0)
    index.append(1)
for i in range(index[0] + 2, n, 2):
    front_b.append(a[i])
front_b.reverse()
for i in range(index[1] + 2, n, 2):
    b.append(a[i])
print(*front_b, end=' ')
print(*b)

Measured memory_bytes: 26180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        String rs = String.valueOf(r);
        String gs = String.valueOf(g);
        String bs = String.valueOf(b);

        String num = rs + gs + bs;
        int number = Integer.parseInt(num);

        if (number % 4 == 0)
            System.out.println("YES");
        else
            System.out.println("NO");

    }


}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define dfor(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long
#define ull unsigned long long

int main() {
	int a,b;
	cin>>a>>b;
	int n = 0;
	if(b==1){
		cout<<0;
		return 0;
	}
	if(a>=b){
		cout<<1;
		return 0;
	}
	int num=a;
	n=1;
	while(num<b){
		num+=a-1;
		n++;
	}
	cout<<n;
}

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
#define V std::vector
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 4e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 998244353, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

ll QPow(ll a, ll b) {
	ll ans = 1, bas = a;
	for(; b; b >>= 1, bas = bas * bas % kMod) if(b & 1) ans = ans * bas % kMod;
	return ans;
}

ll fac[kN], fac_inv[kN];
ll C(int n, int m) {
	return fac[n] * fac_inv[m] % kMod * fac_inv[n - m] % kMod;
}
int main() { 
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	int T = 1; //rd(T);
	while(T--) {
		ll n, m, k, ans = 0; rd(n, m, k);
		fac[0] = 1; for(int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % kMod;
		fac_inv[n] = QPow(fac[n], kMod - 2);
		for(int i = n - 1; ~i; --i) fac_inv[i] = fac_inv[i + 1] * (i + 1) % kMod;
		for(int i = 0; i <= k; ++i) {
			ans = (ans + m * QPow(m - 1, n - i - 1) % kMod * C(n - 1, n - i - 1) % kMod) % kMod;
		}
		printf("%lld", ans);
	} return 0;
}

Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int par[200010]; //親
int siz[200010]; //根ノードiの木に含まれる要素数。iが根ノード出ない場合無意味な値となる。

//n要素で初期化
void init(int n) {
	for(int i = 0;i < n;i++) {
		par[i] = i;
		siz[i] = 1;
	}
}

//木の根を求める
int find(int x) {
	if(par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

//ｘとｙの属する集合を併合
void unite(int x,int y) {
	x = find(x);
	y = find(y);
	if(x == y) {
		return;
	}
	if(siz[x] < siz[y]) {
		swap(x,y);
	}
	par[y] = x;
	siz[x] += siz[y];
}

//ｘとｙが同じ集合に属するか否か
bool same(int x,int y) {
	return find(x) == find(y);
}

int size(int x) {
	return siz[find(x)];
}

int main() {
    int N,K,L;
    cin >> N >> K >> L;
    init(N);
    for(int i = 0;i < K;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        unite(A,B);
    }
    vector<int> road(N);
    for(int i = 0;i < N;i++) {
        road.at(i) = find(i);
    }
    init(N);
    for(int i = 0;i < L;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        unite(A,B);
    }
    vector<int> train(N);
    for(int i = 0;i < N;i++) {
        train.at(i) = find(i);
    }
    map<P,int> cnt;
    for(int i = 0;i < N;i++) {
        P p = P(road.at(i),train.at(i));
        cnt[p]++;
    }
    for(int i = 0;i < N;i++) {
        cout << cnt[P(road.at(i),train.at(i))] << " ";
    }
    cout << endl;
}

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

using Vertex = size_t;
using Graph = vector<vector<Vertex>>;
template<typename T> using PropMap = vector<T>;

inline void addEdge(Graph& g, Vertex u, Vertex v) {
    g[u].push_back(v);
    g[v].push_back(u);
}

template<typename Action>
inline void forEachOutVertices(const Graph& g, Vertex u, const Action& action) {
    for (auto v : g[u]) {
        action(v);
    }
}

int main() {
    size_t n, m, k;
    cin >> n >> m >> k;
    Graph frends(n);
    for (size_t i = 0; i < m; i++) {
        Vertex a, b;
        cin >> a >> b;
        addEdge(frends, a - 1, b - 1);
    }
    Graph blocks(n);
    for (size_t i = 0; i < k; i++) {
        Vertex a, b;
        cin >> a >> b;
        addEdge(blocks, a - 1, b - 1);
    }
    PropMap<int> vertexProp(n);
    for (Vertex u = 0; u < n; u++) {
        if (vertexProp[u] == 0) {
            unordered_set<Vertex> visitedVertices;
            stack<Vertex> q;
            q.push(u);
            while(!q.empty()) {
                Vertex v = q.top();
                q.pop();
                if (visitedVertices.count(v) == 0) {
                    visitedVertices.emplace(v);
                    forEachOutVertices(frends, v, [&](auto w) {
                        q.push(w);
                    });
                }
            }
            for (Vertex v : visitedVertices) {
                int count = visitedVertices.size() - 1;
                forEachOutVertices(frends, v, [&](auto w) {
                    if (visitedVertices.count(w) != 0) {
                        count--;
                    }
                });
                forEachOutVertices(blocks, v, [&](auto w) {
                    if (visitedVertices.count(w) != 0) {
                        count--;
                    }
                });
                vertexProp[v] = count;
            }
        }
        if (u != 0) {
            cout << " ";
        }
        cout << vertexProp[u];
    }
    cout << endl;

    return 0;
}

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

int main(){
  int N;
  int count = 0;
  cin >> N;
  vector<int> d(N);
  rep(i,N)
    cin >> d.at(i);
  
  vector<int> zeros(N,0);
  while(1){
  	int max = 0;
  	rep(i,N){
      if(max<d.at(i))
        max = d.at(i);
  	}
	rep(i,N){
      if(d.at(i)==max)
        d.at(i) = 0;
    }
    count++;
    if(d==zeros)
      break;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]
ans = -1
cost = 10 ** 7
for i in range(2 ** N):
    bit = format(i, '0' + str(N) + 'b')
    A = [0] * M
    work_cost = 0
    counter = 0
    for b in bit:
        if b == "0":
            counter += 1
        else:
            work_cost += CA[counter][0]
            for i, ca in enumerate(CA[counter][1:]):
                A[i] += ca
            counter += 1
        # 理解度がX以上の参考書の数
    x = sum([1 for i in A if i >= X])
    if M == x:
        cost = min(cost, work_cost)
    # print(bit, work_cost, A)

if cost == 10 ** 7:
    cost = -1
print(cost)

Measured memory_bytes: 9236