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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 0;
    rep(i, n) {
        cin >> a[i];
        if(i > 0 && a[i] < a[i - 1]) {
            ans += a[i - 1] - a[i];
            a[i] += a[i - 1] - a[i];
            // debug(a[i - 1] - a[i], ans);
        }
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, 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;
}


Measured memory_bytes: 4048
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on July 27, 2018, 12:04 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 5000001

/*
 * 
 */

int H, Heap[MAX];

void maxHeapify(int i);
void buildHeap();

int main(int argc, char** argv) {
    scanf("%d", &H);
    for (int i = 1; i <= H; ++i) scanf("%d", &Heap[i]);
    buildHeap();
    for (int i = 1; i <= H; ++i) printf(" %d", Heap[i]);
    printf("\n");
    return (EXIT_SUCCESS);
}

void maxHeapify(int i)
{
    int left, right, max, temp;
    left = i*2;
    right = i*2+1;
    
    if (left <= H && Heap[left] > Heap[i]) max = left;
    else max = i;
    if (right <= H && Heap[right] > Heap[max]) max = right;
    
    if (max != i)
    {
        temp = Heap[i];
        Heap[i] = Heap[max];
        Heap[max] = temp;
        maxHeapify(max);
    }
}

void buildHeap()
{
    for (int i = H/2; i >= 1; --i) maxHeapify(i);
}







Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif


int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;

//.....................
const int MAX = (int)2e5 + 5;

int k, s;

void solve() {
	cin >> k >> s;
	int cnt = 0;
	rep(x, k + 1) rep(y, k + 1) {
		int z = s - x - y;
		if (0 <= z && z <= k) cnt++;
	}
	cout << cnt << endl;
}

signed main() {
	int T = 10;
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())#N人K種類
ls=[False for _ in range(N)]
for i in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for j in range(d):
    ls[A[j]-1]=True
S=0
for i in range(N):
  if ls[i]==False:
    S+=1
print(S)

