akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        v: [[(usize1, usize)]]
    }
    let n = v.len();
    let mut ans = 0;
    'next: for i in 1..1 << n {
        let mut tab = vec![2; n];
        let mut c = 0;
        for j in 0..n {
            if i & 1 << j > 0 {
                c += 1;
                if tab[j] == 0 {
                    continue 'next;
                }
                tab[j] = 1;
                for &(x, y) in &v[j] {
                    if tab[x] == 2 {
                        tab[x] = y;
                    } else if tab[x] != y {
                        continue 'next;
                    }
                    if y == 1 && i & 1 << x == 0 {
                        continue 'next;
                    }
                }
            }
        }
        ans = max(ans, c);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
using namespace std;

char c;

void solve()
{
	cin>>c;
	if(c-'a'>=0 && c-'a'<=25) cout<<"a"<<endl;
	else cout<<"A"<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 18:20:35 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))

dp = [True for i in range(K + A[-1] + 1)]
for i in range(K):
    if dp[i]:
        for a in A:
            dp[i + a] = False

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

if dp[K]:
    ans = 'Second'
else:
    ans = 'First'
print(ans)

Measured memory_bytes: 14308
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcountll((x))
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
using namespace std;

const int maxN = 2420;

int main()
{
	int n[3];
	FOR(i, 0, 3)
		scanf ("%d", n+i);

	printf("%s\n", (n[0] == n[1] and n[1] == n[2] ? "Yes" : "No"));
	return 0;
}	


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int X , K , r[N];
int Q , t , a;

