akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int n, Q, qu, y, z, iq, lq, rq;
    char cq;
    string S;
    cin >> n >> S >> Q;
    vector<set<int>> st(26);
    rep(i, n) {
        st[S[i] - 'a'].insert(i + 1);
    }
    rep(i, 26) st[i].insert(n + 1);
    rep(i, Q) {
        cin >> qu;
        if (qu == 1) {
            cin >> iq >> cq;
            st[S[iq - 1] - 'a'].erase(iq);
            st[cq - 'a'].insert(iq);
            S[iq - 1] = cq;
        } else {
            cin >> lq >> rq;
            int ans = 0;
            rep(j, 26) {
                auto l = st[j].lower_bound(lq);
                auto r = st[j].lower_bound(rq + 1);
                //cout << *l - st[j].begin() << endl;
                //int r = st[j].lower_bound(rq + 1);
                if (*l < *r) ans++;
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 24196
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"
#define N 200005
vector<int> a,ans,g[N];
int n;

void dfs(int u,int parent,vector<int> &v)
{
	int m=v.size(),x=-1,prev;
	if(m==0 || v[m-1]<a[u])
		v.pb(a[u]);
	else
	{
		x=lower_bound(v.begin(),v.end(),a[u])-v.begin();
		prev=v[x];
		v[x]=a[u];
	}
	ans[u]=v.size();
	for(auto vv:g[u])
	{
		if(vv==parent)	continue;
		dfs(vv,u,v);
	}
	if(x==-1)	v.pop_back();
	else	v[x]=prev;
}

void solve()
{
	cin>>n;
	ans=a=vector<int> (n);
	int i,x,y;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=1;i<n;i++)
	{
		cin>>x>>y;
		x--,y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	vector<int> v;
	dfs(0,0,v);
	for(i=0;i<n;i++)
		cout<<ans[i]<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	while(t--)	solve();
	return 0;
}

Measured memory_bytes: 30028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    private static final BufferedReader READER = new BufferedReader(new InputStreamReader(System.in));

    private static int getInt() {
        try {
            return Integer.parseInt(READER.readLine());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static int[] getIntArr(int n) {
        int[] ans = new int[n];

        StringTokenizer stringTokenizer = null;
        try {
            stringTokenizer = new StringTokenizer(READER.readLine(), " ");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < n && stringTokenizer.hasMoreTokens(); i++) {
            ans[i] = Integer.parseInt(stringTokenizer.nextToken());
        }

        return ans;
    }

    private static int solve() {
        int n = getInt();
        if (n == 0) {
            return 0;
        }
        int[] hs = getIntArr(n);
        return solveInternal(n, hs);
    }

    private static int solveInternal(int n, int[] hs) {
        if (n <= 3) {
            return hs[n - 1] - hs[0];
        }

        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(hs[1] - hs[0]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i - 1] + Math.abs(hs[i] - hs[i - 1]), dp[i - 2] + Math.abs(hs[i] - hs[i - 2]));
        }

//        for (int i = 0; i < dp.length; i++) {
//            System.out.println(dp[i]);
//        }
        return dp[n - 1];
    }

    public static void main(String... args) {
        System.out.println(solve());
//        System.out.println(solveInternal(6, new int[]{30, 10, 60, 10, 60, 50}));
    }
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  int cur = 0,now = 0;
  for(int i = 0;i < m;i++){
    cin >> a.at(i) >> b.at(i);
    if(a.at(i) == 1){
      cur++;
    }
    else if(b.at(i) == n){
      now++;
    }
  }
  vector<int> start(cur);
  vector<int> goal(now);
  int c = 0,d = 0;
  int k = 0,ok = 0;
  if(cur != 0 || now != 0){
    for(int i = 0;i < m;i++){
      if(a.at(i) == 1){
        start.at(c) = b.at(i);
        c++;
      }
      else if(b.at(i) == n){
        goal.at(d) = a.at(i);
        d++;
      }
    }
    sort(goal.begin(),goal.end());
    for(int i = 0;i < cur;i++){
      k = lower_bound(goal.begin(),goal.end(),start.at(i)) - goal.begin();
      if(k < now){
        if(goal.at(k) == start.at(i)){
          ok++;
          break;
        }
      }
    }
  }
  if(ok != 0){
    cout << "POSSIBLE" << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define ri rd<int>
using namespace std;
const int maxN = 2e3 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

inline int gcd(int x, int y) { while (y) swap(x %= y, y); return x; }

int n, a[maxN];
bool vis[maxN];
int deg[maxN];
int ans[maxN], tt;

struct vec {
	static const int maxE = maxN * maxN;
	int g[maxN], te;
	struct edge {int y, nxt;} e[maxE << 1];
	inline void push(int x, int y) { e[++te] = (edge){y, g[x]}; g[x] = te; }
	inline void link(int x, int y) { push(x, y), push(y, x); }
	inline int& operator () (int x) { return g[x]; }
	inline edge& operator [] (int x) { return e[x]; }
}e, G;
int bac[maxN];

void dfs(int x) {
	vis[x] = 1;
	fore (e, x, y) if (!vis[y]) { // from small to big
		dfs(y);
		G.push(x, y);
		++ deg[y];
	}
} 

void topu() {
	static priority_queue<int, vector<int>, less<int> > q;
	q.push(0);
	while (!q.empty()) {
		int x = q.top(); q.pop();
		if (x) ans[++tt] = a[x];
		fore (G, x, y) if (-- deg[y] == 0) q.push(y);
	}
	rep (i, 1, tt) printf("%d%c", ans[i], " \n"[i == tt]);
}

int main() {

	n = ri(); rep (i, 1, n) a[i] = ri();
	sort(a+1, a+n+1);
	rep (i, 1, n) per (j, n, 1) if (gcd(a[i], a[j]) != 1) e.push(i, j);
	per (i, n, 1) e.link(0, i);

	dfs(0);
	topu();

	return 0;
}

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

int main(){

    int n,k,d,a;
    cin>>n>>k;
    int *list=new int[n];
    
    for(int i=0;i<k;i++){
        cin>>d;
        for(int j=0;j<d;j++){
            cin>>a;
            list[a-1]=1;
        }
    }
    int count=0;
    for(int i=0;i<n;i++){
        if(list[i]==0)count++;
    }
    cout<<count<<endl;

  return 0;
}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split()))

def how_many_times_divisible_of_two(N):
    exp = 0
    while N % 2 == 0:
        N //= 2
        exp += 1
    return exp

result = min([how_many_times_divisible_of_two(v) for v in A])
print(result)

Measured memory_bytes: 9096
def check(S, l):
    idx = {}
    for i in range(len(S)-l+1):
        x = S[i:i+l]
        if x not in idx:
            idx[x] = i
        else:
            if idx[x]+l <= i:
                return True
    return False


def main():
    N = int(input())
    S = input()
    lo = 0
    hi = N//2
    while lo < hi:
        mid = -(-(lo+hi)//2)
        if check(S, mid):
            lo = mid
        else:
            hi = mid - 1
    print(lo)


if __name__ == "__main__":
    main()


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

// Dinic O(|E||V|^2)
template <typename T, bool directed>
class Dinic
{
public:
  Dinic(int n) : n(n), capacity(n, vector<T>(n)) {}
  void add_edge(int src, int dst, T cap)
  {
    capacity[src][dst] = cap;
    capacity[dst][src] = directed ? 0 : cap;
  }

  T max_flow(int s, int t)
  {
    T flow = 0;
    while (bfs(s, t))
    {
      start.assign(n, 0);
      flow += dfs(t, s, numeric_limits<T>::max());
    }
    return flow;
  }

private:
  int n;
  vector<int> level, start;
  vector<vector<T>> capacity;
  bool bfs(int s, int t)
  {
    level.assign(n, -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty())
    {
      int v = que.front();
      que.pop();
      for (int nv = 0; nv < n; ++nv)
        if (capacity[v][nv] > 0 && level[nv] < 0)
        {
          level[nv] = level[v] + 1;
          que.push(nv);
        }
    }
    return level[t] != -1;
  }

  T dfs(int v, int s, T limit)
  {
    if (v == s)
      return limit;

    T res = 0;
    for (int &nv = start[v]; nv < n; ++nv)
    {
      if (capacity[nv][v] > 0 && level[v] == level[nv] + 1)
      {
        T d = dfs(nv, s, min(limit, capacity[nv][v]));
        if (d > 0)
        {
          capacity[nv][v] -= d;
          capacity[v][nv] += d;
          res += d;
          limit -= d;
          if (limit == 0)
            break;
        }
      }
    }
    return res;
  }
};

int main()
{
  int X, Y, E, x, y;
  cin >> X >> Y >> E;
  Dinic<int, true> dn(X + Y + 2);
  int S = X + Y, T = X + Y + 1;
  for (int i = 0; i < E; ++i)
  {
    cin >> x >> y;
    dn.add_edge(x, X + y, 1);
  }
  for (int i = 0; i < X; ++i)
    dn.add_edge(S, i, 1);
  for (int i = 0; i < Y; ++i)
    dn.add_edge(X + i, T, 1);
  cout << dn.max_flow(S, T) << endl;
  return 0;
}


Measured memory_bytes: 3276
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int N = sc.nextInt();
		int t[] = new int[N + 1];
		int x[] = new int[N + 1];
		int y[] = new int[N + 1];
		t[0] = 0;
		x[0] = 0;
		y[0] = 0;
		for (int i = 1; i < N + 1; i++) {
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		String ans = "Yes";
		int dt = 0;
		int dx = 0;
		int dy = 0;
		int chk = 0;

		for (int i = 0; i < N; i++) {
			dt = t[i + 1] - t[i];
			dx = x[i + 1] - x[i];
			dy = y[i + 1] - y[i];
			chk = dt - (dx + dy);

			if (!(chk >= 0 && chk % 2 == 0)) {
				ans = "No";
				break;
			}
		}

		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 90160
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    int ans = 0;
    int cnt = n - 1;
    rep(i, n) {
        if(i == 0) {
            ans += a[i];
            -- cnt;
            continue;
        }
        if(cnt >= 2) {
            cnt -= 2;
            ans += 2 * a[i];
        } else if(cnt == 1) {
            cnt = 0;
            ans += a[i];
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll A[N], B[N]; rep(i,N) cin >> A[i] >> B[i];

  map<p_ll, ll> ab, rab;
  ll zab = 0, za = 0, zb = 0;
  rep(i,N) {
    if (A[i]==0&&B[i]==0) zab++;
    else if (A[i]==0) za++;
    else if (B[i]==0) zb++;
    else {
      ll gab = gcd(abs(A[i]), abs(B[i]));
      A[i] /= gab; B[i] /= gab;
      if (B[i]<0) ab[make_pair(-1*A[i], -1*B[i])]++;
      else ab[make_pair(A[i], B[i])]++;
      if (A[i]<0) rab[make_pair(B[i], -1*A[i])]++;
      else rab[make_pair(-1*B[i], A[i])]++;
    }
  }

  ll p2[N+1] = {}; rep(i,N+1) p2[i] = i==0 ? 1 : p2[i-1]*2%MOD;
  ll result = 1;
  for (auto x: ab) {
    if (rab.count(x.first)) {
      if (x.first.first<0) continue;
      result = result * (p2[x.second]+p2[rab[x.first]]-1) % MOD;
    }
    else {
      result = result * p2[x.second] % MOD;
    }
  }
  result = result * (p2[za]+p2[zb]-1) % MOD;
  result = (result+zab) % MOD;
  result = (result-1+MOD) % MOD;

  cout << result << endl;
  return 0;
}

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

class UnionFind{
    private:
        vector<int> par;

    public:
        UnionFind(int n) : par(n){
            for(int i=0; i<n; i++){
                par.at(i) = i;
            }
        }

        int root(int x){
            if(par.at(x) == x){
                return x;
            }else{
                return par.at(x) = root(par.at(x));
            }
        }

        void unite(int x, int y){
            int rx = root(x), ry = root(y);
            if(rx != ry){
                par.at(rx) = ry;
            }
        }

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

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

    vector<int> vec(n);
    UnionFind tree(n);

    for(int i=0; i<n; i++){
        cin >> vec.at(i);
    }

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

    int ans = 0;

    for(int i=0; i<n; i++){
        if(tree.same(i, vec.at(i)-1)){
            ans++;
        }
    }

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

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int	w;
	while (scanf("%d", &w) != EOF)
	{
		vector<int> v;
		for (int i = 0; i < 10; ++i)
		{
			if (w & 1 << i)
				v.push_back(1<<i);
		}
		for (int i = 0; i < v.size()-1; ++i)
			printf("%d ", v[i]);
		printf("%d\n", v[v.size()-1]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  int n, m, cnt = 0, i, sum = 0;
  double x;
  cin>>n>>m;
  int a[n];
  for(i = 0; i<n ; i++)
  {
      cin>>a[i];
      sum+=a[i];
  }
  x = sum/(4.0*m);
  //cout<<x<<endl;
  for(i = 0; i<n; i++)
  {   //cout<<a[i]<<endl;
      if(a[i]>= x)
      {
          cnt++;
          //cout<<cnt<<endl;
      }
      if(cnt == m)
      {
          cout<<"Yes"<<endl;
          return 0;
      }
  }

  cout<<"No"<<endl;




return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,k; cin >> n >> k;
	ll left=0,right=k+1;
	while(right-left>1){
		ll mid=(left+right)/2;
		ll sum=0;
		ll cp=n;
		ll pp=mid;
		while(pp&&cp){
			sum+=pp;
			pp/=2;
			cp--;
		}
		if(sum<=k){
			left=mid;
		}
		else{
			right=mid;
		}
	}
	cout << left << endl;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, ans = 0;
    cin >> n;
    string s;
    set<string> st;
    map<string,ll> tmp;
    REP(i, n){
        cin >> s;
        sort(ALL(s));
        auto r = st.insert(s);
        if(r.second == false){
            ans += tmp[s];
            tmp[s]++;
        }
        else tmp[s] = 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 19120
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int a,b,c,d,e,f,g = 0;
  int aa,bb,cc,dd,ee;
  int ans = 0;
  cin >> a >> b >> c >> d >> e;
  aa = a % 10; 
  if(aa == 0){
    ans += a;
    a = 0;
  }
  bb = b % 10; 
  if(bb == 0){
    ans += b;
    b = 0;
  }
  cc = c % 10; 
  if(cc == 0){
    ans += c;
    c = 0;
  }
  dd = d % 10; 
  if(dd == 0){
    ans += d;
    d = 0;
  }
  ee = e % 10; 
  if(ee == 0){
    ans += e;
    e = 0;
  }
  
  f = min({(aa+9)%10,(bb+9)%10,(cc+9)%10,(dd+9)%10,(ee+9)%10});
  f++;
 
  if(aa == f){
    ans += (a+b+c+d+e);
    ans += ((10-bb)%10+(10-cc)%10+(10-dd)%10+(10-ee)%10);
  }
  else if(bb == f){
    ans += (a+b+c+d+e);
    ans += ((10-aa)%10+(10-cc)%10+(10-dd)%10+(10-ee)%10);
  }
  else if(cc == f){
    ans += (a+b+c+d+e);
    ans += ((10-aa)%10+(10-bb)%10+(10-dd)%10+(10-ee)%10);
  }
  else if(dd == f){
    ans += (a+b+c+d+e);
    ans += ((10-aa)%10+(10-bb)%10+(10-cc)%10+(10-ee)%10);
  }
  else if(ee == f){
    ans += (a+b+c+d+e);
    ans += ((10-aa)%10+(10-bb)%10+(10-cc)%10+(10-dd)%10);
  }  
  cout << ans << endl;
}


Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
	fastio();
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a+b)
	{
		cout<<min(a,k)<<endl;
	}
	else
	{
		cout<<a-(k-(a+b));
	}
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int n,m; cin >> n >> m;
  vector< vector<int> > s(m,vector<int>(n,0));

  for(int i=0;i<m;i++) {
    int k; cin >> k;
    for(int j=0;j<k;j++) {
      int l; cin >> l;
      s[i][l-1] = 1;
    }
  }

  vector<int> p(m); for(int i=0;i<m;i++) { cin >> p[i]; }

  lint cnt=0, ans=0;
  for(int bit=0;bit<(1<<n);bit++) {

    int check = 1;
    for(int i=0;i<m;i++) {

      lint sum=0;
      for(int j=0;j<n;j++) {
        if(bit & (1<<j)) { sum += s[i][j]; } // switch on
      } // for each switch

      if(sum%2 != p[i]) { check *= 0; }

    } // for each lamp

    ans += check;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if ((A * B * 1) % 2 == 1 || (A * B * 2) % 2 == 1 || (A * B * 3) % 2 == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 764
n = int(input())
graph = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a - 1].append((b - 1, i))
    graph[b - 1].append((a - 1, i))
ans = [0] * (n - 1)

from collections import deque

d = deque()
d.append([0, -1])
while d:
    point, prev = d.popleft()
    color = 1 if prev != 1 else 2
    for a, index in graph[point]:
        if ans[index] == 0:
            ans[index] = color
            d.append([a, color])
            color += 1 if prev != color + 1 else 2
print(max(ans))
print(*ans, sep='\n')

Measured memory_bytes: 41948
#include<stdio.h>
int main()
{
    long long int n;

    scanf("%lld", &n);

    long long int p = n%11;

    long long int d = n / 11;

    long long int l = d*2;

    if(p!=0 && p<=6)
    {
        l++;
    }

    else if(p!=0 && p>=7)
    {
        l=l+2;
    }

    else if(p==0)
    {
        l=l;
    }

    printf("%lld", l);

    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    int n,m;
    cin >> n >> m;
    int h[n];
    int check[n];
    for(int i = 0; i < n; i++) check[i] = 1;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        if(h[a] == h[b]) check[a] = check[b] = 0;
        if(h[a] < h[b]) check[a] = 0;
        if(h[b] < h[a]) check[b] = 0;
    }
    int ans = 0;
    for(int i = 0; i < n; i++) ans += check[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4352
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
string str;
vi hoge;
vi tree[10005];
int depth[10005]={0};
void dfs(int now,int dep){
	depth[now]=dep;
	for(int i=0;i<tree[now].size();i++){
		int nex=tree[now][i];
		if(depth[nex]==0){
			dfs(nex,dep+1);
		}
	}
}
vi depinv[10005];
int ans[10005];
int main(){
	cin>>N;
	rep(i,N-1){
		int a,b;
		cin>>a>>b;a--;b--;
		tree[a].pb(b);
		tree[b].pb(a);
	}
	ll suman=0;
	rep(i,N){
		int x;
		cin>>x;
		hoge.pb(x);
	}
	sort(all(hoge));
	rep(i,N-1)suman+=hoge[i];
	dfs(0, 1);
	rep(i,N){
		//cout<<depth[i]<<endl;
		depinv[depth[i]].pb(i);
	}
	int poi=0;
	for(int d=N;d>=0;d--){
		rep(j,depinv[d].size()){
			int ver=depinv[d][j];
			ans[ver]=hoge[poi];
			poi++;
		}
	}
	cout<<suman<<endl;
	rep(i,N)cout<<ans[i]<<" ";
	cout<<endl;

}

Measured memory_bytes: 2048
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
inline char nc() {
	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
const int maxn = 1e5 + 5;
int n;
int a[maxn];
bool solve() {
	for(int i = 1; i <= n; ++i) {
		if(a[i] & 1) return 1;
	}
	return 0;
}
int main() {
	read(n);
	for(int i = 1; i <= n; ++i) {
		read(a[i]);
	}
	puts(solve() ? "first" : "second");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)


vector<string> v;

void solve()
{
    int n, l;
    cin >> n >> l;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        v.pb(s);
    }
    
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++)
    {
        cout << v[i];
    }
    //cout << "\n";
}



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    solve();
    return 0;
}

Measured memory_bytes: 888
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

const int maxn = 105;
int cn[maxn];

int32_t main(){
    int n, mx = 0;
    cin >>n;
    for(int i = 0; i < n; i ++){
        int x;
        cin >>x;
        xmax(mx, x);
        cn[x] ++;
    }
    bool ans = true;
    if(mx == 1){
        if(n > 2)
            ans = false;
    }
    else if(mx % 2){
        if(cn[(mx + 1)/ 2] != 2)
            ans = false;
        for(int i = 0; i < (mx + 1)/ 2; i ++){
            if(cn[i] > 0)
                ans = false;
        }
        for(int i = (mx + 1)/ 2 + 1; i <= mx; i ++){
            if(cn[i] < 2)
                ans = false;
        }
    }
    else{
        if(cn[mx/ 2] != 1)
            ans = false;
        for(int i = 0; i < mx/ 2; i ++){
            if(cn[i] > 1)
                ans = false;
        }
        for(int i = mx/ 2 + 1; i <= mx; i ++){
            if(cn[i] < 2)
                ans = false;
        }
    }
    if(!ans)
        cout <<"Impossible" <<endl;
    else
        cout <<"Possible" <<endl;
    return false;
}


Measured memory_bytes: 256
import java.util.*;

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

    int n = scan.nextInt();

    int[][] arr = new int[n][201];
    int[] input = new int[n];
    for(int i = 0; i < n; i++) input[i] = scan.nextInt()+100;

    for(int i = 0; i < n; i++) {
      for(int j = 0; j < 201; j++) {
        int dummy = input[i]-j;
        arr[i][j] = dummy*dummy;
      }
    }

    int min = 1 << 30;
    for(int j = 0; j < 201; j++) {
      int sum = 0;
      for(int i = 0; i < n; i++) {
        sum += arr[i][j];
      }
      min = Math.min(sum,min);
    }

    System.out.println(min);
  }
}


Measured memory_bytes: 9940
a, b = input().split()

count = 0
for i in range(int(a), int(b)+1):
    flag = 1
    #print(i)
    for j in range(int(len(str(i))/2)):
        #print("{} vs {}".format(str(i)[j], str(i)[-j-1]))
        if str(i)[j]!=str(i)[-j-1]:
            flag = 0
            break
    if flag==1:
        count +=1
print(count)


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    ll w, a, b;
    cin >> w >> a >> b;

    if(a < b){
        if(a+w < b) cout << b - (a+w) << endl;
        else cout << 0 << endl;
    }
    else{
        if(b+w < a) cout << a - (b+w) << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main()
{
    int t,a[3],i,j,c=0;

    for(i=0;i<3;i++)
        scanf("%d",&a[i]);

    for(i=0;i<3;i++)
    {
        for(j=2;j>i;j--)
        {
            if(a[j]>a[j-1])
            {
                t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }

    c=(a[0]-a[1])+(a[1]-a[2]);

        printf("%d\n",c);

    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
  char ha[1<<21],k[256];
int main(int argc,char *argv[]){
  int flg;
  int val,s,t;
  char c;
  k['T'] = 1;
  k['G'] = 2;
  k['C'] = 3;
  k['A'] = 4;
   
  scanf("%d", &val);
  getchar();
  while (val--) {
    s = 0;
    t = 1;
    flg = ( c = getchar() ) == 'i';
    while ( ( c = getchar() ) != ' ' );
    while ( ( c = k[getchar()] ) != 0 ) {
      s += c * t;
      t *= 4;
    }
    if (flg) ha[s] = 1; else puts( ha[s] ? "yes" : "no" );
  }
  return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>

int main(){
	char suit[4] = {'S','H','C','D'};
	int n;
	int a;
	char c;
	int data[4][13]={0};
	int i,t;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf(" %c %d", &c, &a);
		a--;
		for(t = 0;t < 4;t++){
			if(c==suit[t]){
				data[t][a]=1;			}
		}
	}
	for(i = 0;i < 4;i++){
		for(t = 0;t < 13;t++){
			if(data[i][t]==0)printf("%c %d\n", suit[i], t + 1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10 ** 16

dp = [INF] * N
dp[0] = 0

for i in range(1, N):
    for j in range(i - 1, max(i - 1 - K, -1), -1):
        dp[i] = min(dp[i], dp[j] + abs(H[i] - H[j]))

print(dp[N - 1])


Measured memory_bytes: 52448
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,X;
  cin>>N>>M>>X;
  vector<vector<int>> A(N,vector<int>(M));
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin>>B[i];
    for(int j=0;j<M;j++)cin>>A[i][j];
  }
  int mn=10000000;
  for(int b=0;b<(1<<N);b++){
    bitset<12> C(b);
    vector<int> D(M,0);
    int cnt=0;
    for(int i=0;i<N;i++)
      if(C.test(i)){
        cnt+=B[i];
        for(int j=0;j<M;j++)
          D[j]+=A[i][j];
      }
    int c=10000000;
    for(int &i:D)
      c=min(i,c);
    if(c>=X)
      mn=min(mn,cnt);
  }
  if(mn==10000000)puts("-1");
  else cout<<mn<<endl;
}

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

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

	int n;
	cin>>n;

	string s;
	cin>>s;

	int cr=0,cw=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='W')
			cw++;
		else
			cr++;
	}

	if(cw==0||cr==0)
		cout<<0;

	else
	{
		int val=0;
		for(int i=0;i<cr;i++)
		{
			if(s[i]=='W')
				val++;
		}

		cout<<val;
	}
}

Measured memory_bytes: 3728
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>

using namespace std;

int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	if (n==1) n=15;
	if (m==1) m=15;
	if (n<m) printf("Bob");
	if (n>m) printf("Alice");
	if (n==m) printf("Draw");
	return 0;
}

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


void solve(long long N, std::vector<std::string> S){
    map<string, ll> count;
    for(const auto& x : S){
        count[x]++;
    }

    ll maxval = 0;
    for(auto it = count.begin(); it != count.end(); ++it){
        maxval = max(maxval, it->second);
    }

    for(auto it = count.begin(); it != count.end(); ++it){
        if(it->second == maxval){
            cout << it->first << endl;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 26752
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define INF 1000000000

int main() {
    int H, W, K, x1, y1, x2, y2;
    cin >> H >> W >> K >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    int cost[H][W];
    REP(i, H) {
        string s;
        cin >> s;
        REP(j, W) cost[i][j] = s[j] == '.' ? INF : -1;
    }

    cost[x1][y1] = 0;
    queue<pii> que; que.push({x1, y1});
    while (!que.empty()) {
        pii f = que.front(); que.pop();
        int h = f.first, w = f.second, nc = cost[h][w];

        FOR(i, h + 1, min(h + K + 1, H)) {
            if (cost[i][w] == INF) {
                que.push({i, w});
                cost[i][w] = nc + 1;
            }
            else if (cost[i][w] <= nc) {
                break;
            }
        }
        RFOR(i, h - 1, max(h - K - 1, -1)) {
            if (cost[i][w] == INF) {
                que.push({i, w});
                cost[i][w] = nc + 1;
            }
            else if (cost[i][w] <= nc) {
                break;
            }
        }
        FOR(i, w + 1, min(w + K + 1, W)) {
            if (cost[h][i] == INF) {
                que.push({h, i});
                cost[h][i] = nc + 1;
            }
            else if (cost[h][i] <= nc) {
                break;
            }
        }
        RFOR(i, w - 1, max(w - K - 1, -1)) {
            if (cost[h][i] == INF) {
                que.push({h, i});
                cost[h][i] = nc + 1;
            }
            else if (cost[h][i] <= nc) {
                break;
            }
        }
    }

    if (cost[x2][y2] == INF) cout << -1 << endl;
    else cout << cost[x2][y2] << endl;
    return 0;
}

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

int main()
{
	char s[4];
	cin>>s[0]>>s[1]>>s[2];
	
	if(s[0]!='a'&&s[1]!='a'&&s[2]!='a') cout<<"No"<<endl;
	else if(s[0]!='b'&&s[1]!='b'&&s[2]!='b') cout<<"No"<<endl;
	else if(s[0]!='c'&&s[1]!='c'&&s[2]!='c') cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
   // freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d);


    return 0;
}

Measured memory_bytes: 764
N, X = map(int, input().split())
donuts_cost_list = []
remain = X
for i in range(N):
    donuts_cost_list.append(int(input()))
    remain = remain-donuts_cost_list[i]

# print(donuts_cost_list)
# print(remain)

min_cost = min(donuts_cost_list)
ans , _ = divmod(remain, min_cost)
ans += N
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt=0;
    rep (i, n){
        if(s[i] == '+')cnt++;
        else cnt--;
    }
    out(cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  int f = 1;
  if(n & 1) {
    f = !a[0];
    for(int i = 1; i < n; i += 2)
      if(a[i] != a[i + 1])
        f = 0;
  } else
    for(int i = 0; i < n; i += 2)
      if(a[i] != a[i + 1])
        f = 0;
  if(f) {
    ll o = 1;
    for(int i = 0; i < n / 2; i++)
      o = o * 2 % MOD;
    cout << o << endl;
  } else
    cout << 0 << endl;
}

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

using namespace std;

#define ll long long
#define MOD 1000000007

int main()
{
	int n;
	ll p = 1;
	
	cin >> n;

	for (int i = 2; i <= n; i++) {
		p = (p * i) % MOD;
	}
	cout << p << endl;

	return (0);
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int K = int.Parse(str[1]);
        int[] A = new int[N];
        str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            A[i] = int.Parse(str[i]);
        }
        Array.Sort(A);
        int bf = 0;
        int bl = N;
        while(bf != bl){
            int bc = (bf+bl)/2;
            bool OK;
            if(bc == N || K <= A[bc]){
                OK = true;
            }
            else{
                bool[] b = new bool[K];
                b[0] = true;
                for(int i=0;i<N;i++){
                    if(i != bc){
                        for(int j=K-1;j>=A[i];j--){
                            if(b[j-A[i]]){
                                b[j] = true;
                            }
                        }
                    }
                }
                OK = false;
                for(int i=K-A[bc];i<K;i++){
                    OK |= b[i];
                }
            }
            if(OK){
                bl = bc;
            }
            else{
                bf = bc+1;
            }
        }
        sb.Append(bf+"\n");
    }
}

Measured memory_bytes: 13156
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,A,B,ans,p=1e9+7,jc[500001],ny[500001];
ll C(ll x,ll y){
	return jc[x]*ny[y]%p*ny[x-y]%p;
}
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
int main(){
	ll i,j,x,y,sz;
	scanf("%lld%lld%lld%lld",&n,&m,&A,&B);
	jc[0]=ny[0]=1;
	for(i=1;i<=n+m;i++)jc[i]=jc[i-1]*i%p;
	ny[n+m]=ksm(jc[n+m],p-2);
	for(i=n+m-1;i;i--)ny[i]=ny[i+1]*(i+1)%p;
	ans=C(n+m-2,n-1);
	for(i=1;i<=A;i++){
		x=i;y=m-B;
		sz=C(x+y-2,x-1);
		x=n-i+1;y=m-y;
		sz=sz*C(x+y-2,x-1)%p;
		ans=(ans-sz+p)%p;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5888
MODE = "stdio"
require 'matrix'
include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '4 3 90'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end


a,b,c = line[0].split(" ").map(&:to_f)
r = c*PI/180.0
h=b*sin(r)
s = a*h*0.5
d = (a**2+b**2-2*a*b*cos(r))**0.5
l = a+b+d
printf("%.10f\n%.10f\n%.10f\n",s,l,h)

Measured memory_bytes: 9560
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;

    int ans = 0;
    while (!(A == B && B == C) || ans % 2 != 0)
    {
        ans += 1;
        if (A <= B && A <= C)
        {
            A++;
        }
        else if (B <= A && B <= C)
        {
            B++;
        }
        else
        {
            C++;
        }
    }
    ans /= 2;
    cout << ans << endl;
    return (0);
}

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

void bfs(ll node, vector<bool>& seen, const vector<pair<ll, ll>>& edge, const pair<ll, ll>& remove_edge)
{
    if (seen[node - 1]) {
        return;
    }

    seen[node - 1] = true;
    for (auto&& e : edge) {
        if ((e.first != node && e.second != node)
            || (e == remove_edge)) {
            continue;
        }
        if (e.first == node) {
            bfs(e.second, seen, edge, remove_edge);
        }
        if (e.second == node) {
            bfs(e.first, seen, edge, remove_edge);
        }
    }
}

void main_()
{
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> edge;
    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        edge.emplace_back(a, b);
    }

    ll ans = 0;
    for (ll i = 0; i < M; i++) {
        vector<bool> seen(N);
        bfs(edge.front().first, seen, edge, edge[i]);
        if (!all_of(begin(seen), end(seen), [](bool s) { return s; })) {
            ans++;
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

using namespace std;

typedef long long LL;

struct edge {
	int to;
	int cost;
};

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans += a[i] - 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<p> v(n);
  vector<ll> scores(n);
  vector<vector<int>> g(n);
  rep(i, n-1){
    cin >> v[i].first >> v[i].second;
    v[i].first--, v[i].second--;
    g[v[i].first].push_back(v[i].second);
    g[v[i].second].push_back(v[i].first);

  }
  rep(i, n) cin >> scores[i];
  sort(RALL(scores));

  stack<int> st;
  st.push(0);

  vector<bool> visited(n);
  visited[0] = true;
  vector<int> ans(n);
  int cnt = 0;
  while(!st.empty()){
    int from = st.top();
    st.pop();
    visited[from] = 1;
    ans[from] = scores[cnt];
    cnt++;

    for (auto to : g[from]) {
      if(visited[to]) continue;
      st.push(to);
    }
  }

  ll res = 0;
  rep(i, n-1){
    res += min(ans[v[i].first], ans[v[i].second]);
  }

  cout << res << endl;
  rep(i, n-1) cout << ans[i] << ' ';
  cout << ans[n-1] << endl;

}


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

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

    int ans = 0;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	long long int A, B, C, K;
	cin >> A >> B >> C >> K;
	
	if(K % 2 == 0){
		cout << A - B << endl;
	}else{
		cout << B - A << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s=reader.readLine();
		int in=Integer.parseInt(s);
		int out=100000;
		for(int i=0;i<in;i++){
			out*=1.05;
			if(out%1000!=0){
				out-=out%1000;
				out+=1000;
			}
		}
		System.out.println(out);
	}
}

Measured memory_bytes: 16852