Measured memory_bytes: 9192
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	int aa = b + c;
	int r = max(0, aa - a);
	cout << r << endl;
	return 0;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CBoxesAndCandies solver = new CBoxesAndCandies();
        solver.solve(1, in, out);
        out.close();
    }

    static class CBoxesAndCandies {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long x = in.nextInt();

            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = in.nextInt();

            long answer = 0;
            for (int i = 1; i < n; i++) {
                long tot = a[i] + a[i - 1] - x;
                if (tot > 0) {
                    answer += tot;
                    if (tot <= a[i]) {
                        a[i] -= tot;
                    } else {
                        a[i] = 0;
                    }
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 39540
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    if(A > B) { cout << 0 << endl; return 0; }
    if(N==1) {
        if(A!=B) cout << 0 << endl;
        else cout << 1 << endl;
        return 0;
    }

    // ll mn = A + B + (N-2)*A;
    // ll mx = A + B + (N-2)*B;
    // ll res = mx - mn + 1 = (N-2)*(B-A)+1
    cout << (N-2LL)*(B-A)+1LL << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
int main()
{
	double n;
    scanf("%lf",&n);
    printf("%.0lf\n",pow(floor(sqrt(n)),2.0));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    rep(i,N) cin >> A[i] >> B[i];
    sort(ALL(A)); sort(ALL(B));
    if(N % 2 == 1) {
        int mn = A[(N+1)/2 - 1];
        int mx = B[(N+1)/2 - 1];
        cout << (mx - mn) + 1 << endl;
    } else {
        int mn2 =  A[N/2 - 1] + A[N/2];
        int mx2 = B[N/2 - 1] + B[N/2];
        cout << mx2 - mn2 + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define Isvalid(nx,mx,n,m) nx>0&&nx<=n&&mx>0&&mx<=m
#define mem(a,b)      memset(a, b, sizeof (a))
#define pb            push_back
#define sz            size()
#define kohli         0
#define ll            long long
#define si(x)         scanf("%lld",&x)
#define vsort(v)      sort(v.begin(),v.end())
#define nl            printf("\n")
#define pi(x)         printf("%d",x)
#define ps(ch)        printf("%s",ch)
#define pll(x)        printf("%lld",x)
#define sp            printf(" ")
#define Pi            acos(-1)
#define chkbit(n, j) (((n & (1 << (j))) > 0) ? 1 : 0)
static const ll mod = 1e9 + 7;
static const ll mmx = 1e5 + 5;

/// for interactive problem use      fflush(stdout);
/// or                               cout.flush();

//int dx[] = {0, -1, -1, -1, 0, +1, +1, +1};
//int dy[] = {+1, +1, 0, -1, -1, -1, 0, +1};
//int dx[] = {-5, -4, -4, -3, -3, 0, 0, 3, 3, 4, 4, 5};
//int dy[] = {0, -3, 3, -4, 4, -5, 5, -4, 4, -3, 3, 0};
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};

int ara[100010];
bool chk[100010],yo[100010];

int main()
{
    //bitwise();
    //sieve();
    //vokam();
    //totient();
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a,b;
    while(scanf("%d %d",&a,&b)==2)
    {
        int w = max((a+b),max((a-b),(a*b)));
        printf("%d\n",w);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll num[105];

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

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++){
			cin>>num[i];
		}
		ll ans=num[0];
		for(int i=1;i<n;i++){
			ll temp=gcd(ans,num[i]);
			ans=(ans/temp)*num[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
      while(true){
        int n = sc.nextInt();
        if(n==0) break;
        int max=0,min=1000;
        int[] score = new int[n];

        int avg = 0;
        for(int i=0;i<n;i++){
          score[i] = sc.nextInt();
          if(score[i]>max) max=score[i];
          if(score[i]<min) min=score[i];
          avg += score[i];
        }
        avg = avg - (max + min);
        avg /= (n - 2);
        System.out.println(avg);
      }
    }
  }
}



Measured memory_bytes: 28760
#include <cstdio>

using namespace std;

int main()
{
    int n,c;
    scanf( "%d %d\n", &n, &c );
    int p[100] = {0};
    int num = 0;
    for( int i = 0; i < c; i++  )
    {
        scanf( "%d ", &p[i] );
        num += p[i];
    }
    n++;
    int ret = num / n;
    num %= n;
    if( num > 0 )
    {
        ret++;
    }
    printf( "%d\n", ret );
    return 0;
}


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

// @@ !! LIM(f:gcd)
// --> f:gcd
// ---- inserted function gcd from util.cc
// g = eGCD(a, b, s, t)  --->  sa + tb = g
ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

// gcd(0, x) = x, gcd(-x, y) = gcd(x, y)
ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(abs(a), abs(b), dummy1, dummy2);
}
// ---- end gcd
// @@ !! LIM  -- end mark --

ll mod(ll x, ll y) {
  assert(y > 0);
  if (x >= 0) return x % y;
  else return y - ((-x) % y);
}

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  auto solve = [&](ll a, ll b, ll c, ll d) -> bool {
    if (a < b) return false;
    if (d < b) return false;
    if (b - 1 <= c) return true;
    ll g = gcd(b, d);
    if (b - c - 1 >= g) return false;
    ll x = mod(c + 1 - a, g);
    ll y = mod(b - 1 - a, g);
    if (0 < x && x <= y) return true;
    return false;
  };

  ll T; cin >> T;
  for (ll _t = 0; _t < T; _t++) {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << (solve(a, b, c, d) ? "Yes" : "No") << "\n";
  }

  return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 

int t[1000000];vector<VI>adj;VI ans(1000000,0);VI colour(1000000,0);int n;
void update(int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && r == tr) {
        t[v] += add;
    } else {
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), add);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, add);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return t[v] + get(v*2, tl, tm, pos);
    else
        return t[v] + get(v*2+1, tm+1, tr, pos);
}
void dfs(int v,int par)
{   int px=get(1,1,n,colour[v]);update(1,1,n,colour[v],colour[v],-px);
    for(auto it:adj[v])
    {
        if(it!=par)
        {
            dfs(it,v);
            int x=get(1,1,n,colour[v]);
            if(x>0)
            ans[colour[v]]+=(x*(x+1))/2;
            update(1,1,n,colour[v],colour[v],-x);
        }
    }
    update(1,1,n,1,colour[v]-1,1);update(1,1,n,colour[v]+1,n,1);
    int x=get(1,1,n,colour[v]);
    update(1,1,n,colour[v],colour[v],-x);
    update(1,1,n,colour[v],colour[v],px);
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    
    cin>>n;adj.resize(n+1);
    for(int i=1;i<=n;i++)cin>>colour[i];
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++)
    {
    	int x=get(1,1,n,i);
    	if(x>0)
    	ans[i]+=(x*(x+1))/2;
    }
    for(int i=1;i<=n;i++)cout<<(n*(n+1))/2-ans[i]<<endl;
}


