akhauriyash/Code-Regression huggingface dataset:
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

# p = 1
ans = 0
for i in range(n):
    ans += abs(x[i]-y[i])
print (ans)

# p = 2
ans = 0
for i in range(n):
    ans += (abs(x[i]-y[i]))**2
print (ans**(1/2))

# p = 3
ans = 0
for i in range(n):
    ans += (abs(x[i]-y[i]))**3
print (ans**(1/3))

# p = inf
ans = []
for i in range(n):
    ans.append(abs(x[i]-y[i]))
print (max(ans))



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

long long int n, a, b;

int x[100005];

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

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

	long long int kapaguran = 0;
	for(int i = 1; i < n; i++) kapaguran += min((x[i]-x[i-1])*a, b);

	cout << kapaguran << endl;

	return 0;
}

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

int main(){
    int i, j = 0;
    string s, t = "AKIHABARA";
    cin >> s;
    s += " ";
    for(i=0; i<9; i++){
        if(s[j] == t[i]){
            j++;
        }else if(t[i] != 'A'){
            cout << "NO";
            return 0;
        }
    }
    if(s.length()-1 == j){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
type Row  = [Int]
type Matrix = [Row]

main = getContents >>= putOut.formatOut.solve.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s
  
formatIn :: String -> Matrix
formatIn =  map ((map (read :: String -> Int)).words).tail.lines

formatOut :: Matrix -> String
formatOut = unlines.map (unwords.(map show)) 

solve :: Matrix -> Matrix
solve rows = newRow ++ [allSum (newRow++[])]
  where addSum xs = xs ++ [sum xs]
        newRow = map addSum rows
        allSum [] = [0,0..]
        allSum (y:ys) = zipWith (+) y $allSum ys

Measured memory_bytes: 6468
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
res = 0
sa = -1

for i in range(N):
  t = T - 0.006 * H[i]
  s = abs(A - t)
  if sa < 0 or s < sa:
    sa = s
    res = i + 1

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        for(;;){
            string tmp;
            getline(cin, tmp);
            if(tmp == "")
                break;
            s += tmp;
        }
        int n = s.size();
        if(n == 0)
            return 0;

        string key;
        getline(cin, key);
        int m = key.size();
        vector<bool> isKey(256, false);
        for(int i=0; i<m; ++i)
            isKey[key[i]] = true;

        vector<int> last(256, -1);
        set<int> pos;
        int num;
        int head;
        int len = INT_MAX;
        for(int i=0; i<n; ++i){
            if(isKey[s[i]]){
                if(last[s[i]] != -1)
                    pos.erase(pos.find(last[s[i]]));
                last[s[i]] = i;
                pos.insert(i);

                if(pos.size() == m){
                    int len2 = i - *(pos.begin()) + 1;
                    if(len2 < len){
                        len = len2;
                        num = 1;
                        head = *(pos.begin());
                    }else if(len2 == len){
                        ++ num;
                    }
                }
            }
        }

        if(len == INT_MAX){
            cout << '0' << endl;
        }else{
            cout << num << endl << endl;
            while(len > 72){
                cout << s.substr(head, 72) << endl;
                head += 72;
                len -= 72;
            }
            cout << s.substr(head, len) << endl;
        }
        cout << endl;

        getline(cin, s);
    }
}

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

int main() {
    ll a, b;
    cin >> a >> b;

    if(a >b ){
        if(b == 1){
            cout << "Bob" << endl;
            return 0;
        }
        cout << "Alice" << endl;
    }
    else if(a < b){
        if(a == 1){
            cout << "Alice" << endl;
            return 0;
        }
        cout << "Bob" << endl;
    }
    else if(a == b){
        cout << "Draw" << endl;
    }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

struct Edge {
	int u, v, w;
	Edge(int a = 0, int b = 0, int c = 0) {
		u = a, v = b, w = c;
	}
} edge[100];

int main() {
	int n, ct = 0;
	scanf("%d", &n);
--n;
	int cur = 20;
	while (n) {
		edge[ct++] = Edge(cur - 1, cur, (n + 2) / 2);
		edge[ct++] = Edge(cur - 1, cur, 1 - n % 2);
		if (n % 2 == 0)
			edge[ct++] = Edge(1, cur, 0);
		n = (n - 1) / 2;
		--cur;
	}
	for (int i = 1; i < cur; ++i)
		edge[ct++] = Edge(i, i + 1, 0);
	printf("20 %d\n", ct);
	for (int i = 0; i < ct; ++i)
		printf("%d %d %d\n", edge[i].u, edge[i].v, edge[i].w);
	return 0;
}

Measured memory_bytes: 1668
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long

const lint MOD = 1e9 + 7;
const int MAX = 100005;
long long fac[MAX];

void facinit(){
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }   
}

