akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        String s = sc.nextLine();
        String t = sc.nextLine();
        int len = s.length();

        for (int i = 0; i < len; i++) {
            char tmp = s.charAt(len - 1);
            String stmp = s.substring(0, len - 1);
            s = tmp + stmp;

            if (s.equals(t)) {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");
    }

}

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

int main() {
    int n;
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++) {
        if (i%3 == 0||i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a < b && b < c){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
#define PER(i,y,x) for(ll i=y; i>=x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
using namespace std;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	ll n = s.size();
	string cur = "";
	ll ans = 0;
	REP(i,0,n-1){
		if(cur.size() != 1){
			cur = s.substr(i,1);
			ans++;
		}else if(i == n-1 && cur == s.substr(n-1,1)){
			break;

		}
		else if(cur == s.substr(i,1)){
			cur = s.substr(i,2);
			i++;
			ans++;
		}else{
			cur = s.substr(i,1);
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<utility>
#include<vector>
#include<iostream>
#include<string>
using namespace std;

int main(){
	int i, g, j, gj, h, gh;
	cin >> i >> g >> j >> gj >> h >> gh;

	if(i + 5*g + 10*j + 50*gj + 100*h + 500*gh >= 1000){
		cout << "1" << endl;
	}

	else{
		cout << "0" << endl;
	}

	/*int d, c;
	cin >> d >> c;
	cout << d * c << endl;*/





	return 0;

}



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int t, n;
  scanf("%d", &t);
  while(t--){
    scanf("%d", &n);
    vector<int>l(n);
    rep(i, n) scanf("%d", &l[i]);
    int maxl = 0, minl = 0;
    rep(i, n-1){
      maxl = max(maxl, l[i+1] - l[i]);
      minl = min(minl, l[i+1] - l[i]);
    }
    printf("%d %d\n", maxl, -1 * minl);
  }
  return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class B {
	int a, b, c, d;
public:
	B()
	{
		cin >> a >> b >> c >> d;
	}
	void solve()
	{

		vi arr(101, 0);

		for (int i = a; i <= b; i++)
			++arr[i];
		for (int i = c; i <= d; i++)
			++arr[i];

		int ans{ 0 };
		REP(i, 101)
			if (arr[i] == 2)
				++ans;

		cout << max(0, ans - 1) << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;
string s;
int k;
vector<string> a; 
char c,cc;
int main(){
  cin>>s>>k;
  
  for(int i=0;i<s.size();i++){
    for(int j=1;j<=k;j++){
      a.push_back(s.substr(i,j));
    }
  }
  
  sort(a.begin(),a.end());
  string ans=a[0];
  int now=1;
  for(int i=1;i<k;i++){
    while(ans==a[now]){
      now++;
    }
    ans=a[now];
  }
  cout<<ans<<endl;
 
  return 0;
}



Measured memory_bytes: 1660
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

ll memo[100001]={0};

ll rec(ll n);

int main(void) {
    int a, b;
    cin >> a >> b;
    if(a+b==15)
        cout << "+";
    else if(a*b==15)
        cout << "*";
    else
        cout << "x";
        
}


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

using namespace std;
typedef long long ll;

ll sum[20];

ll len(ll x){
	if(x==0) return 0;
	ll ret = 0;
	int keta = 0;
	ll t = x;
	ll ex = 1;
	while(t){
		keta++;
		t /= 10;
		ex *= 10;
	}
	ex /= 10;
	ret += sum[keta-1];
	// cout<<"keta "<<keta<<endl;
	ll fiz = x/3 - (ex-1)/3;
	ll buz = x/5 - (ex-1)/5;
	ll fizbuz = x/15 - (ex-1)/15;
	ll mod = x-ex+1-fiz-buz+fizbuz;
	// cout<<"len "<<x<<" "<<fiz<<" "<<buz<<" "<<mod<<endl;
	ret += fiz * 4 + buz * 4 + mod * keta;
	return ret;
}

char idx(ll l, int x){
	if(l%15==0){
		return "FizzBuzz"[x];
	}
	if(l%3==0){
		return "Fizz"[x];
	}
	if(l%5==0){
		return "Buzz"[x];
	}
	stringstream ss;
	ss << l;
	string t;
	ss >> t;
	return t[x];
}


char func(ll x){
	ll l = 0;
	ll r = 1e17;
	while(r-l>1){
		ll mid = (r+l)/2;
		// cout<<l<<" "<<r<<" "<<mid<<" "<<len(mid)<<endl;
		if(len(mid)<x){
			l = mid;
		}
		else{
			r = mid;
		}
	}
	x -= len(l);
	// cout<<"func "<<r<<" "<<x-1<<endl;
	return idx(r, x-1);
}

int main(){
	ll tmp = 10;
	sum[1] = 21;
	for(int i=2; i<20; i++){
		tmp *= 10;
		sum[i] += sum[i-1];
		sum[i] += tmp/10*9*i;
		sum[i] += ((tmp-1)/3-(tmp/10-1)/3)*(4-i);
		sum[i] += ((tmp-1)/5-(tmp/10-1)/5)*(4-i);
		sum[i] += ((tmp-1)/15-(tmp/10-1)/15)*(i);
		// cout<<sum[i]<<endl;
	}
	ll s;
	cin>>s;
	for(int i=0; i<20; i++){
		// cout<<"i "<<i<<endl;
		cout<<func(s+i);
		// cout<<s+i<<" "<<func(s+i)<<endl;
	}
	// for(int i=1; i<10000; i++){
	// 	ll l = len(i) - len(i-1);
	// 	ll a;
	// 	if(i%15==0) a = 8;
	// 	else if(i%3==0) a = 4;
	// 	else if(i%5==0) a = 4;
	// 	else{
	// 		stringstream ss;
	// 		ss<<i;
	// 		string t;
	// 		ss>>t;
	// 		a = t.size();
	// 	}
	// 	if(a != l){
	// 		cout<<i<<" "<<l<<" "<<a<<endl;
	// 		cout<<len(i-1)<<" "<<len(i)<<endl;
	// 		return 0;
	// 	}
	// }
	cout<<endl;
}

Measured memory_bytes: 3176
/*
	Author:Bhavya Soriya
*/
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define MAX 1000000007

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;


int main()
{
	fast
    vector<PII> v;
	int n;
	cin>>n;
	int temp;
	for(int i=0;i<n;i++)
	{
		cin>>temp;
		v.push_back({temp,i+1});
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
	{
		cout<<v[i].second<<" ";
	}
	return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    string S; cin >> S;
    int cnt = 0;
    REP(i,S.size()) if (S[i] == '1') cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k,w[100001];

int check(ll P){
    int i = 0;
    for (int j=0; j<k; j++){
        ll s = 0;
        while(s + w[i] <= P){
            s += w[i];
            i++;
            if( i == n ) return n;
        }
    }
    return i;
}

int solve(){
    ll left = 0;
    ll right = 100000*10000;
    ll mid;
    while (right-left>1){
        mid = (right+left)/2;
        int v = check(mid);
        if(v == n) right = mid;
        else if (v < n) left = mid;
    }
    return right;
}

int main(){
    cin >> n >> k;
    for(int i=0; i<n; i++) cin >> w[i];
    ll ans = solve();
    cout << ans << endl;
}


Measured memory_bytes: 3488
#include<iostream>
using namespace std;
int a,b,c,d;
int main(){
	cin>>a>>b>>c;
	d=a;
	a=b;
	b=d;
	d=a;
	a=c;
	c=d;
	cout<<a<<' '<<b<<' '<<c<<endl;
	return 0;
	
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long double n, m, d; cin >> n >> m >> d;
	if(d == 0) {
		cout << setprecision(15) << (double)((m - 1) / n) << endl;
	}
	else {
		cout << setprecision(15) << double((m - 1) * 2 * (n - d) / (n * n)) << endl;
	}
	return 0;                                              
}
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    ll N; cin >> N;
    double x[N];
    string u;
    double sum = 0;
    for(ll i = 0; i < N; i++){
        cin >> x[i] >> u;
        if(u == "JPY"){
            sum += x[i];
        } else {
            sum += x[i]*380000.0;
        }
    }
    cout << fixed << setprecision(5) << sum << endl;

}

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

//最大公約数の計算(ユークリッドの互除法)
long long int gcd(long long int a, long long int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

int main() {
    lint k;
    cin >> k;
    if (gcd(k, 10) != 1) {
        cout << -1 << endl;
        return 0;
    }
    lint a = 7 % k;
    lint n = 1;
    while (true) {
        if (a == 0) {
            cout << n << endl;
            return 0;
        }
        a = (a + 7 * pow_mod(10, n, k) % k) % k;
        n++;
    }
}

Measured memory_bytes: 3672
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#define int long long
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0,-1 }; // x軸方向への変位
int dy[4] = { 1, 0,-1, 0 }; // y軸方向への変位


struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};

int p[1000000];

signed main() {
	uf_tree uf(1000000);
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		int tmp;
		cin >> tmp;
		p[i] = tmp;
	}
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		uf.unite(x, y);
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (uf.is_same(i, p[i])) ans++;
	}
	cout << ans << "\n";


	return 0;




}

Measured memory_bytes: 8832
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int goodsNum, maxWeight;
    cin >> goodsNum >> maxWeight;

    int values[goodsNum];
    int weights[goodsNum];
    rep(i, goodsNum) {
        cin >> values[i] >> weights[i];
    }

    int table[goodsNum + 1][maxWeight + 1];
    rep(w, maxWeight + 1) {
        table[0][w] = 0;
    }
    rep(i, goodsNum) {
        rep(w, maxWeight + 1) {
            if (w >= weights[i]) {
                table[i+1][w] = std::max(std::max(table[i+1][w - weights[i]] + values[i], table[i][w - weights[i]] + values[i]), table[i][w]);
            } else {
                table[i+1][w] = table[i][w];
            }
        }
    }

    cout << table[goodsNum][maxWeight] << endl;
}


Measured memory_bytes: 7044
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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

    int x = n/500;
    int y = n - x*500;

    if(y <= a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import collections

N, M = map(int, input().split(' '))
edges = {i: [] for i in range(N)}
depth = [-1 for i in range(N)]
ans = []

for _ in range(M):
    A, B = map(int, input().split(' '))
    edges[A - 1].append(B - 1)
    edges[B - 1].append(A - 1)

depth[0] = 0
que = collections.deque()
que.append((0, -1))
while que:
    now, par = que.popleft()
    for edge in edges[now]:
        if edge == par or depth[edge] != -1:
            continue
        depth[edge] = depth[now] + 1
        que.append((edge, now))

for i in range(1, N):
    for edge in edges[i]:
        if depth[edge] < depth[i]:
            ans.append(edge + 1)
            break

print('Yes')
print('\n'.join([str(a) for a in ans]))

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

int main() {
  int N;
  cin>>N;
  
  for (int i = 0; i < N; i++) {
    char x;
    cin >>x;
    if (x=='Y'){
      cout<<"Four"<<endl;
      break;
    }
    else if(i==N-1){
      cout<<"Three"<<endl;
    }
  }
}

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

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

int main()
{
  int H, W;
  char s[50][50];
  cin >> H >> W;

  rep(i,H) cin >> s[i];

  rep(i,H){
    rep(j, W) {
      if(s[i][j] == '#') {
        bool flag = false;
        rep(k, 4) {
          int x = j + dx[k];
          int y = i + dy[k];
          if(0 <= x && x < W && 0 <= y && y < H && s[y][x] == '#')
            flag = true;
        }
        if(!flag) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;
ll const MAX_N = 100005;

int main() {
    INIT;
    ll N;
    cin >> N;
    vector<ll> X(N), L(N);
    rep(i, N) { cin >> X[i] >> L[i]; }

    // vector<ll> s(N), t(N);
    pair<ll, ll> itv[MAX_N];
    rep(i, N) {
        itv[i].first = X[i] + L[i];
        itv[i].second = X[i] - L[i];
    }

    sort(itv, itv + N);
    // rep(i, N) { cout << itv[i].second << ", " << itv[i].first << endl; }

    ll ans = 0, t = -INF;
    rep(i, N) {
        if (t <= itv[i].second) {
            ans++;
            t = itv[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	ll n, k,a[20],b[20];	
	b[0] = 0;
	char c[26] = { 'a', 'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	for (int i = 1; i < 12; i++)b[i] = pow(26, i) + b[i - 1];
	cin >> n;
	for (ll i = 1; i > 0; i++) {
		if (b[i] >= n) { k = i; break; }
	}
	if(k>1)n -= b[k-1];
	n--;
	for (int i = 0; i < k; i++) {		
	   a[i] = n%26;
		n /= 26;
	}
	for (int i = k-1; i >=0; i--)cout << c[a[i]];

return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
int N,D;
bool dist_int(vector<vector<int>> &X, int &s, int &t){
    int dist_square = 0;
    for (int i=0; i<D; ++i) dist_square += pow((X[s][i] - X[t][i]), 2);
    return (pow(((int)sqrt(dist_square*1.0)), 2)==dist_square) ? true : false;
}
int main() {
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i=0; i<N; ++i) for (int j=0; j<D; ++j) cin >> X[i][j];
    int res = 0;
    for (int s = 0; s<N-1; ++s) for (int t=s+1; t<N; ++t) {
        if (dist_int(X, s, t)) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node
{
	int p,l,r;
};

Node T[MAX];
int n,D[MAX];

void print(int u)
{
	int i,c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = "<< D[u] << ", ";

	if(T[u].p==NIL)
	{
		cout<<"root, ";
	}
	else if(T[u].l==NIL)
	{
		cout<<"leaf, ";
	}
	else
	{
		cout<<"internal node, ";
	}

	cout<<"[";

	for(i = 0,c = T[u].l;c != NIL;i++,c = T[c].r)
	{
		if(i)
		{
			cout<<", ";
		}
		cout<<c;
	}
	cout<<"]"<<endl;
}

int rec(int u, int p)
{
	D[u]=p;
	if(T[u].r!=NIL)
	{
		rec(T[u].r,p);
	}
	if(T[u].l!=NIL)
	{
		rec(T[u].l,p+1);
	}
}

int main()
{
	int i,j,d,v,c,l,r;
	cin>>n;
	for(i=0;i<n;i++)
	{
		T[i].p = T[i].l = T[i].r = NIL;
	}
	for(i=0;i<n;i++)
	{
		cin>>v>>d;
		for(j=0;j<d;j++)
		{
			cin>>c;
			if(j==0)
			{
				T[v].l=c;
			}
			else
			{
				T[l].r=c;
			}
			l=c;
			T[c].p=v;
		}
	}
	for(i=0;i<n;i++)
	{
		if(T[i].p==NIL)
		{
			r=i;
		}
	}

	rec(r,0);

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

	return 0;
}


Measured memory_bytes: 7672
from collections import Counter
 
def factorize(N):
    p = 2
    PRIME = []
    while p * p <= N:
        if N % p == 0:
            N //= p
            PRIME.append(p)
        else:
            p += 1
    if N > 1:
        PRIME.append(N)
    return Counter(PRIME)
 
n = int(input())
 
prime = factorize(n)
ans=0
for i in prime:
  for j in range(1,prime[i]+1):
    if n % i**j==0:
      n//=i**j
      ans+=1
print(ans)

Measured memory_bytes: 9468
#include <stdio.h>

int trape(int a, int b, int h) {
    int i;
    i = ((a + b) * h)/ 2;
    return i;
}

int main(void) {
    int a, b, h;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &h);

    printf("%d\n", trape(a, b, h));
    return 0;
}


Measured memory_bytes: 128
function Main(input: string) {
  const lines = input.split('\n');
  const params = lines[0].split(' ').map(x => parseInt(x));

  const a = params[0]; // Aピザの値段
  const b = params[1]; // B
  const c = params[2]; // AB
  const x = params[3]; // Aの枚数
  const y = params[4]; // Bの枚数

  const cost = (i: number, j: number, k: number) =>
    a * i + b * j + c * k;

  const min =
    Math.min(
      interval(0, x) // A: x
        .map(i => cost(i, Math.max(0, y - (x - i)), 2 * (x - i)))
        .reduce((n, m) => Math.min(m, n)),
      interval(0, y) // B: y
        .map(i => cost(Math.max(0, x - (y - i)), i, 2 * (y - i)))
        .reduce((n, m) => Math.min(m, n))
    );

  console.log(min);
}

function interval(start: number, end: number): number[] {
  if (start > end) return [];

  let a: number[] = [];
  for (let i = start; i <= end; i++) {
    a.push(i);
  }
  return a;
}

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

Measured memory_bytes: 15136
#include<iostream>
using namespace std;
int main(){
  int a, b, c, x;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  int cnt = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        if(x - 500*i - 100*j - 50*k == 0) cnt++;
      }
    }
  }
  cout << cnt;
    return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
max = 0
for i in range((10 ** 5 ) + 1):
    cand = bisect.bisect_left(a, i + 3) - bisect.bisect_left(a, i)
    if max < cand:
        max = cand
print(max)

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N;
	string s, t;

	cin >> N;
	cin >> s >> t;

	for (int i = 0; i < N; ++i) {
		cout << s[i] << t[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

 int main() {

	 int n;
	 int a;
	 int b;

	 std::cin >> n >> a >> b;

	 if ((b - a) % 2 == 0) {
		 std::cout << "Alice" << std::endl;
	 }
	 else {
		 std::cout << "Borys" << std::endl;
	 }

	 return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int N;
    long long int result=1;
	cin >> N;
    for(int i=1;i<=N;i++){
        result=result*i%(1000000007);
    }
	cout << result << "\n";
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
const ll MOD = 1e9 + 7;
/*/
const ll MOD = 998244353;
//*/
const ll INF = 1e+18;
const ld EPS = 1e-12L;
const ld PI = acos(-1.L);
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void pr(){
  cout << -1 << endl;
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;
  cin >> s;
  ll n = SZ(s);
  if(s[n-1] == '1') pr();
  if(s[0] == '0') pr();
  rep(i, n){
    ll j = n-i-2;
    if(s[i] != s[j]){
      pr();
    }
    if(i >= j) break;
  }
  vll lst;
  rep(i, n){
    if(s[i] == '1'){
      lst.emplace_back(i+1);
    }
  }
  lst.emplace_back(n);
  ll p = 0;
  rep(i, n-1){
    if(s[i] == '1'){
      p++;
    }
    print(i+1, lst[p]);
  }
}


Measured memory_bytes: 2372
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		Deque<Character> deq = new ArrayDeque<Character>();
		String s = sc.next();
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == '0') {
				deq.push('0');
			}else if (s.charAt(i) == '1') {
				deq.push('1');
			}else {
				deq.poll();
			}
		}
		while(!deq.isEmpty()) {
			System.out.print(deq.removeLast());
		}
		System.out.println();
		sc.close();
	}

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

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	mint mk(k);
	mint ans1(0);
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			if(a[i] > a[j]) ans1 += 1;
		}
	}
	ans1 *= mk;
	
	mint ans2(0);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(a[i] > a[j]) ans2 += 1;
		}
	}
	ans2 = ans2 * mk * (mk - 1) / 2;
	
	cout << ans1 + ans2 << endl;
	
	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 998244353;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Int dp[2][550][510];

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

    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 550; j++) {
            for (int k = 0; k <= X; k++) {
                int next_i = (i+1)&1;
                dp[next_i][j][k] = 0;
            }
        }

        for (int j = 0; j < 550; j++) {
            for (int k = 0; k <= X; k++) {
                int crt_i = i&1;
                int next_i = (i+1)&1;
                if (k != 0) {
                    dp[crt_i][j][k] += dp[crt_i][j][k-1];
                    dp[crt_i][j][k] %= MOD;
                }
                int next_xor = j ^ k;
                if (next_xor >= 550) continue;
                dp[next_i][next_xor][k] += dp[crt_i][j][k];
                dp[next_i][next_xor][k] %= MOD;
            }
        }
    }

    for (int j = 0; j < 550; j++) {
        for (int k = 1; k <= X; k++) {
            dp[N&1][j][k] += dp[N&1][j][k-1];
            dp[N&1][j][k] %= MOD;
        }
    }

    cout << dp[N&1][X][X] << endl;
}



Measured memory_bytes: 7492
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int y, x;
  int step;
};
int vy[4] = {-1,1,0,0};
int vx[4] = {0,0,-1,1};

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  int num_block = 0;
  rep(i,H){
    cin >> s[i];
    rep(j,W){
      if(s[i][j] == '#') num_block++;
    }
  }

  int min_step = -1;
  vector<vector<int>> visited(H,vector<int>(W,0));
  queue<ST> que;
  que.push((ST){0,0,1});
  while(!que.empty()){
    ST st = que.front(); que.pop();
    if(visited[st.y][st.x] == 1) continue;
    visited[st.y][st.x] = 1;
    if(st.y == H-1 && st.x == W-1){
      min_step = st.step;
      break;
    }

    rep(k,4){
      int ny = st.y + vy[k];
      int nx = st.x + vx[k];
      int nstep = st.step + 1;

      if(0<=ny && ny<H && 0<=nx && nx<W){
        if(s[ny][nx] == '.' && visited[ny][nx] == 0){
          que.push((ST){ny,nx,nstep});
        }
      }
    }
  }

  if(min_step == -1){
    cout << -1 << endl;
  }else{
    cout << (H * W) - num_block - min_step << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
H=list(map(int,input().split()))
c=0
C=[]

    

for i in range(n-1):
    if H[i]>=H[i+1]:
        c+=1
    else:
        C.append(c)
        c=0
    if i==n-2:
        C.append(c)
if len(H)!=1:        
    ans=max(C)
else:
    ans=0

print(ans)

Measured memory_bytes: 14252
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DPowerfulDiscountTickets {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        priority_queue<P> v;
        REP(i, N) {
            int a = 1;
            while (A[i] > (1LL << a)) a++;
            v.push({a, A[i]});
        }

        int cnt = 0;
        while (cnt < M) {
            auto kv = v.top();
            v.pop();
            if (kv.first == 0) break;
            v.push({kv.first - 1, kv.second / 2});
            cnt++;
        }

        int res = 0;
        while (!v.empty()) {
            auto kv = v.top();
            v.pop();
            res += kv.second;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DPowerfulDiscountTickets solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	int i, r = 0, t = 1;
	char s[81] = "", c;
	while (cin >> s)
	{
		for (i = strlen(s); i >= 0; i--)
		{
			c = s[i];
			if ('0' <= c && c <= '9')
			{
				r += atoi(&c) * t;
				t *= 10;
			}
			else
			{
				t = 1;
			}
		}
	}
	cout << r << endl;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
  int X[102],N,min=100,max=0;
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    scanf("%d",X+i);
    if(X[i]<min) min=X[i];
    if(max<X[i]) max=X[i];
  }
  int ans=100*100*100;
  for(int i=min;i<=max;i++){
    int S=0;
    for(int j=1;j<=N;j++){
      S+=(X[j]-i)*(X[j]-i);
    }
    if(S<ans) ans=S;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1728
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int x, a;
    cin >> x >> a;
    if(x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
} /*atcoder*/


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;

//139 C
int main(void) {
	ll n;
	cin >> n;
	vector<ll> h = vector<ll>(n);
	rep(i, 0, n)cin >> h[i];
	ll ans = 0;
	ll now = 0;
	rep(i, 1, n) {
		if (h[i - 1] >= h[i]) {
			now++;
		}
		else {
			ans = max(ans, now);
			now = 0;
		}
	}
	ans = max(ans, now);
	cout << ans << endl;
}


Measured memory_bytes: 1024
n, yen = map(int, input().split())
for x in range(n + 1):
    for y in range(n - x + 1):
        z = n - x - y
        if yen == x * 10000 + y * 5000 + z * 1000:
            print(x, y, z)
            exit(0)
print("-1 -1 -1")

Measured memory_bytes: 41196
from collections import deque
EMPTY = 0
BLACK = 1
WHITE = 2
N = input()
G = {i: [] for i in range(1, N+1)}
for i in range(N-1):
    a, b = map(int, raw_input().split())
    G[a].append(b)
    G[b].append(a)

parent = {}
dist = [N] * (N+1)
dist[1] = 0
que = deque([1])
while len(que) > 0:
    s = que.popleft()
    for t in G[s]:
        if dist[t] > dist[s]+1:
            dist[t] = dist[s]+1
            parent[t] = s
            que.append(t)

s = N
path = [s]
while s in parent:
    path.append(parent[s])
    s = parent[s]
path = path[::-1]

colors = [EMPTY] * (N+1)
n = len(path)
que_black, que_white = deque(), deque()
for i in range(n):
    if i % 2 == 0:
        v = path[i/2]
        colors[v] = BLACK
        que_black.append(v)
    else:
        v = path[n-i/2-1]
        colors[v] = WHITE
        que_white.append(v)

def paint(que, c):
    while len(que) > 0:
        s = que.popleft()
        for t in G[s]:
            if colors[t] == EMPTY:        
                colors[t] = c
                que.append(t)
paint(que_black, BLACK)
paint(que_white, WHITE)
score = 0
for c in colors:
    if c == BLACK:
        score += 1
    elif c == WHITE:
        score -= 1
print "Fennec" if score > 0 else "Snuke"


Measured memory_bytes: 42780
#include <stdio.h>

int main(void){

	int A,B,coin;
	
	scanf("%d",&A);
	scanf("%d",&B);
	
	coin=0;
	
	if(A>=B){
		coin+=A;
		A--;
	}else{
		coin+=B;
		B--;
	}
	
	if(A>=B){
		coin+=A;
		A--;
	}else{
		coin+=B;
		B--;
	}

	printf("%d",coin);

	return 0;
}

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

int main () {
    int N, V[30], C[30], sum;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    for (int i = 0; i < N; i++) {
        if (V[i]-C[i] > 0) sum += V[i]-C[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull            unsigned long long
#define ll             long long
#define pb             push_back
#define mp             make_pair
#define li(i,ini,r)    for(ull i=ini;i<r;i++)
#define ld(i,ini,r)    for(ull i=ini;i>=r;i--)
#define lit(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define l(v)           for(ull b:v)
#define sorta(v)       sort(v.begin(),v.end())
#define vf(i)          v[i].first
#define vs(i)          v[i].second
#define fast_io        ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define nl             cout<<"\n"
#define sp             cout<<" "
#define en             "\n"
#define sr(s)          reverse(s.begin(),s.end())



using namespace std;


int main()
{
    int k=0,n=0,mi=0,mx=0,x=0;

    cin>>k>>n;
    vector<int>v;

    li(i,0,n)
    {
        cin>>x;
        v.pb(x);
    }

    mx=INT_MIN;
    li(i,0,n-1)
    {
        if(mx<v[i+1]-v[i])
        {
            mx=v[i+1]-v[i];
        }

    }
    //cout<<mx<<en;
    int mm=k-v[n-1];
    mm=v[0]+mm;
    //cout<<mm<<en;
    if(mx<mm)
    {
        mx=mm;
    }
    //cout<<mx<<en;
    cout<<k-mx<<en;

    return 0;
}


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

#define ll long long int
#define pb push_back
#define f(i,x,y) for(i=x;i<y;i++)
#define vll vector<ll>
#define fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mod 1000000007

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
}

void addEdge(vll adj[], ll u, ll v) 
{ 
    adj[u].push_back(v); 
    adj[v].push_back(u); 
}
void DFSE(vll adj[],vector<bool> &visited,ll u)
{
    ll i;
    visited[u] = true;
    cout<<u<<" ";
    f(i,0,adj[u].size())
    {
        if(visited[adj[u][i]]==false)
        {
            DFSE(adj,visited,adj[u][i]);
        }
    }
    
}
void DFS(vll adj[],ll u,ll v)
{
    ll i;
    vector<bool> visited(v,false);
    f(i,0,v)
    {
        if(visited[i]==false)
        {
            DFSE(adj,visited,i);
        }
    }
}
bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 

int main()
{
    fast;
    ll n,i,a;
    cin>>n;
    vll v,s(n,0);
    
    f(i,0,n)
    {
        cin>>a;
        v.pb(a);
    }
    
    s[n-1]=v[n-1];
    
    for(i=n-2;i>=0;i--)
    {
        s[i]=(s[i+1]+v[i])%mod;
    }
    ll ans=0;
    
    f(i,0,n-1)
    {
        ans=(ans+(v[i]*s[i+1])%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6880
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=1000005, INF=1e18;
lld pi=3.1415926535897932;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vi prime;
bool isprime[N];
void pre()
{
    for(int i=2;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<N;j+=i)
            isprime[j]=false;
        }
        prime.pb(i);
    }
    return;
}
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
    sort(a, a+n);
    sort(b, b+n);
    int l=0,r=0;
    if(n&1)
    {
        l=a[n/2];
        r=b[n/2];
    }
    else
    {
        l=a[n/2]+a[(n/2)-1];
        r=b[n/2]+b[(n/2)-1];
    }
    cout<<r-l+1;
}

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

int main(void) {
	int n, x;
	cin >> n >> x;
	int ans = 1;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int l;
		cin >> l;
		sum += l;
		if (sum > x) break;
		ans++; 

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


Measured memory_bytes: 256
n, m = map(int,input().split())
graph = {}
for i in range(0, m):
    am, bm = map(int, input().split())
    if am not in graph:
        graph[am] = [bm]
    else:
        graph[am].append(bm)
    if bm not in graph:
        graph[bm] = [am]
    else:
        graph[bm].append(am)
signs = {1:0}
current = [1]
i = 0
while True:
    flag = 0
    for j in graph[current[i]]:
        if j not in signs:
            signs[j] = current[i]
            current.append(j)
            flag = 1
    i+=1
    if flag == 0 and i == len(current):
        break
    
if i == n:
    print("Yes")
    for x in range(2, n+1):
        print(signs[x])
else:
    print("No")


Measured memory_bytes: 48980
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, h[100010], d[100010];

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++)scanf("%d", h + i);
	for(int i=2;i<=N;i++) {
		d[i] = d[i-1] + abs(h[i] - h[i-1]);
		if(i > 2) d[i] = min(d[i], d[i-2] + abs(h[i] - h[i-2]));
	}
	printf("%d\n", d[N]);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

#define NIL NULL

typedef struct heap{
  int k;
  int pk;
  int lk;
  int rk;
}Heap;

int main(){
  Heap A[250];
  int i,H,p,r,l;
  
  scanf("%d",&H);

  for(i=1;i<=H;i++){
    scanf("%d",&A[i].k);
  }

  for(i=1;i<=H;i++){
    p=i/2;
    l=2*i;
    r=2*i+1;
    
    if(p!=0)
      A[i].pk=A[p].k;
    else
      A[i].pk=NIL;
    

    if(r<=H)
      A[i].rk=A[r].k;
    else
      A[i].rk=NIL;

    
    if(l<=H)
      A[i].lk=A[l].k;
    else
      A[i].lk=NIL;
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i].k);
    if(A[i].pk!=NIL)
      printf("parent key = %d, ",A[i].pk);
    if(A[i].lk!=NIL)
      printf("left key = %d, ",A[i].lk);
    if(A[i].rk!=NIL)
      printf("right key = %d, ",A[i].rk);
    
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2112