return 0;
}





Measured memory_bytes: 49436
package main

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

func main() {
	var (
		n, q int
		s    string
	)
	fmt.Scan(&n, &q, &s)

	xs := make([]int, n)
	sum := 0
	for i := range s[:len(xs)-1] {
		if s[i] == 'A' && s[i+1] == 'C' {
			sum++
		}
		xs[i+1] = sum
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var l, r int
	for i := 0; i < q; i++ {
		sc.Scan()
		l, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ = strconv.Atoi(sc.Text())
		fmt.Println(xs[r-1] - xs[l-1])
	}
}


Measured memory_bytes: 5120
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

//Sort
public class Main{

	int N, ID, INF = 1<<29;
	Map<Integer, Integer> ref;
	boolean[] u;
	
	void dfs(int k, int x){
		if(k==N){
			ref.put(x, ID++); return;
		}
		for(int i=1;i<=N;i++){
			if(!u[i]){
				u[i] = true;
				dfs(k+1, x*10+i);
				u[i] = false;
			}
		}
	}
	
	int[] d;
	void run(){
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		u = new boolean[N+1];
		ref = new HashMap<Integer, Integer>();
		ID = 0;
		dfs(0, 0);
		int[][] c = new int[N][N];
		for(int i=0;i<N;i++)for(int j=0;j<N;j++)c[i][j]=sc.nextInt();
		d = new int[ID];
		Arrays.fill(d, INF);
		int s = 0;
		for(int i=1;i<=N;i++)s=s*10+i;
		d[ref.get(s)] = 0;
		PriorityQueue<Integer> q = new PriorityQueue<Integer>(N, new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return d[ref.get(o1)]-d[ref.get(o2)];
			}
		});
		q.add(s);
		int[] a = new int[N];
		while(!q.isEmpty()){
			int V = q.poll(), v = V;
			for(int i=N-1;i>=0;i--){
				a[i] = v%10; v/=10;
			}
			for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
				int t = a[i];
				a[i] = a[j]; a[j] = t;
				int nv = 0, w = d[ref.get(V)]+c[i][j];
				for(int k=0;k<N;k++)nv=nv*10+a[k];
				if(w<d[ref.get(nv)]){
					d[ref.get(nv)] = w; q.add(nv);
				}
				a[j] = a[i]; a[i] = t;
			}
		}
		int res = 0;
		for(int v:ref.keySet())res = Math.max(res, d[ref.get(v)]);
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000
N = int(input())
T = [[] for _ in range(N)]


def dfs(k):
    q = [k]
    d = [-1] * N
    d[k] = 0
    while len(q) > 0:
        v = q.pop()
        for i in T[v]:
            if d[i] == -1:
                d[i] = d[v] + 1
                q.append(i)
    return d