int main(){
    cin >> X >> K;
    rep(i,1,K+1) cin >> r[i];
    cin >> Q;
    int a = 0 , b = X , c = 0;
    int cur = 0;
    rep(i,0,Q) {
        int t , W;
        cin >> t >> W;
        while(cur < K && r[cur + 1] <= t) {
            int duration = r[cur + 1] - r[cur];
            if(cur & 1) {
                if(a + c + duration >= X) a = b = X , c = 0;
                else if(b + c + duration < X) c += duration;
                else b = X - duration - c , c = X - b;
            } else {
                if(b + c - duration <= 0) a = b = X , c = -X;
                else if(a + c - duration > 0) c -= duration;
                else a = duration - c , c = -a;
            }
            ++cur;
        }
        int fx = 0;
        if(W <= a) fx = a + c;
        else if(a < W && W < b) fx = W + c;
        else fx = b + c;
        if(cur & 1) printf("%d\n",min(X , fx + t - r[cur]));
        else printf("%d\n",max(0 , fx - t + r[cur]));
    }
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main()
{
    int r,c;
    cin >> r >> c;
    char arr[r][c];
    char aaa[r][c];
    char bbb[r][c];
    for (int i =0;i<r;i++){
        for (int j =0;j<c;j++){
            cin>>arr[i][j];
        }
    }
    for (int i=0;i<r;i++){
        for (int j=0;j<c;j++){
            aaa[i][j]=arr[i][j];
            bbb[i][j]=arr[i][j];
        }
    }
    for (int i =0;i<r;i++){
        for (int j=0;j<c;j++){
            cout<<aaa[i][j];
        }
        cout<<endl;
         for (int j=0;j<c;j++){
            cout<<bbb[i][j];
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
using namespace std;

void setIO() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
}

int n,k;
set<int> s;
int main()
{   
    setIO();
    cin >> n >> k;
    for(int i = 0,d; i < k; i++)
    {
        cin >> d;
        for(int j = 0,a; j < d; j++)
            cin >> a, s.insert(a);
    }
    cout << (n - s.size()) << endl;
    return 0;
}


Measured memory_bytes: 3652
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
struct node{int u,d,c;}E[N];
int d[N],c[N],q[N],n,m,Q;
void solve(int S,int dis,int col){
	int h=1,t=0,u;
	q[++t]=S;
	while(h<=t){
		u=q[h++];if(!c[u])c[u]=col;
		go(u)if(cmax(d[v],d[u]-1))q[++t]=v;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	fp(i,1,n)d[i]=-1;
	for(R int i=1,u,v;i<=m;++i)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	scanf("%d",&Q);
	fp(i,1,Q)scanf("%d%d%d",&E[i].u,&E[i].d,&E[i].c);
	fd(i,Q,1)if(cmax(d[E[i].u],E[i].d))solve(E[i].u,E[i].d,E[i].c);
	fp(i,1,n)printf("%d\n",c[i]);
	return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

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


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

int main(void) {
	for (int i = 0; i < 3; i++) {
		string s;
		cin >> s;
		printf("%c", s[0] + ('A' - 'a'));
	}
	printf("\n");


	return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int dp[200009][7];
string s;
bool F(int a, int b, int x, int y){
    for(int i = a; i <= b; i++)
        if(s[i] != s[x - a + i]) return 0;
    return 1;
}
main(){
    cin >> s;
    int n = s.size();
    for(int i = 0; i <n; i++){
        if(i <= 2) dp[i][i+1] = 1;
        for(int j = 1; j <= 3; j++){
            for(int k = 1; k <= 3; k++){
                if(j + k <= i+1){
                    if(j == k && F(i - j - k + 1, i - j, i - j + 1, i)) continue;
                    dp[i][j] = max(dp[i][j], dp[i - j][k] + 1);
                }
            }
        }
    }
    cout<<max(dp[n-1][1], max(dp[n-1][2],dp[n-1][3]))<<endl;



}


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

int main() {
  int N, x, t;
  cin >> N;
  x=0;
  t=N; 
 while(t>0) {
    x += t%10;
   t/=10;
  }
  if(N%x==0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
   

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    while (N > 0) {
        ans++;
        N /= K;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    vector<int> ans(N + 1);
    for (int i = 2; i <= N; i++) {
        cin >> A[i];
        ans[A[i]]++;
    }
    for (int i = 1; i <= N; i++)
        cout << ans[i] << endl;
}

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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main() {
  int a,b;
  cin>>a>>b;
  int sum=0,k;
  for(int i=0;i<b;i++){
    cin>>k;
    sum+=k;
  }
  if(sum>=a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
bool solve(int n, vector<int> a){
    int ma = -1, mi = 100010;
    rep(i,n){
        ma = max(ma, a[i]);
        mi = min(mi, a[i]);
    }
    if(ma - mi > 1) return false;
    else if (ma - mi == 1){
        int min_cnt = 0;
        rep(i, n){
            if(a[i] == mi) min_cnt++;
        }
        return ma > min_cnt && (ma - min_cnt) * 2 <= n - min_cnt;
    }
    else{
        return (n % ma == 0 || n - 1 == ma);
    }
}
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    string ans = solve(n, a)? "Yes":"No";
    cout << ans << endl;
}

Measured memory_bytes: 1024
line = gets.chomp.split().map(&:to_i)
arr = []
# evenループ
num = 0
while num < line[0]
  arr << 0
  num += 1
end
# oddループ
num = 0
while num < line[1]
  arr << 1
  num += 1
end


arrs = arr.combination(2).to_a.map { |ele| ele.inject(:+) } 
# > [0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2]
num = 0
arrs.each {|dd| dd.even? ? num += 1 : num += 0 }
puts num

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

int main(void){
  int N, L;
  string S[100];
  cin >> N >> L;
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  sort(S, S + N);
  for(int i = 0; i < N; i++){
    cout << S[i];
  }
  cout << endl;
  return 0;
}


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

using namespace std;
using llint = long long;
using pint = pair<int,int>;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

const int INF = 1<<28;
const llint LLINF = 1LL<<60;

int x, y, flag=0;
double w, h, area;

int main() {
    // Input
    cin >> w >> h >> x >> y;

    // Solve
    area = w*h/2;
    if (x == w/2 && y == h/2)
    {
        flag = 1;
    }

    // Output
    cout << fixed << setprecision(6) << area << " ";
    cout << flag << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int n;
vector<int> a;
void solve(){
  int cnt=0;
  sort(a.begin(),a.end());
  for(int i=0;i<n-2;i++){
    int k=i+2;
    for(int j=i+1;j<n;j++){
      while(k<n and a[i]+a[j]>a[k]) 
            k++;
      if(k>j) cnt+=(k-j-1);
    }
  }  
  cout<<cnt;
}
int main(){
  fast;
  cin>>n;
  a=vector<int>(n);
  for(int i=0;i<n;i++) cin>>a[i];
  solve();
  return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    sort(s.begin(), s.end());
    if (s.front() == s.back()) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

int main(){
    ll X; cin >> X;
    ll ans = 0;
    ll cnt = 100;
    while(cnt < X){
        ans++;
        ll d = cnt / 100;
        cnt += d; 
    }
    pt(ans);
}

Measured memory_bytes: 3636
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e8+7;
const int MAXN=1e5+9;
const double eps=1e-8;
const long double pi=3.1415926535897932384626433832795;
const long double e=2.71828182845904523536028747135266;
ll n,c[MAXN];
vector<ll> E[MAXN];
ll dfs(ll x,ll fr)
{
	if(E[x].size()==1) {
        return c[x];
    }
	ll s=0,mx=0,w;
	for(auto R:E[x]) {
        if(R!=fr) w=dfs(R,x),mx=max(mx,w),s+=w;
    }
	mx*2<=s?mx=s/2:mx=s-mx;
	if(c[x]>s||c[x]<s-mx) {
        cout << "NO" << endl;
        exit(0);
    }
	w=s-c[x];w=s-2*w;
	if(w<0) {
        cout << "NO" << endl;
        exit(0);
    }
	return w;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    while(t--){
        cin>>n;for(ll i=1;i<=n;i++) cin>>c[i];
	    if(n==2) {
            if(c[1]==c[2]) cout << "YES" << endl;
            else {
                cout << "NO" << endl;
            }
            return 0;
        }
	    for(ll i=1,x,y;i<n;i++) {
            cin>>x>>y;
            E[x].push_back(y);
            E[y].push_back(x);
        }
	    for(ll i=1;i<=n;i++) {
            if(E[i].size()>1) {
                if(dfs(i,0)) cout << "NO" << endl;
                else {
                    cout << "YES" << endl;
                    
                }
                exit(0);
            }
        }
    }
    return 0;
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

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

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, K;
    cin >> N >> K;
    char s[10005];
    cin >> s;

    char res[10005], t[10005], tmp[10005];
    if(K == 1) {
        for(int i = 0; i < N; ++i) {
            t[i] = s[N - i - 1];

        }
        t[N] = '\0';
        strcpy(res, s);
        strcat(s, t);

        for(int i = 1; i < N; ++i) {
            for(int j = i; j < i + N; ++j) {
                tmp[j - i] = s[j];

            }
            if(strcmp(res, tmp) > 0) strcpy(res, tmp);

        }
        cout << res << endl;
        return 0;
    }

    for(int i = 0; i < N; ++i) {
        t[i] = s[N - i - 1];

    }
    t[N] = '\0';
    strcpy(res, s);
    strcat(s, t);
    for(int i = N * 2 - 1; i >= N; --i) {
        for(int j = i; j > i - N; --j) {
            tmp[i - j] = s[j];

        }
        if(strcmp(res, tmp) > 0) strcpy(res, tmp);

    }

    --K;
    int l, r;
    l = 0, r = N - 1;
    while(l < r) {
        swap(res[l], res[r]);
        ++l, --r;

    }

    while(K > 1) {
        int pos = N - 1;
        while(pos >= 0 && res[N - 1] == res[pos]) {
            t[pos] = res[pos];
            --pos;

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

        }

        int p = N - 1;
        while(pos >= 0) {
            t[pos] = res[p];
            --pos, --p;

        }

        strcpy(res, t);
        --K;
    }

    strcpy(t, res);
    l = 0, r = N - 1;
    while(l < r) {
        swap(t[l], t[r]);
        ++l, --r;

    }

    strcpy(s, res);
    strcat(res, t);

    for(int i = 0; i < N; ++i) {
        for(int j = i; j < i + N; ++j) {
            tmp[j - i] = res[j];

        }
        if(strcmp(s, tmp) > 0) strcpy(s, tmp);

    }
    cout << s << endl;
    return 0;
}



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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

typedef long long ll;
typedef pair<ll, ll> P;

const int MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  // 一人一人bitDPで見ていって、正しい数を求める
  int N;cin>>N;
  vector<vector<P>> memo(N);
  REP(i,N) {
    int A;cin>>A;
    REP(j,A) {
      int x,y;cin>>x>>y;
      x--;
      memo[i].push_back({x,y});
    }
  }
  // REP(i,N) {
  //   DUMPP(memo[i]);
  // }
  int ans = 0;
  REP(bit,pow(2,N)) {
    int cnt = 0;
    vector<int> tmp(N,0);
    REP(i,N) {
      if ((1<<i & bit) == 0) {
        // このメンバーは嘘つきとしておく
        tmp[i] = 0;
        continue;
      }
      // 何人いるか
      cnt++;
      // このメンバーは全員正直者としておく
      tmp[i] = 1;
    }
    REP(i,N) {
      if ((1<<i & bit) == 0) continue;
      // 証言チェック
      bool honest = true;
      for (P p:memo[i]) {
        if (tmp[p.first]!=p.second) {
          honest = false;
          break;
        }
      }
      // 食い違いが生じた時点でbreak
      if (!honest) {
        cnt = 0;
        break;
      }
    }
    mmax(ans,cnt);
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 512
rows = []
for _ in range(3):
  rows.append(list(map(int, input().split())))
for i in range(3):
  for j in range(2, -1, -1):
    rows[i][j] -= rows[i][0]
ok = True
for j in range(3):
  for i in range(3):
    if rows[i][j] != rows[0][j]:
      ok = False
if ok: print("Yes")
else: print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
  int h,w;
  cin>>h; cin>>w;
  vector<string> a(h);
  rep(i,h) cin>>a[i];
  vector<bool> height(h),width(w);
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#'){
        height[i]=true;
        width[j]=true;
      }
    }
  }
  rep(i,h){
    if(height[i]){
      rep(j,w) if(width[j]) cout<<a[i][j];
      cout<<endl;
    }
  }
}

Measured memory_bytes: 3612
from collections import defaultdict

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
if n == 1:
    print(1)
    exit()
d = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i== j:
            continue
        a,b = l[i]
        c,e = l[j]
        d[(a-c,b-e)] += 1
ans = n
m = max(d.values())
for i,j in d.items():
    if j != m:
        continue

    x,y = i
    if x==0 and y == 0:
        continue
    count = 0
    for c,d in l:
        if [c+x,d+y] in l:
            count += 1
    ans = min(ans,n-count)
print(ans)

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

using namespace std;

typedef pair<int, int> ii;

int main()
{
    int n;
    scanf("%d", &n);

    bool ok = false;
    while (n) {
        if (n % 10 == 9)
            ok = true;
        n /= 10;
    }

    printf("%s\n", ok ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int ret = 1;
  while(N > 0 && ret < K){
    ret *= 2;
    N--;
  }
  while(N > 0){
    ret += K;
    N--;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1e9 + 7;
int main()
{
    vector<pair<int, bool>> A;
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        A.emplace_back(a, true);
    }
    for (int i = 0; i < N; i++) {
        int b; cin >> b;
        A.emplace_back(b, false);
    }
    sort(begin(A), end(A));
    Int ans = 1, cnt = 0;
    for (int i = 0; i < 2*N; i++) {
        if (cnt > 0 && !A[i].second) ans = (ans * abs(cnt)) % MOD;
        if (cnt < 0 &&  A[i].second) ans = (ans * abs(cnt)) % MOD;
        if (A[i].second) cnt++; else cnt--;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(0);cin.tie(0);
#define mod 1000000009
#define pi 2*acos(0)
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
using namespace std;


int main()
{

	io;
	
	int n; cin >> n;
	vi vis(n+1, 0);
	vi v;
	int tar = 1;
	int del = 0;
	for (int i = 0; i < n; i++)
	{
		int x; cin >> x;
		if (x == tar) {
			vis[tar] = 1;
			tar++;
		}
		else {
			del++;
		}
	}

	if (del == n) cout << -1;
	else cout << del;
}



Measured memory_bytes: 3984
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vector<vecint> m(n, vecint(n));
  REP(i,n)REP(j,n) cin>>m[i][j];
  auto tmp = m;
  REP(k,n)REP(i,n)REP(j,n)
    m[i][j] = min(m[i][j], m[i][k]+m[k][j]);
  if (m != tmp) {
    cout<<-1<<endl;
  } else {
    vector<vector<bool>> need(n, vector<bool>(n, true));
    REP(i,n)REP(j,n)REP(k,n) {
      if (i==j || j==k || k==i) continue;
      if (m[i][j] == m[i][k] + m[k][j]) {
        need[i][j] = false;
      }
    }
    ll sum = 0;
    REP(i,n)REP(j,i) if (need[i][j]) sum += m[i][j];
    cout<<sum<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
int M = 1e9 + 7;
vector<int> v[100005];
bool vis[100005];
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i)
  {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  memset(vis, 0, sizeof(vis));
  vis[0] = 1;
  queue<int> q;
  q.push(0);
  int depth[n];
  depth[0] = 0;
  while (!q.empty())
  {
    int temp = q.front();
    q.pop();
    for (int i = 0; i < v[temp].size(); ++i)
    {
      if (vis[v[temp][i]] == 0)
      {
        vis[v[temp][i]] = 1;
        depth[v[temp][i]] = temp + 1;
        q.push(v[temp][i]);
      }
    }
  }
  for (int i = 0; i < n; ++i)
  {
    if (vis[i] == 0)
    {
      cout << "No";
      exit(0);
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; ++i)
  {
    cout << depth[i] << endl;
  }

}

Measured memory_bytes: 13052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;

#define endl "\n"

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int a,b;
	cin>>a>>b;
	if(a>=13) cout<<b<<endl;
	else if(a>=6) cout<<b/2<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;cin>>n;
  int ans = 100000;
  for(int i = 1; n > i; i++){
    int tmp = 0;
    string s1 = to_string(i);
    string s2 = to_string(n-i);
    for(int z = 0; s1.size() > z; z++)tmp+=s1[z]-'0';
    for(int z = 0; s2.size() > z; z++)tmp+=s2[z]-'0';
    ans = min(tmp,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define MOD 1000000007
using namespace std;

int N;
int C[1010];

int main() {
    cin >> N;
    long long ans = 1;
    for (int i = 1; i <= N; i++) {
        int t = i;
        for (int j = 2; j <= i; j++) {
            int k = 0;
            while (t % j == 0) {
                t /= j;
                k++;
            }
            C[j] += k;
        }
    }

    for (int i = 1; i <= N; i++) {
        ans = ans * (C[i] + 1) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		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();
			}
		}
		long ans = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = i + 1; j < n; ++j) {
				ans+=Math.min(c[i][j], c[j][i]);
			}
		}
		System.out.println(ans);

	}
}

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

int main() {
  int k;
  vector<int> a(5);
  for(int i = 0; i < 5; ++i) cin >> a.at(i);
  cin >> k;
  
  if(a.at(4) - a.at(0) > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif len(e)&1:d.pop()
   else:d.popleft()
 print(*d)
if'__main__'==__name__:s()


Measured memory_bytes: 69732
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdint>
#include <utility>
using namespace std;

int main() {
    uint64_t a[5],n,mi = 0;
    cin >> n;
    for(int i = 0;i < 5;i++) cin >> a[i];
    for(int i = 0;i < 5;i++) {
        if(a[mi] >= a[i]) {
            mi = i;
        }
    }
    uint64_t cnt = n / a[mi];
    if(n % a[mi]) cnt++;
    cnt += 4;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> &P){
    os << P.first;
    os << " ";
    os << P.second;
    os << endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
int N,M;
set<int> ng_nodes;
vector<int> answer;
vector<vector<int>> edge;

vector<int> bfs(int s){ 
    vector<int> dist(N,INF),pre(N);//pre(N); pre[s]=-1; 経路復元するなら
    queue<int> q;
    q.push(s);
    dist[s]=0;
    pre[s]=-1;
    while(!q.empty()){
        int v = q.front(); q.pop();

        for(auto u:edge[v]){
            if(dist[u]!=INF) continue;
            q.push(u); dist[u] = dist[v]+1;
            pre[u] = v;
        }
    }
    debug(dist);

    //サイクル検出
    pair<int,int> best(INF,-1);
    REP(v,N){
        if(v==s) continue;
        for(auto u:edge[v]){
            if(u==s){
                chmin(best,mp(dist[v],v));
            }
        }
    }
    debug(best);
    if(best.first == INF) return vector<int>(N+1); //サイクルなし
    //経路復元
    vector<int> res; int v = best.second;
    while(v!=-1){
        res.push_back(v+1);
        v=pre[v];
    }
    debug(res);
    return res;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    edge.resize(N);
    REP(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
    }
    vector<int> ans(N+2);
    REP(s,N){
        vi now = bfs(s);
        if(now.size() < ans.size()){
            ans = now;
        }
    }
    if(ans.size() > N)cout << -1 << endl;
    else{
        cout << ans.size() << endl;
        cout << ans;
    }
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def main():

    def solve(S, A):
        X = []
        for s, v in zip(S[::-1], A[::-1]):
            for x in X:
                if v & (x & -x):
                    v ^= x
            if v:
                if s == "0":
                    X.append(v)
                else:
                    return 1
        return 0

    T = int(input())
    for t in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        S = input()
        print(solve(S, A))

    return


if __name__ == '__main__':
    main()


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

int main() {
    int H, A;
    cin >> H >> A;

    int ans = 0;
    while (A > 0) {
        if (H == 0) {
            break;
        }
        else if (H < 0) {
            break;
        }
        else {
            H = H - A;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
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;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



string s;
ll K;

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

  ll m = min(100LL, K);
  
  Rep(i, m) {
    if (s[i] != '1') {
      cout << s[i] << "\n";
      return 0;
    }
  }
  cout << s[m-1] << "\n";
}

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

public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int h=Integer.parseInt(br.readLine());

	int a[]=new int[h+1];
	String str[]=br.readLine().split(" ");
	
	for(int i=0;i<h;i++){
	    a[i+1]=Integer.parseInt(str[i]);
	}

	for(int i=h/2;i>=1;i--){
	    maxHeapify(a,h,i);
	}

	for(int i=1;i<=h;i++){
	    System.out.print(" "+a[i]);
	}
	System.out.println();
    }

    static void maxHeapify(int a[],int h,int i){
	    int left=getLeft(i);
	    int right=getRight(i);

	    int max=0;

	    if(left<=h && a[left]>a[i]){
		max=left;
	    }else{
		max=i;
	    }

	    if(right<=h && a[right]>a[max]){
		max=right;
	    }

	    if(max!=i){
		int temp=a[i];
		a[i]=a[max];
		a[max]=temp;
		maxHeapify(a,h,max);	
	    }
    }
    
    static int getParent(int i){
	return i/2;
    }

    static int getLeft(int i){
	return 2*i;
    }

    static int getRight(int i){
	return 2*i+1;
    }
}



Measured memory_bytes: 95604
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int n; cin >> n;
    vector<int> d(n); rep(i, n) cin >> d.at(i);

    sort(all(d));
    cout << d.at(n / 2) - d.at(n / 2 - 1) << "\n";
    return 0;
}

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

 
int main() {
   int n;
   cin>>n;
   vector<int> h(n+1);
   rep(i,n)cin>>h[i];
   int count=0;
   rep(i,100){
       rep(j,n){
          if(h[j]>0){
              h[j]--;
              if(h[j+1]==0)count++;
          }
       }
   }
   cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
inline long long  cntd(long long x){
  long long  res=0;
  while(x){x/=2;res++;}
  return res;
}
int main(){
  long long  n;cin>>n;
  long long k;cin>>k;
  long long a[100010]={};
  for(long long  i=0;i<n;++i)cin>>a[i];
  long long  dig=cntd(k);
  long long q=0;
  for(long long  i=dig-1;i>=0;--i){
	if(q+pow(2,i)>k)continue;
	long long  cnt=0;
	for(long long  j=0;j<n;++j)
	  if(a[j]&(long long )pow(2,i))cnt++;
	if(cnt<(n+1)/2)q+=pow(2,i);
  }
  long long ans=0;

  for(long long  i=0;i<n;++i)
	ans+=q^a[i];

  cout<<ans<<endl;
  return 0;

  

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<ll> d(n);
	map<ll, int> mp;
	rep(i, n) {
		cin >> d[i];
		mp[d[i]] = i;
	}
	sort(all(d));
	vector<int> sz(n, 1);
	vector<P> ans;
	vector<vector<int>> graph(n, vector<int>());
	for (int i = n - 1; i >= 1; i--) {
		int v = mp[d[i]];
		ll dis = n - sz[v] * 2;
		ll par = d[i] - dis;
		ll idx = lower_bound(all(d), par) - d.begin();
		if (dis <= 0 || d[idx] != par) {
			cout << -1 << '\n';
			return 0;
		}
		ans.pb(P(mp[d[idx]] + 1, v + 1));
		graph[mp[d[idx]]].pb(v);
		graph[v].pb(mp[d[idx]]);
		sz[mp[d[idx]]] += sz[v];
	}
	int root = mp[d[0]];
	ll sum = 0;
	queue<P> que;
	vector<bool> vis(n);
	que.push(P(root, 0)); vis[root] = true;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		int pf = p.first; int ps = p.second;
		sum += ps;
		for (int i : graph[pf]) {
			if (vis[i]) continue;
			que.push(P(i, ps + 1));
			vis[i] = true;
		}
	}
	if (sum != d[0]) cout << -1 << '\n';
	else for (P p : ans) cout << p.first << ' ' << p.second << '\n';
}

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

using namespace std;
#define ll long long
bool isprime(ll x)
{
    for(ll i=2;i*i<=x;i++)
        if(x%i==0)
            return 0;
    //cout<<x<<endl;
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll a,b;
    cin>>a>>b;
    ll g=__gcd(a,b);
    ll ans=0;
    for(ll i=2;i*i<=g;i++)
        if(g%i==0)
        {
            ans++;
            while(g%i==0)
                g/=i;
        }
    if(g!=1)ans++;
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 256
r,c = input().split()

r = int(r)
c1 = int(c)+1

table = [[0]*c1 for i in range(r+1)]


num = []

for a in range(r):
    
    num = input().split()

    for b in range(c1):

        if b != c1-1:
            table[a][b] = int(num[b])

        else:
            table[a][b] = sum(table[a])
    
    
for C in range(c1):
    total = 0
    for d in range(r):
        total += table[d][C]

    table[r][C] = total
        
for e in range(r+1):
    print(" ".join(map(str,table[e])))


Measured memory_bytes: 5700
$n = <>;
@a = split(" ",<>);
@b = split(" ",<>);
@c = split(" ",<>);
$sum += $_ for @b;
for($i =0; $i < $n; $i++){
	if(($a[$i+1] - $a[$i])==1){
        $sum += $c[$a[$i]-1];
    }
}
print $sum;

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

int main() {
  int A;
  cin >> A;
  
  if(A==25){
    cout << "Christmas" << endl;
  }
  else if(A==24){
    cout << "Christmas Eve" << endl;
  }
  else if(A==23){
	cout << "Christmas Eve Eve" << endl;
  }
  else{
  	cout << "Christmas Eve Eve Eve" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s;
  cin>>s;
  int n=s.size();
  int c[26]={};
  for(int i=0;i<n;i++) c[s[i]-'a']++;
  int x=0;
  for(int i=0;i<26;i++) x+=c[i]%2;
  if(x==0) cout<<0<<endl;
  else{
    if(n%2) cout<<x/2<<endl;
    else cout<<(x+1)/2<<endl;
  }
  return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.size();
    ll cnt = 0;
    for (int i = 1; i < n; i++) {
        if (s[i-1] != s[i]) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN = 100010;
const int INF = 0x3f3f3f3f;
int n, k, a[MAXN], f[MAXN];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),f[i]=INF;
	f[1] = 0;
	for(int i=1;i<=n;i++)
	{
		for(int j=max(i-k,1);j<i;j++)
			f[i] = min(f[i], f[j]+abs(a[i]-a[j]));
	}
		
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define db double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
const int N=100000;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
struct P{
	int x,y,id,dis;
	inline int init() { return x=inn(),y=inn(); }
	inline int getdis(int r,int c)
	{
		if(x==0) return dis=y;
		if(y==c) return dis=c+x;
		if(x==r) return dis=c+r+(c-y);
		if(y==0) return dis=c+r+c+(r-x);
		return assert(0),0;
	}
	inline bool operator<(const P &p)const { return dis<p.dis; }
}p[N<<1];int s[N],vis[N];
#define on_bj(p) (p.x==0||p.x==r||p.y==0||p.y==c)
int main()
{
	int r=inn(),c=inn(),n=inn(),cnt=0;
	rep(i,1,n)
	{
		static P p1,p2;p1.init(),p2.init();
		if(!on_bj(p1)||!on_bj(p2)) continue;
		p[++cnt]=p1,p[cnt].id=i,p[++cnt]=p2,p[cnt].id=i;
	}
	rep(i,1,cnt) p[i].getdis(r,c);
	sort(p+1,p+cnt+1);int t=0;
	rep(i,1,cnt)
	{
		if(!vis[p[i].id]) vis[s[++t]=p[i].id]=1;
		else{
			if(s[t]!=p[i].id) return !printf("NO\n");
			vis[p[i].id]=0,t--;
		}
	}
	return !printf("YES\n");
}

Measured memory_bytes: 3968
tic=list(input())

b=int(tic[1])
c=int(tic[2])
d=int(tic[3])

a=int(tic[0])
B=[b,-b]
C=[c,-c]
D=[d,-d]

ans=0
ans2=tic[0]

for i in range(2):
  for j in range(2):
    for k in range(2):
      ans=a+B[i]+C[j]+D[k]
      if ans==7:
        b=B[i]
        c=C[j]
        d=D[k]
ans=[b,c,d]

for an in ans:
  if an >= 0:
    ans2 += '+'+str(an)
  else:
    ans2 += str(an)
    
ans2 += '=7'

print(ans2)

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

int main(){
  string S;
  cin >> S;
  string A={};
  A.push_back(S.at(6));
  if(S.at(5)=='1' || stoi(A)>4){
    cout << "TBD" << endl;
  }
  else{
    cout << "Heisei" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
inline void InitRand()
{
    srand((unsigned int)time(NULL));
}

inline int nic(int name_long)
{
    return rand() % name_long ;
}
int main() {
  string name;
  int name_long,nic_begin;
  cin >> name;
  name_long=name.length();
  nic_begin=nic (name_long - 2);
  cout << name.substr(nic_begin,3);
  return 0;
}

Measured memory_bytes: 3596
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();
        calculation(a, b);
    }

    public static void calculation(int a, int b) {
        int sub = a > b ? a - b : b - a;
        if (sub % 2 == 1) {
            System.out.println("IMPOSSIBLE");
            return;
        }
        int k = sub / 2 + (a > b ? b : a);
        System.out.println(String.format("%d", k));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll calc(ll bit,ll k,vector<ll>v){
    if(bit==-1)return 0;
    vector<ll> tmp;
    for(ll i=0;i<(ll)v.size();i++)if((v[i]>>bit)&1)tmp.push_back(v[i]);
    if(tmp.size()>=k)return (1ll<<bit) + calc(bit-1,k,tmp);
    else return calc(bit-1,k,v);
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k;cin>>n>>k;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    vector<ll> v;
    for(ll i=0;i<n;i++)for(ll j=i,sum=0;j<n;j++)sum+=a[j],v.push_back(sum);
    cout<< calc(60,k,v);
}



Measured memory_bytes: 112876
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    int r;
    cin>>r;
    cout<<r*r<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
ans = [0]*n

cnt = 0
for i in range(n):
  if s[i] == 'R':
    cnt += 1
  else:
    ans[i-1] += (cnt+1)//2
    ans[i] += cnt//2
    cnt = 0

for i in reversed(range(n)):
  if s[i] == 'L':
    cnt += 1
  else:
    ans[i+1] += (cnt+1)//2
    ans[i] += cnt//2
    cnt = 0
    
for i in range(n):
  print(ans[i], end=" ")

Measured memory_bytes: 4864