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

int main(){
    ll mod = pow(10,9) + 7;
    ll n,a[3];
    cin >> n;
    rep(i,3){
        a[i] = 1;
        ll N = n;
        ll b = 10 - i;
        while(N>0){
            if(N&1) a[i] = a[i]*b%mod;
            b = b*b%mod;
            N >>= 1;
        }
    }
    ll ans = (a[0] - 2*a[1] + a[2])%mod;
    if(ans<0) ans += mod;
    cout << ans << endl; 
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define Timewarp ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD2 998244353
#define MOD 1000000007
#define cns(z) cout<<z<<' '
#define cnl(z) cout<<z<<'\n'
#define int long long
#define pb push_back
#define xp first
#define yp second
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define rdp(i,a,b) for(i=(a);i>=(b);i--)
#define lb(v,z) lower_bound(all(v),z)
#define ub(v,z) upper_bound(all(v),z)
#define fill(a,z) memset(a,z,sizeof(a))
#define INF 4000000000000000000
#define MAXN 200001
using namespace std;
using namespace __gnu_pbds;

vector<int> adj[MAXN];
int a[MAXN];
int ans[MAXN];
multiset<int> s;

void dfs(int i,int p){
    s.insert(a[i]);
    auto it=s.lower_bound(a[i]);
    it++;
    int num=-1;
    if(it!=s.end()) {
        num=*it;
        s.erase(it);
    }
    ans[i]=s.size();
    for(auto e:adj[i]){
        if(e!=p) dfs(e,i);
    }
    s.erase(s.find(a[i]));
    if(num!=-1) s.insert(num);
}

signed main(){

    int i,j,k,l,n,x,y,r;
    cin>>n;
    rep(i,1,n) cin>>a[i];
    rep(i,1,n-1){
        cin>>l>>r;
        adj[l].pb(r);
        adj[r].pb(l);
    }
    dfs(1,1);
    rep(i,1,n) cnl(ans[i]);
}


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

const ll mod = ll(1e9) + 7;
const int INF = 1<<29;

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> w(n+1,0),b(n+1,0);
    for (int i=n-1;i>=0;i--){
        if (s[i]=='.') w[i] = w[i+1] + 1;
        else w[i] = w[i+1];
    }
    rep(i,n){
        if (s[i]=='#') b[i+1] = b[i] + 1;
        else b[i+1] = b[i];
    }
    int ans = INF;
    rep(i,n+1){
        ans = min(ans,w[i]+b[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
# AGC021
N = input()
ans_1 = 0
ans_2 = 0
for i in range(len(N)):
    ans_1 += int(N[i])
ans_2 = int(N[0]) - 1 + 9 * (len(N) - 1)
print(max(ans_1, ans_2))

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11415141919;
ll N, M; 

vector<vector<ll > > warshall(vector<vector<ll > > GRAPH){
    //中継点に関して
    for(ll reley = 0; reley < N; reley++){
        for(ll from = 0; from < N; from++){
            for(ll to = 0; to < N; to++){
                //中継した方がコストがかからないか否か
                //小さい順からコストが自明に決まっていく
                GRAPH[from][to] = min(GRAPH[from][to], GRAPH[from][reley] + GRAPH[reley][to]);
            }
        }
    }

    return GRAPH;
}

int main(){

    //頂点数と辺の数
    ll L;
    cin >> N >> M >> L;

    vector<vector<ll > > G;
    //L以下の頂点に辺を貼ったグラフ
    vector<vector<ll > > G2;
    G.assign(N, vector<ll >());
    G2.assign(N, vector<ll >());
    
    //初期化
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            G[i].push_back(INF);
            G2[i].push_back(INF);
        }       
    }
    //cout << G.size() << " " << G[0].size() << endl;
    //辺入力
    for(ll i = 0; i < M; i++){   
        ll u, v, w;
        cin >> u >> v >> w;
        //適宜揃える
        u--;
        v--;
        //有向か無向かでコメントアウト　多重辺も防止
        G[u][v] = min(G[u][v], w);
        G[v][u] = min(G[v][u], w);
    }

    //ワーシャルフロイド実行
    G = warshall(G);

    //もう一度グラフを作る
    //L以下の燃料でたどり着ける町同士をつなぐ(燃料を補給せずに行ける町まで)
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            if(G[i][j] <= L ){
                G2[i][j] = 1;
            }
        }
    }

    //ワーシャルフロイド実行
    G2 = warshall(G2);

    ll Q; cin >> Q;

    //確認
    vector<ll > ans;
    for(ll i = 0; i < Q; i++){
        ll s, t; cin >> s >> t;
        s--; t--;
        if(G2[s][t] == INF){
            cout << -1 << endl;
        }else{
            //最初の町へは補給無しで行けるので
            cout << G2[s][t] - 1 << endl;
        }
    }

}

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