def main():
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        T[a].append(b)
        T[b].append(a)
    c = dfs(0)
    d = dfs(N - 1)
    ac = 0
    for x, y in zip(c, d):
        if y >= x:
            ac += 1
    if ac > N // 2:
        print('Fennec')
    else:
        print('Snuke')


main()


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

map<long long, int> prime_factor(long long n)
{
    map<long long, int> ret;
    for (long long i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

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

    map<ll, int> pf = prime_factor(p);

    ll answer = 1l;
    for (auto i = pf.begin(); i != pf.end(); i++)
    {
        if ((i->second) >= n)
        {
            for (ll j = 0; j < i->second / n; j++)
            {
                answer *= (i->first);
            }
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,k,l,p,dp[55][2555][55],mod=1e9+7,ans,fac[55];
int main()
{
	scanf("%d%d",&n,&m);
	if(m&1){
		puts("0");
		return 0;
	}
	fac[0]=1;
	fz1(i,n){
		fac[i]=1ll*fac[i-1]*i%mod;
	}
	m/=2;
	dp[0][0][0]=1;
	fz0k(i,n){
		fz0g(j,m){
			fz0g(k,i){
				inc(dp[i+1][j+k][k],1ll*dp[i][j][k]*(2*k+1)%mod);
				inc(dp[i+1][j+k][k+1],dp[i][j][k]);
				if(k)inc(dp[i+1][j+k][k-1],1ll*dp[i][j][k]*k*k%mod);
			}
		}
	}
	cout<<dp[n][m][0]<<endl;
	return 0;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] a = na(n);
		int tmp = 1;
		int result = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] == tmp) {
				tmp++;
			} else {
				result++;
			}
		}		
		System.out.println(tmp == 1 ? -1 : result);
	}

	//Find greatest common divisor
	static long gcd (long a, long b) {
		return b > 0 ? gcd(b, a%b) : a;
	}
	//Find least common multiple
	static long lcm (long a, long b) {
		return a * b / gcd(a, b);
	}
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 57520
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

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

    li n, capacity;
    cin >> n >> capacity;

    vector<li> weights(n), values(n);

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

    vector<li> dp(capacity + 1, 0);

    for (int item = 0; item < n; ++item) {
        for (int new_weights = capacity; new_weights >= 0; --new_weights) {
            li prev_weights = new_weights - weights[item];
            if (prev_weights < 0) {
                continue;
            }
            dp[new_weights] = max(dp[prev_weights] + values[item], dp[new_weights]);
        }
    }

    cout << dp[capacity] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int r[100005],l[100005],a[100005];
bool su(int x){
	if(x==2)
		return true;
	if(x==1||x%2==0)
		return false;
	int n=sqrt(x);
	for(int i=3;i<=n;i+=2)
		if(x%i==0)
			return false;
	return true;
}
int main(){
	int n,minv=9999999,maxv=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&l[i],&r[i]);
		minv=min(l[i],minv);
		maxv=max(maxv,r[i]);
	}
	for(int i=minv;i<=maxv;i+=2){
		a[i]=a[i-2];
		if(su(i)&&su((i+1)/2))
			a[i]++;
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",a[r[i]]-a[l[i]-2]);
	return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;

    REP2(i, -200, 200) REP2(j, -200, 200) {
        if (pow((ll)i, 5LL) - pow((ll)j, 5LL) == n) {
            printf("%d %d\n", i, j);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 4140
S = input()

a = 'dreamer'
b = 'eraser'
c = 'dream'
d = 'erase'
key = [a,b,c,d]

st = S[::]

while len(st):
    for i in range(4):
        tmp = st[-len(key[i]):]
        if tmp == key[i]:
            st = st[:-len(key[i])]
            if not len(st):
                print('YES')
                exit(0)
            break
        if i == 3:
            print('NO')
            exit(0)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	//a,b,c,k
	if(k&1){
		cout<<b-a<<endl;	
	}else{
		cout<<a-b<<endl;
	}
	return 0;
}


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

#define INF 1e+9
#define MAX_V 100000

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];
vector<int> previous(MAX_V,-1);

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<(int)G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
                previous[e.to] = v;
            }
        }
    }
}