long long modinv(long long a) {
    long long b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD; 
    if (u < 0) u += MOD;
    return u;
}

int main(){
    facinit();

    int n; cin >> n;
    vector<lint> x;
    rep(i, n){
        lint y; cin >> y; x.push_back(y);
    }

    vector<lint> c;
    rep(i, n-1){
        if(i == 0){
            c.push_back(fac[n-1]); continue;
        }
        lint newc = (fac[n-1] * modinv(i+1)) % MOD;
        newc = (c[i-1] + newc) % MOD;
        c.push_back(newc);
    }

    lint res = 0;
    rep(i, n-1){
        lint d = ((x[i+1]-x[i]) * c[i]) % MOD;
        res += d;
        res %= MOD;
    }

    cout << res << endl;
    
}

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

string a, b;
int dp[3001][3001];
int mark[3001][3001];
int main(){
    cin>>a>>b;
    int n = a.length(), m = b.length();


    for(int x=1;x<=n;x++){
        for(int y = 1; y<=m;y++){
            if(a[x-1] == b[y-1]){
                dp[x][y] = 1 + dp[x-1][y-1];
                mark[x][y] = 1;
            }else{
                if(dp[x-1][y] >= dp[x][y-1]){
                    mark[x][y] = 2;
                }else{
                    mark[x][y] = 3;
                }
                dp[x][y] = max(dp[x-1][y], dp[x][y-1]);

            }
        }
    }
    string res = "";
    int x = n;
    int y = m;

    while(x >= 1 && y >= 1){
        if(mark[x][y] == 1){
            res += a[x-1];
            x--;
            y--;
        }else if(mark[x][y] == 2){
            x--;
        }else{
            y--;
        }
    }
    reverse(res.begin(), res.end());
    //cout<<dp[n][m]<<endl;
    cout<<res<<endl;

}


Measured memory_bytes: 73912
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  char c[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<w;i++){
    bool a=true;
    for(int j=0;j<h;j++){
      if(c[j][i]=='#')
        a=false;
    }
    if(a){
      for(int j=0;j<h;j++){
        c[j][i]='%';
      }
    }
  }
  for(int i=0;i<h;i++){
    bool a=true;
    for(int j=0;j<w;j++){
      if(c[i][j]=='#')
        a=false;
    }
    if(a){
      c[i][0]='d';
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]=='d')
        break;
      else if(c[i][j]!='%')
        cout<<c[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }

struct UnionFind {
  std::vector<int> par, rank;

  UnionFind(int n) : par(n , -1), rank(n, 0) {}

  void init(int n) {
    par.assign(n, -1); rank.assign(n, 0);
  }

  int root(int x) {
    if (par[x] == -1) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(int x, int y) {return root(x) == root(y);}

  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (rank[x] < rank[y]) std::swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    return;
  }
};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, m; cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i]; --p[i];
  }
  vector<int> x(m), y(m);

  UnionFind uf(n);

  for (int i = 0; i < m; ++i) {
    cin >> x[i] >> y[i];
    --x[i]; --y[i];
    uf.unite(x[i], y[i]);
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += uf.issame(p[i], i);
  }

  print(ans);

  return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath> 
using namespace std;
	int main(){
		int a,b,c,d;
		double pi=acos(-1.0);
		cin>>a>>b>>c>>d;
		double jiao1=d*6;
		double jiao2=c*30.0+(d/60.0)*30.0;
		double j=abs(jiao1-jiao2);
		if(j>180)
			j=360-j;
		j=j*2*pi/360;
		cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(j))<<endl;
	}

Measured memory_bytes: 4048
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

const long long LL_INF = (long long) 2e18 + 5;

