akhauriyash/Code-Regression huggingface dataset:
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    vll ans(3, 0); ans[a - 1] = 1; ans[b - 1] = 1;
    REP(i, 3) {
        if (ans[i] == 0) {
            cout << i + 1 << '\n';
            break;
        }
    }
    return 0;
}


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

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

	minn = min(min(a,b),c);
	maxn = max(max(a,b),c);

	if(minn != a && maxn != a) midn = a;
	else if(minn != b && maxn != b) midn = b;
	else midn = c;

	cout << minn << " " << midn << " " << maxn << endl;
	return 0;
}


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

int main(){
  ll n,ctr=0;
  cin>>n;
  vector<string>s(n);
  map<string,ll>m;
  for(ll i=0;i<n;i++){
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
    ctr+=m[s[i]];
    m[s[i]]++;
  }
  cout<<ctr<<endl;
  return 0;
}


Measured memory_bytes: 18176
using System;

namespace AtCoder {
    class Program {
        static void Main() {
            long x = long.Parse(Console.ReadLine());
            long yokin = 100, year = 0;
            while(yokin < x) {
                yokin += yokin / 100;
                year++;
            }
            Console.WriteLine(year);
        }
    }
}

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

int main(){
  int x, y;
  while(std::cin >> x >> y){
    if(x == 0 and y == 0)break;
    if(x > y)swap(x, y);
    std::cout << x << " " << y << std::endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> input(N);
  for (int i = 0; i < N; i++) {
    cin >> input[i];
  }
  int cnt = 0;
  for (int i = 1; i < N - 1; i++) {
    if (input[i - 1] < input[i] && input[i] < input[i + 1]) cnt++;
    if (input[i - 1] > input[i] && input[i] > input[i + 1]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX_N 810

int cost[MAX_N][MAX_N];
int size[MAX_N];
int p[MAX_N], d[MAX_N];
int N;
int res1 = 0, res2 = 0, rmax = 0;

typedef struct{
	int isl, len;
}result;

int max(int a, int b){
	if(a > b) return a;
	else return b;
}

result dfs(int is, int prei, int len){//????????¶???????????¶????????¢->?????¢????????§??¨????????¶??¨???????????¢
	result res1, res2;
	int i;
	res1.isl = is; res1.len= len;
	for(i = 0; i < N; i++){
		if(i == is || i == prei) continue;
		if(cost[is][i] > 0){
			res2 = dfs(i, is, len+cost[is][i]);
			if(res1.len < res2.len) res1 = res2;
		}
	}
	return res1;
}

int main(int argc, char const *argv[])
{
	int i, j;
	while(1){
		scanf("%d", &N);
		if(N == 0) break;
		res1 = 0 ; res2 = 0;
		for(i = 0; i < N; i++)for(j = 0; j < N; j++) cost[i][j] = 0;
		for(i = 0; i < N; i++) size[i] = 0;
		for(i = 1; i < N; i++){ scanf("%d", &p[i]); p[i]--; }
		for(i = 1; i < N; i++) scanf("%d", &d[i]);
		for(i = 1; i < N; i++){
			cost[i][p[i]] = d[i];
			cost[p[i]][i] = d[i];
			size[p[i]]++;
			size[i]++;
		}
		for(i = 0; i < N; i++){
			if(size[i] == 1){
				for(j = 0;j < N;j++){
					if(cost[i][j] != 0){
						res1 += cost[i][j];
						cost[i][j] = 0;
						cost[j][i] = 0;
					}
				}
			}
		}
		for(i = 0; i < N; i++)for(j = i+1; j < N;j++) res2 += cost[i][j];
		result r;
		for(i = 0; i < N; i++){
			if(size[i] > 1){
				r = dfs(i,-1,0);
				r = dfs(r.isl,-1,0);
				break;
			}
		}

		printf("%d\n", res1+res2*3-r.len);
	}
	return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[105];
	cin>>s;
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='C')
		  for(int j=i;j<strlen(s);j++)
		    if(s[j]=='F')
		    {
			  cout<<"Yes";
			  return 0;
		    }  
	}
	cout<<"No";
	return 0;
}


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


def main():
    for a in range(n + 1):
        for b in range(n - a + 1):
            c = n - a - b
            if (a * 1000 + b * 5000 + c * 10000 == y) & (a + b + c == n):
                return print(c, b, a)
    return print("-1 -1 -1")


main()


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

using namespace std;


int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    vector <string> v ={"AC", "WA", "TLE", "RE"};
    vector <int> cnt(4);
    while(n--){
        string s;
        cin >> s;
        for (int i = 0; i < 4; ++i) {
            if(v[i] == s)
                cnt[i]++;
        }
    }
    for(int i = 0; i < 4; ++i){
        cout << v[i] << " x " << cnt[i] << "\n";
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
vector<string> vs;
//=============================
void input()
{
    cin>>N;
    vs.resize(N);
    rep(i,0,N-1){
        cin>>vs[i];
    }

}
//=============================
void func(){}
//=============================
void solve()
{
    map<char,int> mp;
    char M='M';
    char A='A';
    char R='R';
    char C='C';
    char H='H';
    for(auto x : vs){
        char n = x[0];
        if (n == M  || n==A || n== R || n==C || n==H){
            mp[n]++;
        }
    }
    
    int n = mp.size();
    int ans = 0;

    string ss = "MARCH";
    rep(i,0,4){
        rep(j,i+1,4){
            rep(k,j+1,4){
               ans +=  mp[ss[i]]*mp[ss[j]]*mp[ss[k]];
            }
        }
    }

    cout<<ans<<endl;



}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
void abb(int n, int m){
	long long sum;
	sum = (1900 * m + 100 * (n - m))*  (pow(2, m));
	cout << sum;
}
int main(){
    long long n, m;
    cin >> n >> m;
	abb(n, m);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

typedef pair<int, int> P;

ll modnum = 998244353;

const int MAX = 200005;


long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

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



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

    COMinit();

    ll ans = 0;
    rep(i, k+1) {
        ll tmp = m*modpow(m-1, n-i-1, modnum)%modnum;
        tmp = tmp * COM(n-1, i) % modnum;
        ans += tmp;
        ans %= modnum;
    }

    cout << ans << endl;

    return 0;

}



Measured memory_bytes: 8296
// https://atcoder.jp/contests/abc167/tasks/abc167_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  string S, T;
  cin >> S >> T;

  if (S == T.substr(0, S.size())) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
bool ischar(char c){
	if('A'<=c&&c<='Z')return true;
	else return false;
}
signed main(){
	string s;
	cin>>s;
	int k;
	cin>>k;
	int dp[110][4][2]={};
	dp[0][1][0]=s[0]-'0'-1;
	dp[0][1][1]=1;
	dp[0][0][0]=1;
	for(int i=1;i<s.size();i++){
		dp[i][0][0]=dp[i-1][0][0];
		for(int j=1;j<=k;j++){
			dp[i][j][0]+=dp[i-1][j-1][0]*9+dp[i-1][j][0];
			if(s[i]!='0'){
				dp[i][j][0]+=dp[i-1][j-1][1]*(s[i]-'0'-1);
				dp[i][j][0]+=dp[i-1][j][1];
			}
			if(s[i]=='0'){
				dp[i][j][1]=dp[i-1][j][1];
			}else{
				dp[i][j][1]=dp[i-1][j-1][1];
			}
		}
	}
	/*for(int i=0;i<s.size();i++){
		for(int j=0;j<=k;j++){
			for(int l=0;l<2;l++){
				cout<<dp[i][j][l]<<" ";
			}
			cout<<endl;
		}
		cout<<endl;
	}*/
	cout<<dp[s.size()-1][k][0]+dp[s.size()-1][k][1]<<endl;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll r;cin >> r;
	cout << 3 * r * r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#pragma warning(disable : 4996)


struct Node {
	int value;
	Node *parent;
	Node *left;
	Node *right;
	Node() : parent(NULL), left(NULL), right(NULL) {}
};

void Preorder(Node *node) {
	printf(" %d", node->value);
	if(node->left != NULL) Preorder(node->left);
	if(node->right != NULL) Preorder(node->right);
}
void Inorder(Node *node) {
	if (node->left != NULL) Inorder(node->left);
	printf(" %d", node->value);
	if (node->right != NULL) Inorder(node->right);
}
void Postorder(Node *node) {
	if (node->left != NULL) Postorder(node->left);
	if (node->right != NULL) Postorder(node->right);
	printf(" %d", node->value);
}
Node *Insert(Node *root, Node *z) {
	Node *y = NULL;
	Node *x = root;
	while (x != NULL) {
		y = x;
		if (z->value < x->value) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NULL) {
		root = z;
	}
	else if(z->value < y->value) {
		y->left = z;
	}
	else {
		y->right = z;
	}
	return root;
}
Node *Find(Node *root, int v) {
	Node *x = root;
	while (x != NULL) {
		if(x->value == v) { 
			return x;
		}
		else if (v < x->value) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	return NULL;
}
int main(void) {
	int n;
	scanf("%d", &n);
	char line[1024];
	Node *root = NULL;
	for (int i = 0; i < n; ++i) {
		scanf("%s", &line[0]);
		if (strcmp(line, "print") == 0) {
			Inorder(root);
			printf("\n");
			Preorder(root);
			printf("\n");
		}
		else {
			int k;
			scanf("%d", &k);
			if (strcmp(line, "insert") == 0) {
				Node *z = new Node();
				z->value = k;
				root = Insert(root, z);
			}
			else {
				if (Find(root, k) == NULL) {
					printf("no\n");
				}
				else {
					printf("yes\n");
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 21472
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<string>S(N);
	rep(i, N)cin >> S[i];
	string T;
	cin >> T;
	vector<string>a(N), z(N);
	a = z = S;
	rep(i, N)rep(j, a[i].size())if (a[i][j] == '?')a[i][j] = 'a';
	rep(i, N)rep(j, z[i].size())if (z[i][j] == '?')z[i][j] = 'z';
	sort(a.begin(), a.end());
	sort(z.begin(), z.end());
	int A = N + 1, Z = N + 1;
	rep(i, N)if (a[i] > T) {
		A = i + 1;
		break;
	}
	rep(i, N)if (z[i] >= T) {
		Z = i + 1;
		break;
	}
	for (int i = Z; i <= A; i++) {
		cout << i;
		if (i != A)cout << " ";
	}
	cout << endl;
}

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

int main(){
    int n,m,a,b;
    cin >> n >> m;
    vector<vector<int>> g(n);

    for(int i = 0;i < m;i++){
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    vector<int> dist(n, -1);
    vector<int> prev(n, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int nv : g[v]) {
            if (dist[nv] != -1) continue;

            dist[nv] = dist[v] + 1;
            prev[nv] = v;
            que.push(nv);
        }
    }

    cout << "Yes" << endl;
    for (int v = 1; v < n; ++v) cout << prev[v] + 1 << endl;
}


Measured memory_bytes: 10724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

int main()
{
ll n;
cin >> n ;
vector<vector<ll>> g(n);
vector<pair<ll,ll>> v(n);
rep(i, n)
{
  ll a, b;
  cin >> a >> b;
  v[i].first=a;
  v[i].second=b;
  if(i==0)continue;
  g[i].push_back((i-1)/2);
  g[(i-1)/2].push_back(i);
}
vector<ll> par(n);
vector<ll> d(n);
vector<bool> see(n);
{
queue<ll> q;
par[0]=-1;
see[0]=1;
d[0]=1;
q.push(0);
while(!q.empty()){
  auto p=q.front();
  q.pop();
  for(auto r:g[p]){
    if(see[r]!=0)continue;
    par[r]=p;
    d[r]=d[p]+1;
    see[r]=1;
    q.push(r);
  }
}
}
vector<vector<ll>> dp(min(n,(1LL<<9) -1), vector<ll>(100010,INF) );
rep(i,100010)if(i<v[0].second)dp[0][i]=0; else dp[0][i]=v[0].first; 
rep(i,min(n,(1LL<<9) -1)){
  if(i==0)continue;
  rep(j,100010)dp[i][j]=dp[(i-1)/2][j];
  rep(j,100010)if(j-v[i].second>=0)dp[i][j]=max(dp[i][j], dp[(i-1)/2][j-v[i].second]+v[i].first);
}
ll q ;
cin >> q ;
vector<ll> ans(q,0);
rep(i,q){
  ll u , l ;
  cin >> u >>l  ;
  if(u< 1LL<<9)ans[i]=dp[u-1][l];
  else{
    vector<pair<ll,ll>> t;
    ll w=u-1;
    rep(j,d[u-1]-9){
      t.push_back(v[w]);
      w=(w-1)/2;
    }
    rep(j,1LL<<t.size()){
      ll vv=0,ww=0;
      rep(k,t.size())if((j>>k)&1LL){vv+=t[k].first;ww+=t[k].second;}
      if(l-ww>=0)ans[i]=max(ans[i],dp[w][l-ww]+vv);
    }
  }
}
for(auto r:ans)cout << r << endl;
return 0;
}

Measured memory_bytes: 429996
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node{
    int wield;
    int throw;
}node;

int cmpDscWield(const void* a, const void* b){
    int x = ((node*)a)->wield, y = ((node*)b)->wield;
    if(x < y){
        return 1;
    }
    if(x > y){
        return -1;
    }
    return 0;
}

int cmpDscThrow(const void* a, const void* b){
    int x = ((node*)a)->throw, y = ((node*)b)->throw;
    if(x < y){
        return 1;
    }
    if(x > y){
        return -1;
    }
    return 0;
}

int main(){
    int n, h;
    scanf("%d %d", &n, &h);
    node a[n];
    rep(i, 0, n){
        scanf("%d %d", &a[i].wield, &a[i].throw);
    }
    qsort(    a,   n, sizeof(node), cmpDscWield);
    qsort(&a[1], n-1, sizeof(node), cmpDscThrow);
    int ans = 0;
    rep(i, 1, n){
        if(h<=a[i].throw || h<=a[0].throw || h<=a[0].wield){
            h = 0;
            ans++;
            break;
        }
        if(a[i].throw < a[0].wield){
            break;
        }
        h -= a[i].throw;
        ans++;
    }
    if(h > 0){
        if(a[0].wield >= a[0].throw){
            ans += (h + a[0].wield - 1)/a[0].wield;
        }else{
            ans++;
            h -= a[0].throw;
            if(h > 0){
                ans += (h + a[0].wield - 1)/a[0].wield;
            }
        }
    }
    printf("%d", ans);

    return 0;
}

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

#define STR_LEN 100

int main(void)
{
    char str[STR_LEN];
    char str2[STR_LEN];
    int len;
    int i,j,k;

    while (scanf("%s", str) != EOF)
    {
        k = 0;
        len = strlen(str);
        for (i = 0; i < len; i++){
            if (str[i] == '@'){
                for (j = 0; j < str[i + 1] - '0'; j++){
                    str2[k] = str[i + 2];
                    k++;
                    //printf("<%d %c>", k, str2[k]);
                }
                i += 2;
                
            }else{
                str2[k] = str[i];
                k++;
            }
            
        }

        for (i = 0; i < k; i++){
            printf("%c", str2[i]);
        }
        printf("\n");
    }

    return (0);
}


Measured memory_bytes: 2100
/*
 Educational Dp Contest Atcoder
 
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}

const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=1e5+5;
int h[N+1];int dp[N];
void solve()
{
    
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=0;i<=n;i++)
        dp[i]=INF;
    dp[1]=0;
    
    for(int i=2;i<=n;i++)
    {
        for(int j=i-1;j>=max((int)1,i-k);j--)
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    cout<<dp[n]<<endl;
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;


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

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  ll n;
  cin>>n;
  mint ans=mint(10).pow(n);
  ans=ans-mint(9).pow(n)-mint(9).pow(n)+mint(8).pow(n);
  cout<<ans.x<<endl;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

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

    bool t = true;
    
    string f,b;


    rep(i,Q) {
        int q;
        cin >> q;
        
        if (q==1) {
            if (t) t = false;
            else t = true;
        }
        else {
            int p;
            cin >> p;
            string tmp;
            cin >> tmp;
            if (p==1 and t) {
                f = tmp+f;
            }
            else if (p==1 and !t) {
                b = b + tmp;
            }
            else if (p==2 and t) {
                b = b + tmp;
            }
            else {
                f = tmp + f;
            }
        }
    }
    if (t) {
        cout << f + S + b << endl;
    }
    else {
        reverse(S.begin(),S.end());
        reverse(f.begin(),f.end());
        reverse(b.begin(),b.end());


        cout << b + S + f<< endl;
    }
}



Measured memory_bytes: 1512
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String str = sc.next();
        	int sum = 0;

        	if(str.equals("0")) {
        		break;
        	}

        	for(int i = 0; i < str.length(); i++) {
        		sum += Integer.parseInt(str.substring(i, i+1));
        	}

        	System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26664
# -*- coding: utf-8 -*-


def main():
    s = list(input())
    n = len(s)
    large_k = int(input())
    dp = [[[0 for k in range(2)] for j in range(4)] for i in range(105)]
    dp[0][0][0] = 1

    # See:
    # https://www.youtube.com/watch?v=JQmQjJd-sLA&feature=youtu.be
    for i in range(n):
        for j in range(4):
            for k in range(2):
                nd = int(s[i])

                for digit in range(10):
                    ni, nj, nk = i + 1, j, k

                    if digit != 0:
                        nj += 1
                    if nj > large_k:
                        continue
                    if k == 0:
                        if digit > nd:
                            continue
                        if digit < nd:
                            nk = 1

                    dp[ni][nj][nk] += dp[i][j][k]

    print(dp[n][large_k][0] + dp[n][large_k][1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = 1e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

bool compare_by_b(P a, P b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
  cin>>n;
  vp t(n);
  REP(i,n){
      ll a,b;
      cin>>a>>b;
      t[i]=make_pair(a,b);
  }
  sort(ALL(t), compare_by_b);
  ll c=0;
  REP(i,n){
      c+=t[i].first;
      if(c>t[i].second){
          cout<<"No"<<endl;
          return 0;
      }
  }
  cout<<"Yes"<<endl;
}

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

int N, W;

int w[110];
int v[110];

long long dp[110][100100] = {0};

int main(){
    cin >> N >> W;
    for(int i=0; i < N; i++) cin >> w[i] >> v[i];

    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j - w[i] >= 0) dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll ,ll>;
const ll INF = 1LL<<61LL;

int main(){
	ll X, Y;
	cin >> X >> Y;
	if(abs(X - Y) <= 1)
		cout << "Brown" << endl;
	else
		cout << "Alice" << endl;
}


Measured memory_bytes: 256
# ABC057
# B
# Checkpoints

n, m = map(int, input().split())
ax = [None]*n
by = [None]*n
cx = [None]*m
dy = [None]*m

d_list = [[None]*m for i in range(n)]

for i in range(n):
    ax[i],by[i] = map(int, input().split())
for i in range(m):
    cx[i],dy[i] = map(int, input().split())

for i in range(n):
    for j in range(m):
        d_list[i][j] = abs(ax[i]-cx[j]) + abs(by[i]-dy[j])
        
for i in range(n):
    print(d_list[i].index(min(d_list[i]))+1)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;
const int N = 205, M = 510;
const int mod = 1e9 + 7;

inline int ksm(int a, int b = mod - 2) {
	int ans = 1; 
	for (; b; b >>= 1, a = 1ll * a * a % mod) 
		if (b & 1) ans = 1ll * ans * a % mod;
	return ans;
}

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

vector<int> D[N];
int dfn[N], low[N], cnt, num, c[N], sta[N], top, fac[M], inv[M], ifac[M], root;
struct edge{int y, next;} a[M << 1]; int len, last[N];
void ins(int x, int y) {a[++len] = (edge){y, last[x]}; last[x] = len;}

void tarjan(int x) {
	dfn[x] = low[x] = ++cnt; sta[++top] = x; int flag = 0;
	for (int k = last[x], y; k; k = a[k].next) {
		++flag;
		if (!dfn[y = a[k].y]) {
			tarjan(y);
			low[x] = min(low[x], low[y]);
			if (low[y] == dfn[x]) {
				++num; int z;
				do {
					z = sta[top--];
					D[num].push_back(z);
				} while (z != y);
				D[num].push_back(x);
			}
		}
		else low[x] = min(low[x], dfn[y]);
	}
}

int K;

int check(int u) {
	if (D[u].size() == 1) return -1;
	if (D[u].size() == 2) return 0;
	int siz = 0;
	for (int x : D[u]) c[x] = u;
	for (int x : D[u]) {
		for (int k = last[x], y; k; k = a[k].next) {
			if (c[y = a[k].y] == u) ++siz;
		}
	}
	siz /= 2;
	return siz;
}
 
int calc1(int n) {
	int ans = ksm(K, n);
	for (int i = 1; i < n; ++i) 
		ans = (ans + ksm(K, gcd(n, i))) % mod;
	ans = 1ll * ans * ksm(n) % mod;
	return ans;
}


int binom(int n, int m) {
	if (n < m || n < 0 || m < 0) return 0;
	if (n == m || m == 0) return 1;
	return 1ll * fac[n] * ifac[n - m] % mod * ifac[m] % mod;
}

int main() {
	len = 1; memset(last, 0, sizeof last);
	int n, m; scanf("%d%d%d", &n, &m, &K);
	for (int i = 1; i <= m; ++i) {
		int x, y; scanf("%d%d", &x, &y);
		ins(x, y); ins(y, x);
	}
	fac[0] = ifac[0] = inv[0] = fac[1] = ifac[1] = inv[1] = 1;
	for (int i = 2; i <= K + m; ++i) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[i] = 1ll * inv[mod % i] * (mod - mod / i) % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
	}
	for (int i = 1; i <= n; ++i) if (!dfn[i]) 
		tarjan(i);
	int ans = 1;
	for (int i = 1; i <= num; ++i) {
		int flag = check(i);
		if (flag == -1) continue;
		if (!flag) {ans = 1ll * ans * K % mod; continue;}
		int siz = D[i].size();
		if (flag == siz) ans = 1ll * ans * calc1(siz) % mod;
		else ans = 1ll * ans * binom(flag + K - 1, K - 1) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3224
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 1;
        int w = sc.nextInt();
        int p = sc.nextInt();
        int q = sc.nextInt();
        int a = Math.min(p,q);
        int b = Math.max(p,q);
        if(b<=a+w){
            ans=0;
        }else{
            ans=b-a-w;
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 21844
#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>;
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); }

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s.at(i);
    map<char, int> mp;
    for (char c : s.at(0)) mp[c]++;
    for (int i = 1; i < n; ++i) {
        map<char, int> m;
        for (char c : s.at(i)) m[c]++;
        for (auto p : mp) {
            if (m.count(p.first)) {
                mp.at(p.first) = min(p.second, m.at(p.first));
            }
            else mp.at(p.first) = 0;
        }
    }
    stringstream ss;
    for (auto p : mp) {
        rep(i, p.second) ss << p.first;
    }
    cout << ss.str() << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
 
#define FOR(idx, begin, end) for(int idx = (begin); idx < (end); ++idx)
#define DMP(x) cerr << #x << ": " << x << "\n"
 
using namespace std;
typedef long long lint;
const int MOD = 1000000007;
 
int main() {
 
	cin.tie(0);
 
	int N, M;
	cin >> N >> M;
 
	vector<int> visited(N, 0);
 
	vector<int> a(M), b(M);
	FOR(i, 0, M) cin >> a[i] >> b[i];
 
	vector<vector<int>> path(N, vector<int>(N, 0));
	FOR(i, 0, M) {
		path[a[i] - 1][b[i] - 1] = 1;
		path[b[i] - 1][a[i] - 1] = 1;
	}
 
	int ans = 0;
 
	stack<pair<int, vector<int>>> node;
	node.push({0, visited});
 
	while (!node.empty()) {
		
		auto now = node.top();
		now.second[now.first] = 1;
		node.pop();
 
		FOR(i, 0, N) {
			if (now.second[i] == 0 && path[now.first][i] == 1) {
 
				node.push({i, now.second});
			}
		}
 
		FOR(i, 0, N) {
 
			if (now.second[i] == 0) break;
			if (i == N - 1) ans++;
		}
	
	}
 
	cout << ans;
 
	return 0;
}


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

int n;
int x[30], y[30], r[30], c[30];
bool used[30];
vector<int> G[30];
map<int,int> m;

int dfs(int f){
	int ret = 0;
	if(m[f]) return m[f];
	rep(i,n){
		if(used[i])continue;
		used[i] = true;
		bool yes = true;
		rep(j,G[i].size()){
			if(!used[G[i][j]]){
				yes = false;
				break;
			}
		}
		if(yes){
			for(int j = i+1; j < n; j++){
				if(used[j]) continue;
				if(c[i] != c[j]) continue;
				
				used[j] = true;
				bool no = false;
				rep(k,G[j].size()){
					if(G[j][k] == i){
						no = true;
						break;
					}
					if(!used[G[j][k]]){
						no = true;
						break;
					}
				}
				if(!no){
					ret = max(ret,dfs(f+(1<<i)+(1<<j))+2);
				}
				used[j] = false;
			}
		}
		used[i] = false;
	}
	m[f] = ret;
	return ret;
}

int main(){
	while(scanf("%d",&n),n){
		memset(used,0,sizeof(used));
		m.clear();
		rep(i,30) G[i].clear();
		rep(i,n) scanf("%d%d%d%d",x+i,y+i,r+i,c+i);
		rep(i,n) for(int j = i+1; j < n; j++){
			if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<(r[i]+r[j])*(r[i]+r[j])){
				G[j].pb(i);
			}
		}
		printf("%d\n",dfs(0));
	}
}

Measured memory_bytes: 50108
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
string test[123456];
signed main() {
	vector<char> v; map<int, int> cost;
	int n, m, a, b, c, cnt = 0, ans = 0; string s, t;
	cin >> n >> a >> b >> c;
	for (int h = 0; h < n; h++) { cin >> s; test[h] = s; }
	for (int h = 0; h < n; h++) {
		if (test[h] == "AB") {
			if (a == 0 && b == 0) { cout << "No" << endl; return 0; }
			else if (a == 0) { a++; b--; v.push_back('A'); }
			else if (b == 0) { b++; a--; v.push_back('B'); }
			else {
				if (test[h + 1] == "AC") { a++; b--; v.push_back('A'); }
				else { a--; b++; v.push_back('B'); }
			}
		}
		if (test[h] == "AC") {
			if (a == 0 && c == 0) { cout << "No" << endl; return 0; }
			else if (a == 0) { a++; c--; v.push_back('A'); }
			else if (c == 0) { c++; a--; v.push_back('C'); }
			else {
				if (test[h + 1] == "AB") { a++; c--; v.push_back('A'); }
				else { a--; c++; v.push_back('C'); }
			}
		}
		if (test[h] == "BC") {
			if (b == 0 && c == 0) { cout << "No" << endl; return 0; }
			else if (b == 0) { b++; c--; v.push_back('B'); }
			else if (c == 0) { c++; b--; v.push_back('C'); }
			else {
				if (test[h + 1] == "AB") { b++; c--; v.push_back('B'); }
				else { b--; c++; v.push_back('C'); }
			}
		}
	}
	cout << "Yes" << endl;
	for (int h = 0; h < v.size(); h++) {
		cout << v[h] << endl;
	}
	return 0;
}

Measured memory_bytes: 7564
import sys
import math
def get_array(): return list(map(int,sys.stdin.readline().strip().split()))
def get_ints(): return map(int,sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
x,y=get_ints()
flag=0
if y%2!=0:
    flag=0
else:
    a=y//2 
    b=a-x
    a=x-b
    if a<0 or b<0:
        flag=0 
    else:
        flag=1 
if flag==1:
    print("Yes")
else:
    print("No")
    

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

int main() {
  int a, b;
  cin >> a >> b;
  int min, max;
  if(a > b){
    max = a;
    min = b;
  } else {
    max = b;
    min = a;
  }
  
  for(int i=1; i<=max ; i++){
    if(i < max ){
      cout << min;
    } else {
      cout << min << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int graph[101][101] = {0};
	int num;
	int hon;
	int eda;
	int ver;

	cin>>num;
	for(int i=0;i<num;i++){
		cin>>eda;
		cin>>hon;
		for(int j=0;j<hon;j++){
			cin>>ver;
			graph[eda][ver]++;
		}
	}
	for(int i=1;i<=num;i++){
		for(int j=1;j<=num;j++){
			cout<<graph[i][j];
			if(j==num)
				break;
			cout<<" ";
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1208
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 14
 * 
 */

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    lv(a);
    lv(b);
    if((a+b)&1)
        puts("IMPOSSIBLE");
    el
        cout<<(a+b)/2LL<<endl;
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();

		int[] cnt = new int[4];

		for (char c : s) {
			if (c == 'N') {
				cnt[0]++;
			} else if (c == 'S') {
				cnt[1]++;
			} else if (c == 'W') {
				cnt[2]++;
			} else if (c == 'E') {
				cnt[3]++;
			}
		}

		if ((cnt[0] == 0 && cnt[1] != 0)
				|| (cnt[0] != 0 && cnt[1] == 0)
				|| (cnt[2] == 0 && cnt[3] != 0)
				|| (cnt[2] != 0 && cnt[3] == 0)) {
			pr.println("No");
		} else {
			pr.println("Yes");
		}
	}

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9556
#include<stdio.h>
#include<algorithm>
using namespace std;

int N;
int A[1000010];
int ans = 0;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d",A + i);
    }
    sort(A, A + N);
    int sum = 1;
    for(int i = 0; i < N; i++)
    {
        if(i == N - 1 || A[i] != A[i + 1])
        {
            if(sum % 2)ans++;
            sum = 0;
        }
        sum++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;
int main()
{
    int n,i,j,step=0;
    long long int k;
    scanf("%d",&n);
    scanf("%lld",&k);
    static int t[200005],book[200005]={0};
    for(i=1;i<=n;i++)scanf("%d",&t[i]);
    for(i=1;book[i]!=1;i=t[i])
    {
        step++;
        book[i]=1;
    }
    step--;
    int tmp=step;
    step=0;
    for(j=1;j!=i;j=t[j])step++;
    if(k<step)
    {
        int ans=1;
        while(k--)ans=t[ans];
        printf("%d",ans);
        return 0;
    }
    k=(k-step)%(tmp-step+1);
    int ans=i;
    while(k--)
    {
        ans=t[ans];
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;


int main(){
    string s;
    cin >> s;

    int L = s.length();

    string result = s[0] + to_string(L-2) + s[L-1];

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	string s;
	cin>>s;
	int sum=0;
	rep(i,s.size()){
		sum+=s[i]-'0';
		sum%=9;
	}
	if(sum==0)cout<<"Yes\n";
	else cout<<"No";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <set>
using namespace std;
bool cnt[100005],vis[100005];
vector<int> v[100005];
set<pair<int,int> > ans;
bool dfs(int node,int p)
{
	vis[node]=1;
	bool f=cnt[node];
	for (int u:v[node])
	{
		if (!vis[u])
		f^=dfs(u,node);
	}
	if (node!=1 && f)
	{
		ans.erase({min(node,p),max(node,p)});
		ans.insert({max(node,p),min(node,p)});
	}
	return f;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	while (m--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
		cnt[min(a,b)]^=1;
		ans.insert({min(a,b),max(a,b)});
	}
	if (dfs(1,0))
	printf("-1");
	else
	{
		for (auto p:ans)
		printf("%d %d\n",p.first,p.second);
	}
}

Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000
#define INF 1e18
typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll a[100005];
int main()
{
    fastread;
     ll i,j,k,n,m,y,t;
    string s;
    cin>>n;
   for(i=0;i<n;i++)
    cin>>a[i];
    ll gun=1;
      double jog=0.00000;

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

  jog+=(double)(log10f ((double)a[i]));

   }

   if(jog>18) {
            cout<<-1<<endl;}
            else
            {
                for(i=0;i<n;i++)
                    gun*=a[i];
                    if(gun>INF) cout<<"-1\n";
                    else cout<<gun<<endl;
            }
    return 0;
}


Measured memory_bytes: 4700