#define F return(false);
typedef string::iterator S;

string ss;

bool mew(S& it){
    if( *it != 'm' ) F
    it++;
    if( it == ss.end() ) F
    if( *it == 'm' ){
        if( !mew(it) ) F
    }else if( it == ss.end() || *it != 'e' ) F
    it++;
    if( it == ss.end() ) F
    if( *it == 'm' ){
        if( !mew(it) ) F
    }else if( it == ss.end() || *it != 'w' ) F
    it++;
    return true;
}

int main(){
    cin >> ss;
    if( ss == "" ){
        cout << "Cat" << endl;
        return 0;
    }
    S it = ss.begin();
    bool flg = mew(it);
    if( flg && it == ss.end() ){
        cout << "Cat" << endl;
    }else{
        cout << "Rabbit" << endl;
    }
    return 0;
}

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

int N, A, B, C;
vector<int> L;
int ans = 1e9;

void dfs(vector<int> V) {
  if (V.size() == N) {
    int a = 0, b = 0, c = 0, d = 0;
    for (int i = 0; i < N; i++) {
      if (V.at(i) == 0) a += L.at(i);
      if (V.at(i) == 1) b += L.at(i);
      if (V.at(i) == 2) c += L.at(i);
      if (V.at(i) == 3) d++;
    }
    if (!a || !b || !c) return;
    int mp = ((N - d - 3) * 10 + abs(A - a) + abs(B - b) + abs(C - c));
    ans = min(ans, mp);
    return;
  }
  for (int i = 0; i <= 3; i++) {
    V.push_back(i);
    dfs(V);
    V.pop_back();
  }
}