int N;
vector<long long> A;
vector<int> ops;

void add_ops(int first, int second) {
    while (second - first > 2) {
        ops.push_back(first + 2);
        second -= 2;
    }

    ops.push_back(first + 1);
}

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

    cin >> N;
    A.resize(N);

    for (auto &a : A)
        cin >> a;

    long long best = -LL_INF;
    vector<int> best_indices;

    for (int parity = 0; parity < 2; parity++) {
        long long sum = 0;
        vector<int> indices;
        vector<pair<long long, int>> values;

        for (int i = parity; i < N; i += 2)
            values.emplace_back(A[i], i);

        sort(values.rbegin(), values.rend());

        for (pair<long long, int> entry : values)
            if (indices.empty() || entry.first > 0) {
                sum += entry.first;
                indices.push_back(entry.second);
            }

        sort(indices.begin(), indices.end());

        if (sum > best) {
            best = sum;
            best_indices = indices;
        }
    }

    cout << best << '\n';

    for (int i = N - 1; i > best_indices.back(); i--)
        ops.push_back(i);

    for (int i = (int) best_indices.size() - 1; i > 0; i--)
        add_ops(best_indices[i - 1], best_indices[i]);

    for (int i = 0; i < best_indices.front(); i++)
        ops.push_back(0);

    cout << ops.size() << '\n';

    for (int op : ops)
        cout << op + 1 << '\n';
}


Measured memory_bytes: 256
import sys
def f(a,b,c):
    return a if a!="s"and a==b==c else 0
for s in sys.stdin:
    for i in range(3):
        c=f(*s[i:9:3])
        if c: break
        j=i*3
        c=f(*s[j:j+3])
        if c: break
    else:
        c=s[4] if f(*s[0:9:4])or f(*s[2:7:2]) else "d"
    print c

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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

const int maxn = 2e5 + 5;
vector<int> g[maxn];
bool vis[maxn];

int dfs(int x) {
    vis[x] = 1;
    int cnt = 1;
    for (int adj: g[x]) {
        if (!vis[adj]) {
            cnt += dfs(adj);
        }
    }
    return cnt;
}

void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int mx = 0;
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            mx = max(mx, dfs(i) - 1);
        }
    }
    cout << mx + 1 << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 24088
def main(): 
    a=int(input())
    a_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(a_list[a-1])
main()

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10**9
MOD = 10**9+7

N = int(input())
L = [int(x) for x in input().split()]
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        k = bisect_left(L, L[i]+L[j])
        ans += k-j-1
print(ans)


Measured memory_bytes: 44796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N, K, dif, min = 2000000000;
    cin >> N >> K;
    int h[100000];
    for(int i=0;i<N;i++)
        cin >> h[i];
    // 降順ソート
    sort(h, h + N, greater<int>());
    // 差
    for(int i=0;i+K-1<N;i++){
        dif = h[i] - h[i+K-1];
        if(dif < min)
            min = dif;
    }
    cout << min << endl;
    return 0;
}

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

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=20;
char c[maxn];
string s;
ll ans;

void solve(int k,ll cur,ll sum){
//	cout<<k<<" "<<cur<<" "<<sum<<endl;
	if(k==s.size()){
		ans+=sum+cur;
		return;
	}
	solve(k+1,cur*10+(s[k]-'0'),sum);
	if(k)solve(k+1,s[k]-'0',sum+cur);
} 

int main(){
	scanf("%s",c);
	s=c;
	solve(0,0LL,0LL);
	printf("%lld",ans);
	return 0;
}

/*
Input:
-----------------
Output:
*/

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

int main(){
	map<string, int> word;
	int mfrec=0;
	string mfs, ls, in;
	while(cin>>in){
		if(word.count(in)==0) word[in]=0;
		word[in]++;
		if(mfrec<word[in]){
			mfrec=word[in];
			mfs=in;
		}
		if(ls.length()<in.length()) ls=in;
	}
	cout << mfs << " " << ls << endl;
	return 0;
}