int main() {
    cin >> V;
    int E;
    cin >> E;
  
    previous.resize(V);
    
    for (int i=0; i<E; ++i) {
        int a, b;
        cin >> a >> b; a--; b--;
        edge e = {b, 1};
        edge f = {a, 1};
        G[a].push_back(e);
        G[b].push_back(f);
    }
    dijkstra(0);
    cout << "Yes" << endl;
    for (int i=1; i<V; ++i) {
      cout << previous[i]+1 << endl;
    }
}

Measured memory_bytes: 13540
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
char a[101000];
int k,n;
int main() {
	scanf("%s%d",a,&k);
	n=strlen(a);
	rep(i,0,n) {
		if (a[i]=='a') continue;
		int w='z'-a[i]+1;
		if (k>=w) {
			k-=w;
			a[i]='a';
		}
	}
	k%=26;
	a[n-1]=(a[n-1]-'a'+k)%26+'a';
	puts(a);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll dp[3010][3010][6];
ll v[3010][3010];

int main() {
  ll r, c, k;
  cin >> r >> c >> k;
  rep(i, k) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    v[a][b] = c;
  }
  rep(i, r + 1) rep(j, c + 1) rep(m, 4) {
    // printf("dp[%d][%d][%d]=%d\n", i, j, m, dp[i][j][m]);
    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][m]);
    dp[i][j + 1][m] = max(dp[i][j + 1][m], dp[i][j][m]);
    if(m < 3) {
      dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][m] + v[i][j]);
      dp[i][j + 1][m + 1] = max(dp[i][j + 1][m + 1], dp[i][j][m] + v[i][j]);
    }
  }
  ll ans = 0;
  rep(m, 4) ans = max(ans, dp[r][c][m]);
  cout << ans << endl;
  // cout << 0 << endl;
}

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

using namespace std;

int main()
{
    int a,b,c,d;

    cin >> a >> b;
    cin >> c >> d;

    if((a+b) > (c+d))
        cout << "Left";
    else if((a+b) == (c+d))
        cout << "Balanced";
    else
        cout << "Right";
    return 0;
}


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