int main() {
  cin >> N >> A >> B >> C;
  L.resize(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  vector<int> start;
  dfs(start);
  cout << ans << "\n";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    ll sum=0;
    for(ll i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 5152
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vi level,iter;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	void bfs(int s){
		level=vi(n,-1);
		queue<int>q;
		level[s]=0;
		q.push(s);
		while(!q.empty()){
			int v=q.front();q.pop();
			for(int i=0;i<G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					q.push(e.to);
				}
			}
		}
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge &e=G[v][i];
			if(level[v]>=level[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int mf(int s,int t) {//from s to t,ford_fulkerson
		int flow=0;
		while(1){
			bfs(s);
			if(level[t]<0)return flow;
			iter=vi(n);
			int f;
			while((f=dfs(s,t,inf))>0)flow+=f;
		}
	}
};
class MFL{
	public:
	MF flow;
	int S,T;
	int sum_lb;
	
	MFL(int n) : flow(n),S(n-2),T(n-1),sum_lb(0){ }
	
	void add_edge(int u,int v,int lb,int ub){
		if(u==v||ub==0)return;
		flow.add_edge(u,v,ub-lb);
		flow.add_edge(S,v,lb);
		flow.add_edge(u,T,lb);
		sum_lb+=lb;
	}
	int mfl(int s,int t){
		int S=this->S,T=this->T;
		int a=flow.mf(S,T);
		int b=flow.mf(s,T);
		int c=flow.mf(S,t);
		int d=flow.mf(s,t);
		return (a+c==sum_lb&&a+b==sum_lb)?b+d:-1;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	MFL mfl(2+n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		mfl.add_edge(a,b,0,c);
	}
	cout<<mfl.mfl(0,n-1)<<endl;
}

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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    
    while(b <= a){
          b *= 2;
          cnt++;
        }
  	while(c <= b){
          c *= 2;
          cnt++;
        }
    if(cnt <= k){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 3624
X, N = list(map(int, input().split()))
if N == 0:
    print(X)
    exit()

p = list(map(int, input().split()))

min_diff_val = X + 100
min_val = -100
for y in range(-100, 200):
    if not (y in p):
        if min_diff_val > abs(y - X):
            min_val = y
            min_diff_val = abs(y - X)
print(min_val)


Measured memory_bytes: 61848
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s, t;
int main() {
  cin >> s >> t;
  lli ss = s.size(), st = t.size();
  bool match = false;
  for (lli i=ss-st; i>=0; --i) {
    lli j = 0;
    for (; j<st; ++j) {
      if (s[i+j] != '?' && s[i+j] != t[j]) break;
    }
    if (j == st) {
      copy(begin(t), end(t), &s[i]);
      match = true;
      break;
    }
  }
  if (!match) {
    cout << "UNRESTORABLE" << endl; return 0;
  }
  for (lli i=0; i<ss; ++i) {
    if (s[i] == '?') s[i] = 'a';
  }
  cout << s << endl;
  return 0;
}


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

typedef long long ll;

int N;
std::vector<ll> A;


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



int main (void) {
  std::cin >> N;

  A.resize(N);
  for(int i=0; i<N; i++) {
    std::cin >> A[i];
  }

  std::vector<ll> memo1(N,0), memo2(N,0);
  memo1[0] = A[0];
  for(int i=1; i<N; i++){
    memo1[i] = gcd(A[i], memo1[i-1]);
  }
  memo2[N-1] = A[N-1];
  for(int i = N-2; i>=0; i--){
    memo2[i] = gcd(A[i], memo2[i+1]);
  }

  ll ans = 0;
  for(int i=0; i<N; i++){
    if ( i==0 ){
      ans = std::max(ans, memo2[1]);
      continue;
    }
    if ( i == N-1){
      ans = std::max(ans, memo1[N-2]);
      continue;
    }
    ans = std::max(ans, gcd(memo1[i-1], memo2[i+1]));
  }
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = ((int)(s)); i < (int)(n); i++)
int main(){
    int blue_card, red_card, count, max_point = 0;
    cin >> blue_card;
    vector<string> string_blue(blue_card);
    rep(i, 0, blue_card){
        cin >> string_blue.at(i);
    }
    cin >> red_card;
    vector<string> string_red(red_card);
    rep(i, 0, red_card){
        cin >> string_red.at(i);
    }
    
    rep(i, 0, blue_card){
        count = 0;
        rep(j, 0, blue_card){
            if(string_blue.at(i) == string_blue.at(j)){
                count += 1;
            }
        }
        rep(k, 0, red_card){
            if(string_blue.at(i) == string_red.at(k)){
                count -= 1;
            }
        }
        max_point = max(max_point, count);
    }
    cout << max_point << endl;
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    D, T, S = read_ints()
    if S*T >= D:
        return 'Yes'
    return 'No'


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 61808
def resolve():
    # 整数 1 つ
    k = int(input())
    s = input()
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if len(s) <= k:
        print(s)
    else:
        print(s[:k] + "...")



resolve()

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

int main(){
  int a,b,c,d,e;
  int k;
  
  cin >> a >> b >> c >> d >> e;
  cin >> k;
  
  vector<int> v = {a,b,c,d,e};
  bool ok = true;
  
  for (int i =0;i <v.size();i++)
  {
    for (int j=0;j < v.size();j++)
    {
      if(v[j]-v[i]>k){
        ok = false;
      }
    }
  }
  string ans;
  if(ok)ans="Yay!";
  else ans =":(";
  
  cout << ans <<endl;

}

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# arr = [[int(el) for el in input().split()] for i in range(n)]

a, b, c, d = map(int, input().split())

def solve(a, b, c, d):

    i = 0
    while a > 0 and c > 0:
        if i % 2 == 1:
            a -= d
        else:
            c -= b
        i += 1

        # print (a, c)

    return a > 0

ans = solve(a, b, c, d)

if ans:
    print ('Yes')
else:
    print ('No')


Measured memory_bytes: 9236
import sys

input = sys.stdin.readline


class UnionFind:
    """Union Find class.

    "Path compression" and "Union by rank" are used.

    References:
        <https://en.wikipedia.org/wiki/Disjoint-set_data_structure>
    """

    def __init__(self, N):
        self.N = N
        self.__make_set()

    def __make_set(self):
        self._parent = list(range(self.N))
        self._rank = [0] * self.N
        self._size = [1] * self.N

    def find(self, x):
        if self._parent[x] != x:
            self._parent[x] = self.find(self._parent[x])
        return self._parent[x]

    def union(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)

        if x_root == y_root:
            return

        x_rank = self._rank[x_root]
        y_rank = self._rank[y_root]
        if x_rank > y_rank:
            self._parent[y_root] = x_root
            self._size[x_root] += self._size[y_root]
        elif x_rank < y_rank:
            self._parent[x_root] = y_root
            self._size[y_root] += self._size[x_root]
        else:
            self._parent[y_root] = x_root
            self._rank[x_root] += 1
            self._size[x_root] += self._size[y_root]

    def same_set(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self._size[self.find(x)]


def main():
    N, Q = map(int, input().split())

    uf = UnionFind(N)

    ans = []
    for _ in range(Q):
        com, x, y = map(int, input().split())
        if com == 0:
            uf.union(x, y)
        else:
            ans.append(int(uf.same_set(x, y)))

    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()



Measured memory_bytes: 9448
#include<bits/stdc++.h>
# define M_PI  3.14159265358979323846
using namespace std;
int main()
{
    long long x,y,sum = 0;
    cin>>x>>y;
    while(y--)
    {
        int t; cin>>t;
        sum += t;
    }
    if(x < sum) cout<<"-1"<<endl;
    else cout<<x - sum<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define open freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
using namespace std; typedef long long ll; typedef long double ld; mt19937 rnd(time(0));

#define int ll

void solve(){
    int n, k;
    cin >> n >> k;
    cout << min(n % k, k - (n % k)) << endl;
}

signed main(){
    ios;
    // open;
    ll t = 1;
    // cin >> t;
    cout.precision(16);
    while(t--){
        solve();
    }
    return 0;
}

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

int main(void) {
  string num;
  cin >> num;
  
  vector<int> v(num.size());
  int a = num.at(0) - '0';
  rep(i, num.size() - 1)
    v.at(i) = num.at(i + 1) - '0';
  
  long long total = 0;
  for (int tmp = 0; tmp < (1 << (num.size() - 1)); tmp++) {
    bitset<9> s(tmp);
    
    long long sum = a;
    rep(i, num.size() - 1) {    
      if (s.test(i)) {
        total += sum;
        sum = v.at(i);
      }
      else
        sum = sum * 10 + v.at(i);
    }
    total += sum;
  }
  
  cout << total << endl;
  
  return 0;
}

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

using namespace std;

using ll = long long;

const int P = (int)3e3 + 5;
int p, b[P], fact[P], invFact[P], pw[P][P];

int add(int _a, int _b) {
    _a += _b;
    if (_a >= p) _a -= p;
    return _a;
}
int mul(int _a, int _b) { return (int)( (ll)_a * _b % p); }

int binPow(int _a, int _m) {
    int ret = 1;
    for (; _m; _m >>= 1, _a = mul(_a, _a) ) if (_m & 1) ret = mul(ret, _a);
    return ret;
}

int C(int _n, int _k) { return mul(fact[_n], mul(invFact[_k], invFact[_n - _k]) ); }

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

    fact[0] = 1; for (int i = 1; i < p; ++i) fact[i] = mul(fact[i - 1], i);
    invFact[p - 1] = binPow(fact[p - 1], p - 2);
    for (int i = p - 2; i >= 0; --i) invFact[i] = mul(invFact[i + 1], i + 1);

    for (int i = 0; i < p; ++i) {
        pw[i][0] = 1;
        for (int j = 1; j < p; ++j) pw[i][j] = mul(pw[i][j - 1], i);
    }

    for (int i = 0; i < p; ++i) {
        int a; scanf("%d", &a);
        if (!a) continue ;

        if (!i) {
            b[0] = add(b[0], 1);
            b[p - 1] = add(b[p - 1], p - 1);
            continue ;
        }

        for (int j = 0; j < p; ++j) {
            b[j] = add(b[j], mul(pw[p - i][p - 1 - j], p - C(p - 1, j) ) );
            if (!j) b[j] = add(b[j], 1);
        }
    }

    for (int i = 0; i < p; ++i) printf("%d ", b[i]);

    return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n;
    vector < pll > pq;
    ll i;
    cin>>n;
    FOR0(i, n)
    {
        ll a, b; 
        cin>>a>>b;
        pq.push_back(mp(b, a));
    }
    sort(pq.begin(), pq.end());
    ll curtime = 0;
    bool is = true;
    FOR0(i, n)
    {
        ll deadline = pq[i].ff;
        ll duration = pq[i].ss;
        if(curtime + duration <= deadline)
            curtime += duration;
        else 
        {
            is = false;
            break;
        }
    }
    if(is)
        cout<<"Yes";
    else cout<<"No";
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 6256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    int ret = 10000;
    chmin(ret, p + q);
    chmin(ret, q + r);
    chmin(ret, r + p);
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	int n, ans = 1, h[20], m;
	cin >> n;
	FOR(i, n)cin >> h[i];
	m = h[0];
	FOR(i, n - 1) {
		if (m <= h[i + 1]) {
			ans++;
			m = h[i + 1];
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
    int N,K;
    cin>>N>>K;
    vector<long long>A(N);
    for(auto &i:A)
    cin>>i;
    vector<long long>dp(N,0);
    dp[0]=0;
    for(int i=1;i<N;i++)
    {
        long long z=LLONG_MAX;
        for(int j=1;j<=K;j++)
        {
            if(i>=j)
            z=min(z,abs(A[i]-A[i-j])+dp[i-j]);
        }
        dp[i]=z;
    }
    cout<<dp[N-1]<<endl;
}

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

int main(){
    bool A=1;
    vector<int> vec(26, 0);
    while (A){
        string s;
        cin >> s;
        if (s=="") {A=0;}
        
        for(int i=0; i<s.size(); i++){
            if (65<=s.at(i) && s.at(i)<=90) {vec.at(s.at(i)-65)++;}
            else if (97<=s.at(i) && s.at(i)<=122) {vec.at(s.at(i)-97)++;}
        }
    }

    for (int i=0; i<26; i++){
        char index=i+97;
        cout << index << " : " << vec.at(i) << endl;
    }
}


Measured memory_bytes: 3216
""" AtCoder """

N = int(input())
ans_list = [2, 4, 8, 16, 32, 64]
ans_list = ans_list[::-1]

if N == 1:
    print(1)
    exit()

for i in range(7):
    if N >= ans_list[i]:
        print(ans_list[i])
        break


Measured memory_bytes: 2940
#include <cstring>
#include <cstdio>
int lst[100005], to[200005], pre[200005], tot;
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u];
	lst[u] = tot++;
}
int dfs(int u, int fa = -1)
{
	int res = 0;
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] != fa)
			res ^= dfs(to[i], u) + 1;
	}
	return res;
}
int main()
{
	// freopen("AGC017-D.in", "r", stdin);
	memset(lst, -1, sizeof(lst));
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v);
		add_edge(--u, --v);
		add_edge(v, u);
	}
	puts(dfs(0) ? "Alice" : "Bob");
	return 0;
}


Measured memory_bytes: 6784
n = int(input())
a = list(map(int,input().split()))

ans = 0
up = 0
down = 0
i=0

while (i+1)<n:
    if up == down:
        if a[i+1] > a[i]:
            up += 1
            down = 0
        elif a[i+1] < a[i]:
            up = 0
            down += 1
        else:
            up += 1
            down += 1
    elif up == 0 and down !=0:
        if a[i+1] <= a[i]:
            down += 1
        else:
            ans += 1
            down = 0
    elif down == 0 and up!= 0:
        if a[i+1] >= a[i]:
            up += 1
        else:
            ans += 1
            up = 0
    i += 1

print(ans+1)

Measured memory_bytes: 20468
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i=0;i<N;i++) {
        cin >> S.at(i);
    }
    
    bool Y = false;
    for (int i=0;i<N;i++) {
        if(S.at(i) == "Y") {
            Y = true;
            break;
        }
    }
    if (Y == true) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskB {
private:
	Debugger debugger;

	bool ok;
	void rec(int red, int green, int blue, int k) {
		if (green > red && blue > green) {
			ok = true;
		}
		if(k == 0) {
			return;
		}
		rec(red*2, green, blue, k-1);
		rec(red, green*2, blue, k-1);
		rec(red, green, blue*2, k-1);
	}

public:
	void solveOne(int it){
		int red, green, blue;
		cin >> red >> green >> blue;
		int k;
		cin >> k;
		ok = false;
		rec(red, green, blue, k);
		cout << (ok ? "Yes":"No") << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


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

int main()
{
    int H,N;
    int A[100000];
    cin >> H >> N;
    for(int i=0; i<N; i++)
        cin >> A[i];

    for(int j=0; j<N; j++)
    {
        H = H - A[j];
    }

    if(H <= 0)
        cout << "Yes";
    else
        cout << "No";
    

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

int n;
LL ai[200005];

int main(){
	cin >> n;
	REP(i, 1, n) cin >> ai[i];
	REP(i, 1, n) ai[i] += ai[i - 1];
	LL ans = 1ll << 60;
	REP(i, 1, n - 1) if (abs(ai[n] - ai[i] - ai[i]) < ans) ans = abs(ai[n] - ai[i] - ai[i]);
	cout << ans << endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    long long A[N + 1], B[N];
    for (int i = 0; i < N+1; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }

    long long ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(B[i] < A[i]){
            ans += B[i];
        }
        else if(B[i] < A[i] + A[i+1]) {
            ans += B[i];
            A[i+1] -= B[i] - A[i];
        }
        else {
            ans += A[i] + A[i+1];
            A[i+1] = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int64_t a;
  long double b;
  cin >> a >> b;
  int64_t ans = (int64_t)a*b;
  cout << ans << endl;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string S; cin >> S;
    int ans = 0;
    REP(i, SZ(S)){
        int j = SZ(S) - i - 1;
        if(i < j && S[i] != S[j]) ans++;
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    li n,t,ans=0;
    cin>>n>>t;
    vi a(n);
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        if(a[i+1]-a[i]>=t) ans+=t;
        else ans+=a[i+1]-a[i];
    }
    ans+=t;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long total = 0;
		Pair[] pairs = new Pair[n];
		for (int i = 0; i < n; i++) {
		    pairs[i] = new Pair(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(pairs);
		for (int i = 0; i < n; i++) {
		    total += pairs[i].b;
		    if (total >= k) {
		        System.out.println(pairs[i].a);
		        return;
		    }
		}
	}
	
	static class Pair implements Comparable<Pair> {
	    int a;
	    int b;
	    public Pair(int a, int b) {
	        this.a = a;
	        this.b = b;
	    }
	    
	    public int compareTo(Pair another) {
	        return a - another.a;
	    }
	}
}


Measured memory_bytes: 89380
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, m;
    int i;
    priority_queue<int> a;
    ll ans = 0;

    cin >> n >> m;

    for (i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a.push(x);
    }

    for (i = 0; i < m; i++)
    {
        int k = a.top();

        a.pop();
        a.push(k / 2);
    }

    for (i = 0; i < n; i++)
    {
        ans += a.top();
        a.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 892
def cross(a, b):
  return a.real * b.imag - a.imag*b.real

def convex_hull(p):
  pp = sorted(p, key=lambda x:(x.imag, x.real))
  n = len(pp)
  ans, j = [0] * (n+1), 0
  for i in range(n):
    while j > 1 and cross(ans[j-1] - ans[j-2], pp[i]-ans[j-1]) < 0:
      j -= 1
    ans[j] = pp[i]
    j += 1
  k = j

  for i in range(n-2, -1, -1):
    while j > k and cross(ans[j-1]-ans[j-2], pp[i]-ans[j-1]) < 0:
      j -= 1
    ans[j] = pp[i]
    j +=1
  return ans[0:j-1]

n = int(input())
p=[]
for i in range(n):
  x,y = list(map(int, input().split()))
  p.append(complex(x,y))
ans = convex_hull(p)
print(len(ans))

for i in ans:
  print(int(i.real), int(i.imag))



Measured memory_bytes: 22948
n=int(input())
def f(a,b,c,d):
    return lambda x:a*x**3+b*x**2+c*x+d
for i in range(n):
    a,b,c,d=map(int,input().split())
    fx=f(a,b,c,d)
    D=b**2-3*a*c
    if D<=0 :
        if d==0:
            pl=mi=0
        elif (a>0 and d<0) or (a<0 and d>0):
            pl,mi=1,0
        elif (a<0 and d<0) or (a>0 and d>0):
            pl,mi=0,1
    else:
        if a>0:
            al=(-b-D**0.5)/(3*a)
            be=(-b+D**0.5)/(3*a)
            if (fx(al)<0 or fx(be)>0) and d==0:
                pl=mi=0
            elif ((fx(al)<0 or fx(be)>0) and d>0) or (fx(be)==0 and d==0 and be==0):
                pl,mi=0,1
            elif (fx(al)==0 or (fx(al)>0 and fx(be)<0)) and d==0 and be<0:
                pl,mi=0,2
            elif (fx(al)==0 or fx(be)==0 or (fx(al)>0 and fx(be)<0)) and d>0 and be<0:
                pl,mi=0,3
            elif ((fx(al)<0 or fx(be)>0) and d<0) or (fx(al)==0 and d==0 and al==0):
                pl,mi=1,0
            elif fx(al)>0 and fx(be)<0 and d==0 and al<0 and be>0:
                pl=mi=1
            elif (fx(al)==0 or (fx(al)>0 and fx(be)<0)) and d<0 and al<0:
                pl,mi=1,2
            elif (fx(be)==0 or (fx(al)>0 and fx(be)<0)) and d==0 and al>0:
                pl,mi=2,0
            elif (fx(be)==0 or (fx(al)>0 and fx(be)<0)) and d>0 and be>0:
                pl,mi=2,1
            elif ((fx(al)==0 and al>0) or fx(be)==0 or (fx(al)>0 and fx(be)<0 and al>0)) and d<0:
                pl,mi=3,0
        else:
            al=(-b+D**0.5)/(3*a)
            be=(-b-D**0.5)/(3*a)
            if (fx(al)>0 or fx(be)<0) and d==0:
                pl=mi=0
            elif ((fx(al)>0 or fx(be)<0) and d<0) or (fx(be)==0 and d==0 and be==0):
                pl,mi=0,1
            elif (fx(al)==0 or (fx(al)<0 and fx(be)>0)) and d==0 and be<0:
                pl,mi=0,2
            elif (fx(al)==0 or fx(be)==0 or (fx(al)<0 and fx(be)>0)) and d<0 and be<0:
                pl,mi=0,3
            elif ((fx(al)>0 or fx(be)<0) and d>0) or (fx(al)==0 and d==0 and al==0):
                pl,mi=1,0
            elif fx(al)<0 and fx(be)>0 and d==0 and al<0 and be>0:
                pl=mi=1
            elif (fx(al)==0 or (fx(al)<0 and fx(be)>0)) and d>0 and al<0:
                pl,mi=1,2
            elif (fx(be)==0 or (fx(al)<0 and fx(be)>0)) and d==0 and al>0:
                pl,mi=2,0
            elif (fx(be)==0 or (fx(al)<0 and fx(be)>0)) and d<0 and be>0:
                pl,mi=2,1
            elif (fx(al)==0 or fx(be)==0 or (fx(al)<0 and fx(be)>0)) and d>0 and al>0:
                pl,mi=3,0
    print(pl,mi)


Measured memory_bytes: 5824
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,d,c=0,f=1;
  cin>>n>>d;
  while(f<=n)
  {
    f=f+2*d;
    f++;
    c++;
  }
  cout<<c;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

void solve()
{
	string s,t;
	cin>>s;
	cin>>t;
	bool ok = true;
	int n1=s.length(), n2=t.length();
	if (n1+1!=n2) {
		cout << "No\n";
		return;
	}
	for (int i=0; i<n1; i++) {
		if (s[i]!=t[i]) {
			ok = false;
			break;
		}
	}
	if (ok) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

int main()
{
	fastIO;
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
int n;
vector<vector<int>> graph;
vector<bool> visited;
int dfs(int cur){
    int ans = 0;
    visited[cur] = true;
    REP(i, n){
        if(visited[i] == false){
            break;
        }
        if (i == n - 1){
            visited[cur] = false;
            return 1;
        }
    }
    for (int i = 0; i < graph[cur].size(); i++){
        if (visited[graph[cur][i]] == true){
            continue;
        }
        ans += dfs(graph[cur][i]);
    }
    visited[cur] = false;
    return ans;
}

signed main() {
    int m;
    cin >> n >> m;
    graph.resize(n);
    visited.resize(n);
    REP(i, m){
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }
    cout << dfs(0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int s, ans = 0;	
	scanf("%d", &s);
	
	for(int i = 5;i >= 0;i --){
		int com = 1;
		for(int j = 0;j < i;j ++)
			com *= 10;
		
		if(s >= com){
			ans ++;	
			s -= com;
		}
	}
	
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            sum += Integer.parseInt(String.valueOf(c[i]));
        }
        if (Integer.parseInt(str) % sum == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int aoki_atk = (a + d - 1) / d;
  Yes(aoki_atk * b >= c);
}


Measured memory_bytes: 3136
n = int(input())
data = [[-1 for _ in range(n)] for _ in range(n)]
for i in range(n):
    reps = int(input())
    for _ in range(reps):
        x, y = list(map(int, input().split(' ')))
        x -= 1
        data[i][x] = y

# print(data)

ans = 0
for i in range(pow(2, n)):
    nat = [0 for _ in range(n)]
    for idx in range(n):
        bit = (i >> idx) & 1
        nat[idx] = bit

    # print(nat)

    # vertification
    ok = True
    for user, row in enumerate(data):
        if not nat[user]:
            continue
        for idx in range(n):
            if row[idx] != -1:
                if nat[idx] != row[idx]:
                    ok = False

    if ok: 
        ans = max(ans, sum(nat))

print(ans)


Measured memory_bytes: 45148
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    //freopen("E:\\Codes\\Problem\\C++\\AAA.txt", "r", stdin);
    //freopen("C:\\Users\\Dell\\Desktop\\Problem\\BBB.txt", "w", stdout);
	
	int n,t;
	cin>>n>>t;
	
	string str[n],ans;
	for(int i=0 ; i<n ; i++)
	{
		cin>>str[i];
	}
	
	sort(str,str+n);
	
	for(auto it:str){
		ans+=it;
	}
	
	cout<<ans;
}



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

int main() {
    int n;
    cin >> n;
    string color;
    cin >> color;
    vector<int> a(n);
    int r = 0;
    int w = 0;
    for (int i = 0; i < n; i++) {
        if (color[i] == 'W') {
            a.at(i) = 1;
            w++;
        }
    }   
    r = n - w;

    ll sum = 0;
    for (int i = 0; i < r; i++) {
        if (a.at(i) == 1) {
            sum++;
        }
    } 
    cout << sum << endl;
     
    


    return 0;
}

Measured memory_bytes: 4424
from collections import Counter

n = int(input())
s = [x for x in input()]
c = Counter(s)
for _ in range(n-1):
   s = [x for x in input()]
   d = Counter(s)
   for k in c.keys():
      c[k] = min(c[k], d[k])

c = sorted(c.items(), key=lambda x:x[0])
ans = ''
for k, v in c:
   ans += v * k
print(ans)


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

int solve(const string& n, int i) {
    if (n.size() - 1 == i) {
        return n.back() - '0';
    }
    if (n[i] == '0') {
        return solve(n, i + 1);
    }
    int size = n.size();
    return max(n[i] - '0' + solve(n, i + 1), n[i] - '0' - 1 + 9 * (size - i - 1));
}

int main() {
    string n;
    cin >> n;
    cout << solve(n, 0);
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int H, W, K; cin >> H >> W >> K;
	vector<string> S(H); cin >> S;

	int B = (1<<(H-1));	
	int ans = INF;
	for (int bit = 0; bit < B; bit++) {
		int size = __builtin_popcount(bit) + 1;
		vint num(size, 0);
		int data = size-1;
		bool muri = false;
		for (int j = 0; j < W; j++) {
			int cnt = 0;
			vint now(size, 0);
			for (int i = 0; i < H; i++) {
				now[cnt] += (int)(S[i][j] == '1');
				if (i < H-1 && ((bit>>i)&1)) cnt++;
			}
			for (int i = 0; i < size; i++) {
				if (num[i] + now[i] > K) {
					data++;
					num.assign(size, 0);
					break;
				}
			}
			for (int i = 0; i < size; i++) {
				if (now[i] > K) { muri = true; break; }
				num[i] += now[i];
			}
			if (muri) break;
		}
		if (!muri) chmin(ans, data);
	}

	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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


int main ()
{

int n;
cin >> n;
int arr[n];


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

bool flag=false;

for(int i=0;i<n;i++)
{
	flag=true;
 for(int j=0;j<i;j++)
 {
 	if(arr[j]>arr[i])
 	{
		flag=false;
		break;
	}

 }
if(flag)
{
	 count++;
}
}

cout << count << endl;

 	return 0;
}












Measured memory_bytes: 3592