Measured memory_bytes: 3188
//#include <bits/stdc++.h>
#include<iostream>
#include <iosfwd>
#include<limits.h>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <limits>
#include<stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include<vector>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define fr(i,j,n)   for(lli i=j;i<(n);++i)
#define bk(i,j,n)   for(lli i=j;i>=n&&j>=n;--i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mem(p,v) memset(p,v,sizeof(p))
#define present(c,x)    ((c).find(x) != (c).end())
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define debug4(x,y,z,a) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<" "<<#a<<" "<<a<<endl;
#define ub upper_bound
#define lb lower_bound
typedef long long int lli;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<lli> vl;
typedef pair<lli,lli> pl;
inline lli max(lli a,lli b){ return a>b?a:b;}
inline lli min(lli a,lli b){ return a<b?a:b;}
const long long inf = 1e18;
const lli MOD =998244353 ;
void show(vector<lli> v){fr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;}
void show(vector<int> v){fr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;}
void show(int a[], int arraysize){for (int i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(lli a[], lli arraysize){for (lli i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(bool a[], lli arraysize){for (lli i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(set<int> s){for (auto it = s.begin(); it != s.end(); it++){cout << *it << " ";}cout<<endl;}
void show(map<lli,lli> mp){for (auto it = mp.begin(); it != mp.end(); it++){cout << it->first << " "<<it->second<<endl;}cout<<endl;}
//Pair hashing is done using std::map ;
lli modpow(lli x,lli n){lli res=1;while(n>0){if(n&1) res=((res%MOD)*(x%MOD))%MOD;x=((x%MOD)*(x%MOD))%MOD;n>>=1;}return res;}
lli power(lli x, lli n){lli res=1;while(n>0){if(n&1) res=res*x;x=x*x;n>>=1;}return res;}

/////// ------ Main code starts here ------ /////
void solve()
{
    lli x,d,k;
    cin>>x>>k>>d;
    x=abs(x);
    lli i= x/d;
    if(i>=k)
    {
        cout<<abs(x-k*d)<<endl;
        return;
    }
    else
    {
        lli l1=x-d*i,l2=abs(l1-d);
        if((k-i)%2==0)
        {
            cout<<abs(l1)<<endl;
        }
        else
        {
            cout<<abs(l2)<<endl;
        }
        
    }
}
int main()
{
    run;cout<<fixed<<setprecision(12);
    int t;
    t=1;
    while(t){solve();t--;}
    return 0;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1005;

int n;
int a[N];

int main() {

	FAST;

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(b - a) <= d && abs(c - b) <= d)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define rrep(i, n) for (i = n; i >= 0; i--)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)

const int mod = 1000000007;

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

    long long ans = 1; int i;
    rep(i, n) {
        ans *= i + 1;
        ans %= mod;
    }

    printf("%d\n", ans);
    return 0;
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 2 * N;

int n, m, k;
int h[N], e[N], ne[N], idx;
int p[N], size[N];
int res[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int find(int x)
{
	if (x != p[x]) p[x] = find(p[x]);
	return p[x];
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b), add(b, a);
	}
	
	for (int i = 0; i <= n; i ++ ) p[i] = i, size[i] = 1;
	
	for (int t = 1; t <= n; t ++ )
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			res[t] -- ;
			int a = find(t), b = find(j);
			if (a == b) continue;
			size[b] += size[a];
			p[a] = b;
		}
		
	// for (int i = 1; i <= n; i ++ ) cout << res[i] << ' ';
	// puts("");
		
	for (int i = 0; i < k; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		int aa = find(a), bb = find(b);
		if (aa == bb) res[a] -- , res[b] -- ;
	}
	
	for (int i = 1; i <= n; i ++ ) printf("%d ", res[i] + size[find(i)] - 1);
    return 0;
}

Measured memory_bytes: 5120
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int cnt = 0;
    for (int i = 0; i < S.length() - 1; i++) {
      if (S.charAt(i) == S.charAt(i + 1)) {
        cnt++;
      }
    }
    if (cnt == 0) {
      System.out.println("Good");
    } else {
      System.out.println("Bad");
    }
  }
}


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

int main() {
     string S,T;
     string ans = "Yes";
     cin >> S >> T;
     if(S.length() + 1 == T.length()) {
         for(long unsigned int i=0;i<S.length();i++) {
             if(S[i] != T[i]) {
                  ans = "No";
                  break;
              } 
          }   
      } else {
          ans = "No";
      }
      cout << ans;
  }    


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){

    

}

ll get(ll x,ll y,ll z){
    ll ans = x*x + y*y + z*z;
    ans += x*y + y*z + z*x;
    return ans;
}

ll ans[maxs];

void solve(){
    
    ll n;
    cin >> n;
    for(ll i=1;i<=100;i++){
        for(ll j=1;j<=100;j++){
            for(ll k=1;k<=100;k++){
               ll val = get(i,j,k);
                if(val < maxs){
                    ans[val]++;
                }
            }
        }
    }

    for(ll i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

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

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        const ll MOD=1e9+7;
        ll n;
        cin>>n;
        map<ll,ll> m;
        rep(i,n-1){
            ll x=i+2;
            map<ll,ll> m2=prime_factor(x);
            rbf(p,m2){
                m[p.Fi]+=p.Se;
            }
        }
        ll res=1;
        rbf(p,m){
            res*=p.Se+1;
            res%=MOD;
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  
  if(N%2 == 1) cout << 0 << endl;
  else {
    N /= 2;
    int five = 0;
    while(N > 0) {
      N /= 5;
      five += N;
    }
    cout << five << endl;
  }
    
  
}

Measured memory_bytes: 3556
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  gra g(n);
  ll a,b;
  rep(i,n-1){
    cin >> a >> b;
    g[a-1].pb(b-1);
    g[b-1].pb(a-1);
  }
  ll dlits[n];
  function<void(const gra&,ll,ll,ll)> dfs= [&](const gra &g,ll p,ll v,ll f) {
      dlits[v]=f;
      for(auto next_v:g[v]){
          if(next_v==p)continue;
          dfs(g,v,next_v,f+1);
      }
  };
  dfs(g,-1ll,0ll,0ll);
  
  ll tpoi = (dlits[n-1])/2;
  ll co=0;
  function<void(const gra&,ll,ll)> dfs2= [&](const gra &g,ll p,ll v) {
      co++;
      for(auto next_v:g[v]){
          if(next_v==p || dlits[next_v]==tpoi)continue;
          dfs2(g,v,next_v);
      }
  };
  dfs2(g,-1ll,n-1);
  pri((n+2-1)/2>co?"Fennec":"Snuke");
  
  return 0;
}



Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> R >> G >> B;
    ans = 100 * R + 10 * G + B;
    if (ans % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 3504
def f(i):
    global ans
    if i == l:
        if 3 in s and 5 in s and 7 in s:
            c = 0
            for j in range(l):
                c += s[j] * 10 ** (l - j - 1)
            if c <= n:
                ans += 1
                #print(c)
        return
    f(i + 1)
    s[i] = 7
    f(i + 1)
    s[i] = 5
    f(i + 1)
    s[i] = 3

n = int(input())
l = len(str(n))
s = [3] * l
ans = 0
f(0)
m = [6, 36, 150, 540, 1806, 5796]
if l >= 4:
    for i in range(l - 3):
        ans += m[i]
print(ans)

Measured memory_bytes: 3064
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;	
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) 
{
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}

template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
int modulo = 1e9 + 7;

int fpow(int a, int n) 
{
	int ans = 1;
	while (n) 
	{
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

signed main() 
{
	fast_io();
	int n; cin >> n;
	int ans = inf;
	for (int i = 1; i <= sqrt(n); ++i)
	{
		if (n%i) continue;
		int a = n/i, b = i;
		ans = min(ans, a+b-2);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
require 'set'
s = Set.new
for i in 1..n
  com,name = gets.split
  case com
  when "insert"
    s.add(name)
  when "find"
    if s.include?(name)
      puts "yes"
    else
      puts "no"
    end
  end
end

Measured memory_bytes: 169064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n, k;
    cin >> n >>k;
    ll s[n], i;
    for(i=0; i<n; i++){
        cin >> s[i];
    }
    for(i=0; i<n-k; i++){
        s[i]<s[i+k]?cout <<"Yes\n":cout <<"No\n";
    }
    return 0;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#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 F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;

int n;
vi v;
int a[100050];
int b[100050];
priority_queue<pii> A;
priority_queue<pii> B;


int main(void) {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  //freopen("in.txt", "r", stdin);
  cin >> n;
  v.resize(n);
  rep(i,0,n) {
    cin >> v[i];
  }

  rep(i,0,n) {
    if(i%2) {
      b[v[i]]++;
    } else {
      a[v[i]]++;
    }
  }

  rep(i,0,100050) {
    if(a[i] > 0)
      A.push(mp(a[i],i));
    if(b[i] > 0)
      B.push(mp(b[i],i));
  }

  int maxA = A.top().F;
  int numA = A.top().S;
  A.pop();
  int maxB = B.top().F;
  int numB = B.top().S;
  B.pop();

  if(numA != numB) {
    cout << n - maxA - maxB << endl;
    return 0;
  } else {
    int maxA2 = (A.empty() ? 0 : A.top().F);
    int maxB2 = (B.empty() ? 0 : B.top().F);
    int ret = n;
    ret = min(ret, n - maxA - maxB2);
    ret = min(ret, n - maxA2 - maxB);
    cout << ret << endl;
  }
  return 0;
}

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

int main(void){
	int a, b;
	cin>>a>>b;
	for(int i=1; i<999; i++){
		int val1  = ((i)*(i+1))/2;
		int val2 = ((i+1)*(i+2))/2;
		if(val1> a && (val2)>b){
			if(val1-a == val2-b && val1-a>0){
				cout<<val1-a<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int c[MAXn],t[MAXn];
int main(){
  IOS();
  int n,T;
  cin>>n>>T;
  REP(i,n) cin>>c[i]>>t[i];
  int ans = INF;
  REP(i,n)if( t[i]<=T ) chkmin(ans,c[i]);
  if( ans==INF ) cout<<"TLE"<<endl;
  else cout<<ans<<endl;
}


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

int main() {
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int ans;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(500*i+100*j+50*k==x){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

#define N 10000

int n;

void Countingsort(unsigned short* ,unsigned short*,int);

int main(){

  unsigned short *A, *B;

  int k=0;
  int i;

  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
      if(k<A[i+1]) k = A[i+1];
  }


  Countingsort(A,B,k);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i<n) printf(" ");
  }

  printf("\n");

  return 0;

}

void Countingsort(unsigned short *A, unsigned short *B, int k){

  int i,C[k];

  for ( i = 0; i <= k; i++ ) C[i] = 0;

  for ( i = 1; i <= n; i++ )  C[A[i]]++;

  for ( i = 1; i <= k; i++ ) C[i] = C[i] + C[i - 1];

  for ( i = n; i > 0; i-- ){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }

}

Measured memory_bytes: 8456
fun main(args: Array<String>) = println(run {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val s = (1..m).map { readLine()!!.split(" ").map { it.toInt() }.drop(1) }
    val p = readLine()!!.split(" ").map { it.toInt() }

    fun ok(pattern: Int): Boolean {
        val switch = (0 until n).map { pattern.shr(it).and(1) == 1 }
        val light = s.map { it.count { i -> switch[i-1] } }
                .mapIndexed { i, count -> count % 2 == p[i] }
        return light.all { it }
    }

    (0 until 1.shl(n)).count { ok(it) }
})

Measured memory_bytes: 40420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll n,m,x[55];
vector<pll> v[55];
ll dp[1<<20];

bool dfs1(ll a,ll b,ll c,ll d) {
  if(a==c) {
    return 1;
  }
  for(auto& i:v[a]) {
    if(i.first!=b&&dfs1(i.first,a,c,d)) {
      x[i.second]^=1<<d;
      return 1;
    }
  }
  return 0;
}

int main() {
  cin >> n;
  vec a(n),b(n);
  for(ll i=1;i<n;i++) {
    ll a,b;
    cin >> a >> b;
    v[a].emplace_back(b,i);
    v[b].emplace_back(a,i);
  }
  cin >> m;
  for(ll i=0;i<m;i++) {
    ll a,b;
    cin >> a >> b;
    dfs1(a,0,b,i);
  }
  dp[0]=1;
  for(ll i=1;i<n;i++) {
    for(ll j=(1<<m)-1;j>=0;j--) {
      dp[j|x[i]]+=dp[j];
    }
  }
  cout << dp[(1<<m)-1] << endl;
}

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

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

int main(){ 
  string s;
  cin >> s;
  rep(i,s.length()){
    cout << 'x';
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 200010
using namespace std;
 
int arr[MAX];
int partial[MAX];
 
int main(void)
{
	cout << setprecision(12);
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> arr[i];
	for (int i = 0; i < N; i++) partial[i + 1] = partial[i] + arr[i];
	int mmax = 0;
	for (int i = K; i <= N; i++) mmax = max(mmax, partial[i] - partial[i - K]);
	double ans = (mmax + K) / 2.0;
	cout << ans << endl;
}


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

#define int long long

signed main(){

  int S;
  int ans = 0, con = 0;
  map<int,int> mp;
  
  cin>>S;

  for(int i = 1; i <= S; i++){
    for(int j = i, sum = i; sum <= S; j++){
      mp[sum]++;
      // cout<<"i "<<i<<" j "<<j<<" "<<sum<<endl;
      sum += j+1;
      
      con++;
    }
  }

  // cout<<con<<endl;

   for(int i = 1; i <= S; i++){
     if(S%i) continue;
     int a = mp[i], b = mp[S/i];

     // if(i == S/i) b--;

      if(a < 0 || b < 0) continue;

     ans += a * b;
   }

   cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 9228
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back

int n;


int main(){
    int dy[]={0,1,0,-1};
    int dx[]={-1,0,1,0};
    
    while(cin>>n){
        int left=1000,right=-1,up=1000,down=-1;
        if(n==0)break;
        
        vector<pii> point(300);
        point[0]=pii(250,250);
        
        left=min(left,point[0].second);
        right=max(right,point[0].second);
        up=min(up,point[0].first);
        down=max(down,point[0].first);
        
        rep(i,n-1){
            int num,dir;
            cin>>num>>dir;
            point[i+1]=pii(point[num].first + dy[dir],point[num].second + dx[dir]);
            left=min(left,point[i+1].second);
            right=max(right,point[i+1].second);
            up=min(up,point[i+1].first);
            down=max(down,point[i+1].first);
        }
        cout<<right-left+1<<" "<<down-up+1<<endl;
    }
    
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int r,g,b,n,rs=0;
        cin>>r>>g>>b>>n;
        for(int i=0;r*i<=n;i++)
        {
                for(int j=0;r*i+g*j<=n;j++)
                {
                        int lf=n-r*i-g*j;
                        rs+=((lf%b)==0);
                }
        }
        cout<<rs<<"\n";
        return 0;
}
/**

**/


Measured memory_bytes: 256
import sys,math,string,bisect
from itertools import *
input=sys.stdin.readline
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
S=lambda :input().strip()
n=I()
i=input()
#print()
l=list(map(int,i.split()))
l=tuple(l)
i=input().strip()
m=list(map(int,i.split()))
m=tuple(m)
d=list(permutations(set(l)))
#print(d)
print(abs(d.index(l)-d.index(m)))


Measured memory_bytes: 8560
N = int(input())
S = input()
temp=0
for i in range(N-1):
    S1=S[0:i+1]
    S2=S[i+1:N]
#    print(S1 + " " + S2)
    kaburi=[]
    for s in S1:
        if s in S2 and s not in kaburi:
            kaburi.append(s)
    if len(kaburi)>temp:
        temp = len(kaburi)
print(temp)

Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long a,b,k;
   cin>>a>>b>>k;
   long long sum=a+b-k;
   if(sum>=0)
   {
       if(sum>b)
       cout<<(sum-b)<<" "<<b<<"\n";
       else
       cout<<0<<" "<<sum<<"\n";
   }
   else
   cout<<0<<" "<<0<<"\n";
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define N 300000 + 5
#define int long long
#define mid (l + r) / 2
#define inf 10000000000000000
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define dep(i, l, r) for(int i = r; i >= l; --i)
typedef double D;
int n, m, P, X, top, f[N], g[N], h[N], t[N], T[N], S1[N], S2[N], st[N], mx[N];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Y1(int x){
    return f[x] + x * (x - 1) / 2 + S1[x];
}
int Y2(int x){
    return g[x] + x * (x - 1) / 2 + S2[x];
}
int Y3(int x){
    return x * (x + 1) / 2 - S1[x] + g[x + 1];
}
int Y4(int x){
    return x * (x - 1) / 2 + S1[x] + f[x];
}
D slope1(int a, int b){
    return 1.0 * (Y1(a) - Y1(b)) / (a - b);
}
D slope2(int a, int b){
    return 1.0 * (Y2(a) - Y2(b)) / (a - b);
}
D slope3(int a, int b){
    return 1.0 * (Y3(a) - Y3(b)) / (a - b);
}
D slope4(int a, int b){
    return 1.0 * (Y4(a) - Y4(b)) / (a - b);
}
void solve(int l, int r){
    if(l == r){ h[l] = max(h[l], f[l - 1] + g[l + 1] + 1 - T[l]); return;}
    solve(l, mid), solve(mid + 1, r);
    st[top = 1] = mid + 1;
    rep(i, mid + 2, r){
        while(top > 1 && slope3(st[top], st[top - 1]) < slope3(st[top - 1], i)) --top;
        st[++top] = i;
    }
    rep(i, l - 1, mid - 1){
        while(top > 1 && i > slope3(st[top], st[top - 1])) --top;
        t[i] = f[i] + (st[top] - i + 1) * (st[top] - i) / 2 + g[st[top] + 1] - S1[st[top]] + S1[i];
    }
    mx[l - 1] = -inf;
    rep(i, l, mid) mx[i] = max(mx[i - 1], t[i - 1]), h[i] = max(h[i], mx[i]);
    st[top = 1] = l - 1;
    rep(i, l, mid - 1){
        while(top > 1 && slope4(st[top], st[top - 1]) < slope4(st[top - 1], i)) --top;
        st[++top] = i;
    }
    rep(i, mid + 1, r){
        while(top > 1 && i > slope4(st[top], st[top - 1])) --top;
        t[i] = g[i + 1] + (i - st[top] + 1) * (i - st[top]) / 2 + f[st[top]] - S1[i] + S1[st[top]];
    }
    mx[r + 1] = -inf;
    dep(i, mid + 1, r) mx[i] = max(mx[i + 1], t[i]), h[i] = max(h[i], mx[i]);
}
signed main(){
    n = read();
    rep(i, 1, n) T[i] = read(), S1[i] = S1[i - 1] + T[i], h[i] = -inf;
    dep(i, 1, n) S2[n - i + 1] = S2[n - i] + T[i];
    st[++top] = 0;
    rep(i, 1, n){
        while(top > 1 && i > slope1(st[top], st[top - 1])) --top;
        f[i] = max(f[i - 1], f[st[top]] + (i - st[top] + 1) * (i - st[top]) / 2 + S1[st[top]] - S1[i]);
        while(top > 1 && slope1(st[top], st[top - 1]) < slope1(st[top - 1], i)) --top;
        st[++top] = i;
    }
    st[top = 1] = 0;
    rep(i, 1, n){
        while(top > 1 && i > slope2(st[top], st[top - 1])) --top;
        g[i] = max(g[i - 1], g[st[top]] + (i - st[top] + 1) * (i - st[top]) / 2 + S2[st[top]] - S2[i]);
        while(top > 1 && slope2(st[top], st[top - 1]) < slope2(st[top - 1], i)) --top;
        st[++top] = i;
    }
    reverse(g + 1, g + n + 1);
    solve(1, n);
    m = read();
    while(m--) P = read(), X = read(), printf("%lld\n", max(f[P - 1] + g[P + 1], h[P] + T[P] - X));
    return 0;
}


Measured memory_bytes: 22460
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}



signed main() {
	int k, a, b, mu=0;
	cin >> k >> a >> b;
	if (a + 2 >= b || a>=k) {
		cout << k + 1 << endl;
		ggr
	}
	int ta = k;
	ta -= (a - 1);
	mu += ((ta / 2)*(b - a - 2));
	cout << k + 1 + mu << endl;
}


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

int main() {
	// your code goes here
	int test;
	scanf("%d",&test);
	
	int value;
	scanf("%d",&value);
	
	int sum=0;
	int count = 1;
	

	for(int i=1; i<=test; i++){
		
		int val;
		scanf("%d",&val);
		
		sum=sum+val;
		if(sum<=value){
			
			count=count+1;
		}
		
		
	}
	
	printf("%d",count);
	
	return 0;
}

Measured memory_bytes: 256