long long x,y,k;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>k;
    for (long long i=-200ll;i<=200ll;i++){
        x=i*i*i*i*i;
        for (long long j=-200ll;j<=200ll;j++){
            y=j*j*j*j*j;
            if (x-y==k){
                cout<<i<<' '<<j<<'\n';
                return 0;
            }
        }
    }
}


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

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count = 1;
    char prev = S[0];
    for(int i = 1; i < N; i++)
    {
        if(prev != S[i]){
            count++;
        }
        prev = S[i];
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
a_num = int(input())
b_num = int(input())
c_num = int(input())
x = int(input())

total = []

for a in range(0, a_num+1):
  for b in range(0, b_num+1):
    for c in range(0, c_num+1):
      total.append(a*500+b*100+c*50)

print(total.count(x))

Measured memory_bytes: 8276
#include<stdio.h>



int main(){
    int height[10];
    int i;
    for(i=0;i<10;i++){
        scanf("%d",&height[i]);
    }
    
    int j, tmp;
    for(i=0;i<9;i++){
        for(j=i+1;j<10;j++){
            if(height[i] < height[j]){
                tmp=height[i];
                height[i]=height[j];
                height[j]=tmp;
            }
        }
    }
    
    for(i=0;i<3;i++){
        printf("%d\n",height[i]);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
int main(){
    ll n,k;cin >> n >> k;
    vl v(n);rep(i,n)cin >> v[i];
    while(k--){
        vl cum(n,0);
        rep(i,n){
            if(i-v[i]<0)cum[0]++;
            else cum[i-v[i]]++;
            if(i+v[i]+1>=n)continue;
            else cum[i+v[i]+1]--;
        }
        rep(i,n-1)cum[i+1]+=cum[i];
        v=cum;
        bool check=true;
        rep(i,n)if(v[i]!=n)check=false;
        if(check)break;
    }
    for(auto p:v)cout << p <<" ";
    cout << endl;
}   


Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	std::vector<ll> d(N);
	int sum = 0;

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

	for (int i = 0; i < N-1; i++){
		for (int j = i+1; j < N; j++)
		{
			sum += d[i]*d[j];
			//cout << sum << endl;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		System.out.println(a == b ? b == c ? "Yes" : "No" : "No");
		sc.close();
	}
}


Measured memory_bytes: 23380
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
CD = [list(map(int,input().split())) for _ in range(M)]
def dist(AB, CD):
  return abs(AB[0]-CD[0]) + abs(AB[1]-CD[1])

for i in range(N):
  d = 10**18; ans = -1;
  for j in range(M):
    tmp = dist(AB[i], CD[j])
    if tmp < d:
      d = tmp; ans = j+1;
  print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int health1,strength1,health2,strength2;
    cin >> health1 >> strength1 >> health2 >> strength2;
    int x = (health1+strength2-1)/strength2;
    int y = (health2+strength1-1)/strength1;
    if (x>=y){
        cout << "Yes";
        
    }else {
        cout << "No";
    }

}

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

using namespace std;

bool IsHeisei(int m, int d) {
  if (m < 4)
    return true;
  if (m == 4 && d <= 30)
    return true;

  return false;
}

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

  string s;
  cin >> s;
  const int m = atoi(s.substr(5, 2).data());
  const int d = atoi(s.substr(8, 2).data());

  if (IsHeisei(m, d))
    cout << "Heisei\n";
  else
    cout << "TBD\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
const long long MOD = 1e9+7;
const string AC = "AC";
int main(){  
    int n,m;
    cin >> n >> m;
    int p;
    string s;
    int pen[n];
    fill_n(pen,n,0);
    bool now[n];
    fill_n(now,n,false);
    int sol = 0;
    int pn = 0;
    rep(i,m){
        cin >> p >> s;
        p--;
        if(s==AC){
            if(!now[p]){
                pn+=pen[p];
                sol++;
                now[p]=true;
            }
        }
        else{
            pen[p]++;
        }
    }
    cout << sol << " " << pn << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	ll K, A[100100];
	cin >> N >> K;
	for (int i = 0; i < N; ++i)cin >> A[i];
	vector<int>k_count(41, 0);
	vector<int>A_count(41, 0);
	for (int i = 0; i < N; ++i) {
		ll key = A[i];
		int j = 0;
		while (key != 0) {
			if (key % 2 == 1) {
				A_count[j]++;
			}
			j++;
			key /= 2;
		}
	}
	ll key = K+1;
	int j = 0;
	while (key != 0) {
		if (key % 2 == 1) {
			k_count[j]++;
		}
		j++;
		key /= 2;
	}
	ll ans = 0;
	for (int i = 40; i >= 0; --i) {
		vector<ll>X(41, 0);
		if (k_count[i] == 0)continue;
		for (int j = 40; j >= i + 1; --j) {
			X[j] = k_count[j];
		}
		X[i] = 0;
		for (int j = i - 1; j >= 0; --j) {
			if (A_count[j] >= (N + 1) / 2) {
				continue;
			}
			else {
				X[j] = 1;
			}
		}
		ll key = 0;
		for (int j = 0; j < 41; ++j) {
			if (X[j] > 0) {
				key += pow(2, j);
			}
		}
		ll key2 = 0;
		for (int j = 0; j < N; ++j) {
			key2 += key ^ A[j];
		}
		ans = max(ans, key2);
	}
	cout << ans << endl;
	return 0;
}



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

main() {
    int N,M; cin >> N >> M; int K[M],S[M][N];
    bool can = true;    
    rep(j,M){
        cin >> K[j];
        rep(k,K[j]){
              cin >> S[j][k];
        }
    }
    int P[M]; rep(i,M) cin >> P[i];
    int ans=0;
    for(int i=0;i<(1<<N);i++){
        bool can = true;
        rep(j,M){
            int pos=0;
            rep(k,K[j]){
                if((i>>(S[j][k]-1)) & 1) pos++;
            }
            if(pos%2!=P[j]) can = false;
        }
        if(can) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

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

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

    double a = (n / 2) + (n % 2);
    double p = a / n;
    cout << fixed << setprecision(15) << p << endl;

	return 0;
}

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

int main(void){
	int r, g, b;
	cin >> r >> g >> b;
	int product =  10 * g + b;
    if(product % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("Failed to read line");
    let input: u32 = input.trim().parse()
        .expect("Failed to parse");

    let hour: u32 = input / (60 * 60);
    let minute: u32 = (input % (60 * 60)) / 60;
    let second: u32 = (input % (60 * 60)) % 60;
        
    println!("{}:{}:{}", hour, minute, second);
}



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




int main() {

  int n;
  cin>>n;

  int64_t out;
  cin>>out;
  for(int i=0;i<n-1;i++){
    int64_t wk;
    cin>>wk;

    out = gcd(out,wk);
  }

  cout<<out<<endl;

  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());

    int Alice = 0;
    int Bob = 0;
    for(int i = 0;i < N; i++){
        if(i % 2 == 0) Alice += a.at(i);
        else Bob += a.at(i);
    }

    cout << Alice - Bob << endl;
}

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

string s;
long long ans = 0;
bool fp[26];

struct trie
{
	trie *nt[26], *pr;
	int sp[26], rc;
	bool f;

	trie()
	{
		pr = nullptr;
		for (int i = 0; i < 26; i++) {
			nt[i] = nullptr;
			sp[i] = 0;
		}
		f = false;
		rc = 0;
	}
	
	void insert(int p)
	{
		if (p >= s.length()) {
			f = true;
			fp[rc] = true;
			return;
		}
		int tc = s[p] - 'a';
		if (!nt[tc])
			nt[tc] = new trie;
		nt[tc]->pr = this;
		nt[tc]->rc = tc;
		nt[tc]->insert(p + 1);
		for (int i = 0; i < 26; i++)
			if (fp[i])
				sp[i]++;
		fp[rc] = true;
	}

	void ps()
	{
		if (f)
			ans += pr->sp[rc];
		for (int i = 0; i < 26; i++) {
			if (!nt[i]) continue;
			nt[i]->ps();
		}
	}
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	trie *rt = new trie;
	for (int i = 0; i < n; i++) {
		cin >> s;
		reverse(s.begin(), s.end());
		rt->insert(0);
		for (int j = 0; j < 26; j++)
			fp[j] = false;
	}
	rt->ps();
	cout << ans - n << '\n';
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

class cake {
public:
  i64 sum;
  i32 a, b, c;
  bool operator<(const cake &that) const {
    if (sum != that.sum) return sum < that.sum;
    if (a != that.a) return a < that.a;
    if (b != that.b) return b < that.b;
    return c < that.c;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i32 x, y, z, k;
  cin >> x >> y >> z >> k;
  vi64 a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  sort(all(a), greater<i64>());
  sort(all(b), greater<i64>());
  sort(all(c), greater<i64>());
  priority_queue<cake> que;
  set<cake> s;
  que.push({a[0] + b[0] + c[0], 0, 0, 0});
  rep(_, k) {
    auto q = que.top();
    que.pop();
    cout << q.sum << endl;
    if (q.a < x - 1) {
      cake d = {a[q.a + 1] + b[q.b] + c[q.c], q.a + 1, q.b, q.c};
      if (s.find(d) == s.end()) { que.push(d); s.insert(d); }
    }
    if (q.b < y - 1) {
      cake d = {a[q.a] + b[q.b + 1] + c[q.c], q.a, q.b + 1, q.c};
      if (s.find(d) == s.end()) { que.push(d); s.insert(d); }
    }
    if (q.c < z - 1) {
      cake d = {a[q.a] + b[q.b] + c[q.c + 1], q.a, q.b, q.c + 1};
      if (s.find(d) == s.end()) { que.push(d); s.insert(d); }
    }
  }
  return 0;
}


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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define ll long long
#define ld long double
 
template <class T> struct Dijkstra {
 
  struct Edge{
    int to;
    T cost;
    Edge(int _to, T _cost) : to(_to), cost(_cost) {}
  };
    
  const T INF = numeric_limits<T>::max() / 2;
  vector< vector< Edge > > G;
  vector< T > d;
  Dijkstra (int n) : G(n), d(n) {}
 
  void add_directed_edge(int a, int b, T c) {
    G[a].push_back(Edge(b,c));
  }
    
  void add_undirected_edge(int a, int b, T c) {
    G[a].push_back(Edge(b,c));
    G[b].push_back(Edge(a,c));
  }
 
  void init(int s) {
    priority_queue< pair<T,int>,vector< pair<T,int> >, greater< pair<T,int> > > que;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    que.push(make_pair(0,s));
    while (!que.empty()){
      pair<T,int> p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first) continue;
      for (int i = 0; i < G[v].size(); i++) {
	Edge e = G[v][i];
	if (d[e.to] > d[v] + e.cost) {
	  d[e.to] = d[v] + e.cost;
	  que.push(make_pair(d[e.to],e.to));
	}
      }
    }
  }
    
  T dist(int a) {
    return d[a];
  }
    
}; 
 
ld distan(ld x1, ld y1, ld x2, ld y2){
  ld x = x1-x2;
  ld y = y1-y2;
  return sqrt(x*x+y*y);
}
 
map<pair<ll,ll>, ll>v;
ll xs,ys,xt,yt;
ll N;
 
int main(){  
 
  cin >> xs >> ys >> xt >> yt;
  cin >> N;
  
  vector<ll> x(N+10),y(N+10),r(N+10);
  x[0]=xs,y[0]=ys,x[N+1]=xt,y[N+1]=yt;
  r[0]=0, r[N+1]=0;
  for(ll i = 1;i<=N;i++){
    cin >> x[i] >> y[i] >> r[i];
  }
  for(ll i =0;i<N+2;i++){
    v[make_pair(x[i],y[i])]=i;
  }
  
  Dijkstra<ld> Root(N+2);
  for(ll i = 0;i < N+2;i++){
    for(ll j = 0;j < N+2;j++){
      if(i==j)continue;
      ll v1 = v[make_pair(x[i],y[i])];
      ll v2 = v[make_pair(x[j],y[j])];
      ld cost = distan(x[i],y[i], x[j],y[j]);
      Root.add_undirected_edge(v1,v2,max((ld)0, (cost-(ld)r[i]-(ld)r[j])));
    }
  }
 
  Root.init(0);
  cout << fixed << setprecision(10) << Root.dist(N+1) << endl;
  return 0;
}


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

using namespace std;

const int MX = 100 * 1000 + 7;

vector<int> g[MX];

int dfs(int v, int p = -1) {
    int xr = 0;
    for (int to : g[v]) {
        if (to != p) {
            xr ^= (dfs(to, v) + 1);
        }
    }
    return xr;
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    if (dfs(1)) {
        cout << "Alice\n";
    } else {
        cout << "Bob\n";
    }
}




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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long r) {
  cout << r * r << endl;
}

int main() {
  long long r;
  scanf("%lld", &r);
  solve(r);
  return 0;
}


Measured memory_bytes: 256