akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

ll k,s,t,n;

class UnionFind {
private:
    int sz;
    vector<int> par, nrank;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), nrank(sz, 0){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
    	if(nrank[x] < nrank[y]) swap(x,y);
        par[y] = x;
        if(nrank[x] == nrank[y]) nrank[x]++;
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};

vector<vector<int> > g;
bool flag[100001];
bool black[100001];
int dfs(int id,bool b){
	black[id] = b;
	flag[id] = 1;
	int p = 0;
	for(auto x:g[id]){
		if(flag[x]){
			if(black[x]==black[id])p = 1;
		}else{
			p = max(p,dfs(x,!b));
		}
	}
	return p;
}
int main(){
	int m;
	cin >> n >> m;
	g.resize(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rep(i,n){
		if(g[i].size()==0){
			t++;
		}else if(!flag[i]){
			int x = dfs(i,0);
			if(x==0){
				k++;
			}else{
				s++;
			}
		}
	}
	//cerr << k << " " << s << " " << t << endl;
	cout << 2*k*k+2*k*s+s*s+2*t*(n-t)+t*t << endl;
	return 0;
}

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

int N, M, K;
vector<vector<int>> blk;
vector<unordered_set<int>> adj;

class DisjointSet {
public:
  int N, num;
  vector<int> parent, rank, count;
  DisjointSet(int n): N(n), num(n), parent(n), rank(n), count(n,1) {
    iota(parent.begin(), parent.end(), 0);
  }

  int find(int x) {
    return parent[x] = (parent[x] == x ? x : find(parent[x]));
  }

  int cnt(int x) {
    return count[find(x)];
  }

  void uni(int a, int b) {
    a = find(a);
    b = find(b);
    if(a == b) return;
    if(rank[a] > rank[b]) swap(a,b);
    parent[a] = b;
    if(rank[a] == rank[b]) rank[b]++;
    count[b] += count[a];
    count[a] = 0;
    num--;
  }
};

int main() {
  int a, b;
  scanf("%d %d %d", &N, &M, &K);
  DisjointSet dset(N+1);
  adj.resize(N+1);
  blk.resize(N+1);
  for(int i = 0; i < M; i++) {
    scanf("%d %d", &a, &b);
    adj[a].insert(b);
    adj[b].insert(a);
    dset.uni(a,b);
  }
  for(int i = 0; i < K; i++) {
    scanf("%d %d", &a, &b);
    if(dset.find(b) == dset.find(a)) {
      if(adj[a].count(b) == 0) {
        blk[a].push_back(b);
        blk[b].push_back(a);
      }
    }
  }

  for(int i = 1; i <= N; i++) {
    printf("%d ", (dset.cnt(i) - 1 - adj[i].size() - blk[i].size()));
  }
}





Measured memory_bytes: 23040
import java.util.Scanner;

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

		String word = sc.next();
		StringBuilder sb = new StringBuilder();
		while (!word.equals("-")) {
			int m = sc.nextInt();
			String shuffleWord;
			sb.append(word);
			for (int i = 0; i < m; i++) {
				int h = sc.nextInt();
				shuffleWord = sb.substring(0, h);
				sb.delete(0, h);
				sb.append(shuffleWord);
			}
			System.out.println(sb.toString());
			sb.setLength(0);
			word = sc.next();
		}
	}
}


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

using namespace std;

#define sz(a) ((int)a.size())
#define pb push_back

int n;
vector<int> has[3];
vector<int> has3, ans;

int main() {
    // freopen("inp.txt", "r", stdin);

    cin >> n;

    for (int i = 0; i < 15000; i++) {
        int rem = (i + 1) * 2 % 3;
        has[rem].pb((i + 1) * 2);
        if (3 * (2 * i + 1) <= 30000) has3.pb(3 * (2 * i + 1));
    }

    if (n == 3) {
        cout << "2 5 63";
        return 0;
    }

    ans.pb(has[1].back());
    has[1].pop_back();
    ans.pb(has[2].back());
    has[2].pop_back();

    int cur = 0;
    while (sz(ans) < n - 1) {
        if (cur + 1 >= sz(has3)) break;
        ans.pb(has3[cur++]);
        ans.pb(has3[cur++]);
    }


    while (sz(ans) < n - 1) {
        if (has[1].empty()) break;
        ans.pb(has[1].back());
        has[1].pop_back();
        ans.pb(has[2].back());
        has[2].pop_back();
    }

    while (sz(ans) < n) {
        if (has[0].empty()) break;
        ans.pb(has[0].back());
        has[0].pop_back();
    }

    assert(sz(ans) == n);
    for (int i = 0; i < sz(ans); i++) {
        cout << ans[i] << ' ';
    }

    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
ll n;
int main(){
    scanf("%lld",&n);
    auto cal=[&](int x){
        for(int i=1;;i++){
            if(i*(i+1)/2>x)return i-1;
        }
    };
    int ans=0;
    for(int i=2;1ll*i*i<=n;i++){
        if(n%i)continue;
        int c=0;
        while(n%i==0)n/=i,c++;
        ans+=cal(c);
    }
    if(n!=1)ans+=cal(1);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3832
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int my_abs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    string ans = "Yes";
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    for (int j = 0; j < N-1; j++) {
        if (S.at(j).back() != S.at(j + 1).at(0)) {
            ans = "No";
        }
    }
    for (int k = 0; k < N; k++) {
        for (int l = 0; l < N; l++) {
            if (k == l) {
                continue;
            }
            if (S.at(k) == S.at(l)) {
                ans = "No";
                break;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;
//int t[10010];

int main()
{

    string s;
    cin >> s;
    int n = s.size();

    int target = 753;
    int now = 0;
    int ans = target;
    REP(i, n)
    {
        int t = 100 * (s[i] - '0') + 10 * (s[i + 1] - '0') + s[i + 2] - '0';
        //Cout(t);
        now = abs(target - t);
        ans = min(now, ans);

        if (i >= n - 3)
            break;
    }
    Cout(ans);

    return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#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__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=57;
ll mod;

int n=50;

ll pot[nax][nax];

ll wyn;

void ff()
{
	fflush(stdout);
}

int pyt(int a, int b, int x, int y)
{
	printf("? %d %d %d %d\n", a, x, b, y);
	ff();
	int v;
	scanf("%d", &v);
	return v;
}

int los(int a, int b)
{
	return (rand()%(b-a+1))+a;
}

void szuk(int a, int b, int x, int y, int w)
{
	if (!w)
		return;
	if (a==b && x==y)
	{
		wyn+=pot[a][x];
		return;
	}
	if (a!=b)
	{
		int s=(a+b)>>1;
		//~ int s=los(a, b-1);
		int p=pyt(a, s, x, y);
		szuk(a, s, x, y, p);
		szuk(s+1, b, x, y, w-p);
	}
	else
	{
		int s=(x+y)>>1;
		//~ int s=los(x, y-1);
		int p=pyt(a, b, x, s);
		szuk(a, b, x, s, p);
		szuk(a, b, s+1, y, w-p);
	}
}

int main()
{
	int szit;
	scanf("%d%d%d%lld", &szit, &szit, &szit, &mod);
	ll trz=1;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			pot[i][j]=trz;
			trz=(trz*2)%mod;
		}
	}
	szuk(0, n-1, 0, n-1, 250);
	printf("! %lld\n", wyn%mod);
	ff();
	return 0;
}


Measured memory_bytes: 720
//AtCoder ABC092 A - Traveling Budget
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    auto ans=min(A,B)+min(C,D);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  long long K;
  cin >> N >> K;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    A[i]--;
  }
  
  
  int loop = 0;
  int start = 0; 
  bool Seen[N];
  for(int i=0;i<N;i++) Seen[i]=false;
  Seen[0]=true;
  vector<int> B;
  B.push_back(0);
  int arriveat=0;
  
  for(int i=0;i<N;i++){
    loop++;
    arriveat = A[arriveat];
    if(!Seen[arriveat]){
      Seen[arriveat] = true;
      B.push_back(arriveat);
    }
    else{
      start = arriveat;
      break;
    }
  }
  
  int lpfirst;
  int lpnum;
  for(int i=0;i<loop;i++){
    if(B.at(i)==start){
      lpnum = loop - i;
      lpfirst = i;
      break;
    }
  }
  
  if(lpfirst > K){
    cout << B.at(K)+1 << endl;
  }else{
    int res;
    res = (K - lpfirst) % lpnum;
    cout << B.at(lpfirst + res)+1 << endl;
  }
  
}


Measured memory_bytes: 5296
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 10 ** 9

if k == 1:
    for i in range(n):
        ans = min(ans, abs(x[i]))
elif n == k:
    ans = min(abs(x[0]-x[n-1]) + abs(x[n-1]), abs(x[0]) + abs(x[0] - x[n-1]))
else:
    for i in range(n-k+1):
        ans = min(ans, abs(x[i]-x[i+k-1]) + abs(x[i+k-1]), abs(x[i]) + abs(x[i] - x[i+k-1]))

print(ans)

Measured memory_bytes: 14532
using namespace std;
#include <vector>
#include <cstdio>
#include <cmath>
#define INT_MAX 2147483647

int main(){
  int N, k;
  scanf("%d %d", &N, &k);
  vector<int> hh(N);
  vector<int> DP(N);
  scanf("%d %d", &hh[0], &hh[1]);
  DP[0] = 0; DP[1] = abs(hh[1]-hh[0]);
  for(int i=2; i<N; i++){
    scanf("%d", &hh[i]);
    DP[i] = INT_MAX;
    for(int j=1; i-j>=0 && j<=k; j++)
      DP[i] = min(DP[i-j] + (int)abs(hh[i]-hh[i-j]), DP[i]);
  }
  printf("%d\n", DP[N-1]);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<long long int> v(5,0);
    int n;
    cin>>n;
    string str;
    for(int i=0;i<n;i++){
        cin>>str;
        if(str[0]=='M'){
            v[0]++;
        }
        if(str[0]=='A'){
            v[1]++;
        }
        if(str[0]=='R'){
            v[2]++;
        }
        if(str[0]=='C'){
            v[3]++;
        }
        if(str[0]=='H'){
            v[4]++;
        }
    }
    if(count(v.begin(),v.end(),0)>3){
        cout<<0<<endl;
        return 0;
    }
    long long int ans=0;
    ans+=v[0]*v[1]*v[2];
    ans+=v[0]*v[1]*v[3];
    ans+=v[0]*v[1]*v[4];
    ans+=v[0]*v[2]*v[3];
    ans+=v[0]*v[2]*v[4];
    ans+=v[0]*v[3]*v[4];
    ans+=v[1]*v[2]*v[3];
    ans+=v[1]*v[2]*v[4];
    ans+=v[1]*v[3]*v[4];
    ans+=v[2]*v[3]*v[4];
    cout<<ans<<endl;
}


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

int main(){
   string W,T;
   int i=0;

   cin >> W;
   for(int j=0; j<W.size(); j++){
	W[j] = tolower(W[j]);
   }

   while(cin >> T,T != "END_OF_TEXT"){
	for(int k=0; k<T.size(); k++){
		T[k] = tolower(T[k]);
	}
	if(T == W) i++;
   }
	cout << i << endl;
   return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(const T x, const S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

// ???????????????????¨?
template<typename T> struct SkewHeap
{
public:
  struct Node
  {
    Node *left, *right;
    T v;
    Node() : left(NULL), right(NULL) {}
    Node(T v) : left(NULL), right(NULL), v(v) {}
  }* root;
  int cnt;
  SkewHeap(T v) : root(new Node(v)), cnt(0) {}

  Node* meld(Node* l, Node* r)
  {
    if(l == NULL) return r;
    if(r == NULL) return l;
    if(l->v < r->v) swap(l, r);
    l->right = meld(l->right, r);
    swap(l->left, l->right);
    return l;
  }

  inline void push(T x)
  {
    Node* n = new Node(x);
    root = meld(root, n);
    cnt += 1;
  }

  inline void pop()
  {
    Node* n = root;
    root = meld(root->right, root->left);
    delete n;
    cnt -= 1;
  }

  inline void pop(Node* root)
  {
    Node* n = root;
    root = meld(root->right, root->left);
    delete n;
  }

  inline T top(){ return root->v; }
  inline int size(){ return cnt; }
  inline bool empty(){ return !cnt; }
};

const int MAX_N = 1000000;
int n, q;
int a, v;
int cnt[MAX_N+1];

int main()
{
  SkewHeap<pii> heap = SkewHeap<pii>(mp(-INF, -INF));

  cin >> n >> q;
  while(q--){
    cin >> a >> v;
    cnt[a] += v;
    heap.push(mp(cnt[a], -a));

    while(!heap.empty()){
      pii popop = heap.top();
      if(cnt[-popop.second] == popop.first){
        cout << -popop.second << ' ' << popop.first << endl;
        break;
      }
      heap.pop();
    }
  }

  return 0;
}

Measured memory_bytes: 8216
#include <stdio.h>
#include <algorithm>

using namespace std;

const int MAXN = 1e5 + 5;

int a[MAXN], b[MAXN], mn1 = 2000000000, mn2 = 2000000000;

int main(){
	int A, B, M, best = 2000000000;
	scanf("%d %d %d", &A, &B, &M);
	for(int i=1; i<=A; ++i){
		scanf("%d", &a[i]);
		mn1 = min(mn1, a[i]);
	}
	for(int i=1; i<=B; ++i){
		scanf("%d", &b[i]);
		mn2 = min(mn2, b[i]);
	}
	best = mn1 + mn2;
	for(int i=1; i<=M; ++i){
		int x, y, c;
		scanf("%d %d %d", &x, &y, &c);
		best = std::min(best, a[x] + b[y] - c);
	}
	printf("%d\n", best);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>

using namespace std;
const int MAX = 101;

double item[MAX][MAX];
double ans[MAX][MAX][MAX];

int n,m;

void solve(){
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < MAX; j++)
      fill(ans[i][j],ans[i][j]+MAX,1.0);

  
  for(int i = 2; i <= m; i++)
    for(int j = 0; j < n; j++)
      for(int k = 0; k < n; k++)
	for(int l = 0; l < n; l++)
	  ans[i][j][k] = max(ans[i][j][k],ans[i-1][l][j]*item[j][k]);



  double out = 0.0;

  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      out = max(out,ans[m][i][j]);
 
  printf("%.2f\n",out);
}

int main(){
  while(cin >> n >> m && n+m){

    memset(ans,0,sizeof(ans));

    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
	cin >> item[i][j];

    solve();
  }
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  if (n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 ==9){
    cout<<"hon";
  }
  if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8){
    cout<<"pon";
  }
  if (n%10 == 3){
    cout<<"bon";
  }
	return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
    int k,s,t,l;
    cin >> k >> s;
    t = 0;
    
    REP(i,k+1){
        REP(j,k+1){
            if (0<=s-i-j && s-i-j<=k) t++;
        }
    }
    
    cout << t << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b;
    while(1){
        cin>>a>>b;
        if(a==0){
            break;
        }
        for(int x=1;x<=a;x++){
            for(int y=1;y<=b;y++){
                if(x==1||y==1||x==a||y==b){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007
const int INF = 1e9+5;

int main(){
  ios_base::sync_with_stdio(false);
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
  int n,k; cin>>n>>k;
  vector<int> h(n);
  for(int &i:h)
    cin>>i;

  vector<int> dp(n,INF);
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<=i+k;j++){
      if(j<n)
        dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
    }
  }

  cout<<dp[n-1]<<"\n";
  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = vals[0];
        var m = vals[1];
        var p = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        p.Insert(0, 0);
        var link = Enumerable.Range(0, n + 1).Select(_ => new List<int>()).ToArray();
        for (int i = 0; i < m; i++)
        {
            vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            link[vals[0]].Add(vals[1]);
            link[vals[1]].Add(vals[0]);
        }

        var sets = new List<HashSet<int>>();
        var visit = new bool[n + 1];

        for (int i = 1; i <= n; i++)
        {
            if (visit[i])
            {
                continue;
            }

            var currents = new HashSet<int> { i };
            var set = new List<int> { i };
            while (currents.Count > 0)
            {
                var next = new HashSet<int>();
                foreach (var cur in currents)
                {
                    visit[cur] = true;
                }
                foreach (var cur in currents)
                {
                    next.UnionWith(link[cur].Where(x => !visit[x]));
                }

                set.AddRange(next);
                currents = next;
            }
            sets.Add(new HashSet<int>(set));
        }

        int result = 0;
        foreach (var set in sets)
        {
            var list = set.Select(i => p[i]).ToList();
            foreach (var i in list)
            {
                if (set.Contains(i))
                {
                    result++;
                }
            }
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 49836
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

char piece[10][10][10];

bool DONE = false;

typedef pair<int, int> pii;

vector<pair<pii, pii>> placement[10];

int done[10][10];

vector<pair<pii, pii>> doms;

class CDominoQuality {
public:
  bool okrow(int n, int row) {
    if (row < 0) return true;
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (!done[row][j]) continue;
      if (j == 0 || (done[row][j] != done[row][j - 1])) cnt++;
    }
    return cnt == 3;
  }

  bool okcol(int n, int col) {
    if (col < 0) return true;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (!done[i][col]) continue;
      if (i == 0 || (done[i][col] != done[i - 1][col])) cnt++;
    }
    return cnt == 3;
  }

  void dfs(int n, int p) {
    if (DONE) return;
    if (p % n == 0) {
      int row = p / n - 1;
      if (!okrow(n, row - 1)) return;
      if (p == n * n) {
        for (int i = 0; i < n; i++) {
          if (!okcol(n, i)) {
            return;
          }
        }
        placement[n] = doms;
        DONE = true;
        return;
      }
    }
    dfs(n, p + 1);
    int r = p / n, c = p % n;
    if (c < n - 1 && !done[r][c + 1] && !done[r][c]) {
      doms.push_back({{r, c}, {r, c + 1}});
      done[r][c + 1] = done[r][c] = p + 1;
      dfs(n, p + 1);
      done[r][c + 1] = done[r][c] = 0;
      doms.pop_back();
    }
    if (r < n - 1 && !done[r + 1][c] && !done[r][c]) {
      doms.push_back({{r, c}, {r + 1, c}});
      done[r + 1][c] = done[r][c] = p + 1;
      dfs(n, p + 1);
      done[r + 1][c] = done[r][c] = 0;
      doms.pop_back();
    }
  }

  void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    if (n == 2) {
      out << -1 << endl;
      return;
    }
    if (n == 3) {
      out << "aa.\n";
      out << "..b\n";
      out << "..b\n";
      return;
    }
    memset(piece, '.', sizeof piece);
    for (int i = 4; i <= 7; i++) {
      DONE = false;
      dfs(i, 0);
      for (int j = 0; j < placement[i].size(); j++) {
        auto p = placement[i][j];
        int r1 = p.first.first, c1 = p.first.second, r2 = p.second.first, c2 = p.second.second;
        piece[i][r1][c1] = piece[i][r2][c2] = j + 'a';
      }
    }
    int rep = n / 4 - 1, left = n % 4 + 4;
    vector<vector<char>> res(n, vector<char>(n, '.'));
    for (int k = 0; k < rep; k++) {
      for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
          res[k * 4 + i][k * 4 + j] = piece[4][i][j];
        }
      }
    }
    for (int i = 0; i < left; i++) {
      for (int j = 0; j < left; j++) {
        res[rep * 4 + i][rep * 4 + j] = piece[left][i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++)
      out << res[i][j];
      out << "\n";
    }
	}
};


int main() {
	CDominoQuality solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x,y,k,m;
	long long sum=0;
	scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
	if(x>y){
		k=1;m=y;
	}else{
		k=2;m=x;
	}
	sum+=m*min(a+b,2*c);
	if(k==1){
		sum+=(x-m)*min(a,c*2);
	}
	else{
		sum+=(y-m)*min(b,c*2);
	}
	printf("%d\n",sum);
	return 0;
} 

Measured memory_bytes: 256
(a, b, c) = input().rstrip().split(' ')
a = int(a)
b = int(b)
c = int(c)

if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)

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

int main()
{
    ll n, d;
    cin >> n >> d;
    vector<ll> x(n), y(n);

    rep(i, n) {
        cin >> x[i] >> y[i];
    }
    int ans = 0;
    rep(i, n) {
        if (x[i]*x[i] + y[i]*y[i] <= d*d) {
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6420
#include<complex>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long double ld;
typedef complex<ld> P;
#define X real
#define Y imag
vector<P> data;

namespace std{
  bool operator<(P a,P b){
    return a.X()!=b.X()? a.X()<b.X():a.Y()<b.Y(); 
  }
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

double dot(P a,P b){
  return real(conj(a)*b);
}

int ccw(P a,P b,P c){
  b-=a;c-=a;
  if(cross(b,c)>0)return 1;     //counter clockwise
  if(cross(b,c)<0)return -1;    //clockwise
  if(dot(b,c)<0)return 2;       //c--a--b on line
  if(norm(b)<norm(c))return -2; //a--b--c on line
  return 0;
}

int solve(){
  sort(data.begin(),data.end());
  vector<P> ch(data.size()*2);
  int k=0;
  for(int i=0;i<data.size();ch[k++]=data[i++]){
    while(k>=2 && ccw(ch[k-2],ch[k-1],data[i])<=0)--k;
  }
  for(int i=data.size()-2,t=k+1;i>=0;ch[k++]=data[i--]){
    while(k>=t&&ccw(ch[k-2],ch[k-1],data[i])<=0)--k;
  }
  ch.resize(k-1);
  return ch.size();
}


int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    data.clear();
    for(int i=0;i<n;i++){
      ld a,b;
      char c;
      cin>>a>>c>>b;
      data.push_back(P(a,b));
    }
    cout<<n-solve()<<endl;
  }
}

Measured memory_bytes: 1276
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate
import sys
import bisect
import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N = ii()
A = lmii()

buka = defaultdict(int)

for a in A:
    buka[a] += 1

for i in range(1, N+1):
    print(buka[i])

Measured memory_bytes: 54508
#include <bits/stdc++.h>
#define int long long
using namespace std;
priority_queue<pair<int, pair<int, int> > > q, q1;
const int maxn = 1e3 + 10;
int x, y, z, k, a[maxn], b[maxn], c[maxn], d[maxn * 3], ans[maxn * 3];
inline bool cmp(int x, int y) { return x > y; }
signed main() {
  scanf("%lld%lld%lld%lld", &x, &y, &z, &k);
  for (register int i = 1; i <= x; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + x + 1, cmp);
  for (register int i = 1; i <= y; i++) scanf("%lld", &b[i]);
  sort(b + 1, b + y + 1, cmp);
  for (register int i = 1; i <= z; i++) scanf("%lld", &c[i]);
  sort(c + 1, c + z + 1, cmp);
  q.push(make_pair(a[1] + b[1], make_pair(1, 1)));
  int len = min(k, x * y);
  for (register int cas = 1; cas <= len; cas++) {
    int i = q.top().second.first, j = q.top().second.second;
    d[cas] = q.top().first;
    q.pop();
    if (j < y) q.push(make_pair(a[i] + b[j + 1], make_pair(i, j + 1)));
    if (j == 1 && i < x)
      q.push(make_pair(a[i + 1] + b[j], make_pair(i + 1, j)));
  }
  q1.push(make_pair(c[1] + d[1], make_pair(1, 1)));
  for (register int cas = 1; cas <= k; cas++) {
    int i = q1.top().second.first, j = q1.top().second.second;
    ans[cas] = q1.top().first;
    q1.pop();
    if (j < len) q1.push(make_pair(c[i] + d[j + 1], make_pair(i, j + 1)));
    if (j == 1 && i < z)
      q1.push(make_pair(c[i + 1] + d[j], make_pair(i + 1, j)));
  }
  for (register int i = 1; i <= k; i++) printf("%lld\n", ans[i]);
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int flg[100000001];
int main(void)
{
	int n;
	int s;
	int i,j;
	
	scanf("%d",&n);
	for(i=2;i<=10000000;i++){
		flg[i]=0;
	}
	for(i=2;i*i<=10000000;i++){
		if(flg[i]==0){
			for(j=2;j*i<=10000000;j++){
				flg[i*j]=1;
			}
		}
	}
	while(n!=0){
		for(i=n;i>=13;i--){
			if(flg[i]==0 && flg[i-2]==0 && flg[i-6]==0 && flg[i-8]==0){
		//		printf("%d\n",i);
				s=i;
				printf("%d\n",s);
				break;
			}
		}
		
		scanf("%d",&n);
	}
		return 0;
}

Measured memory_bytes: 41556
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ");
        var N = int.Parse(input[0]);
        var M = int.Parse(input[1]);

        var graph = new List<List<int>>();
        var distBase = new List<int>();

        for (int i = 0; i <= N; i++)
        {
            graph.Add(new List<int>());
            distBase.Add(-1);
        }

        for (int i = 0; i < M; i++)
        {
            var line = Console.ReadLine().Split(" ");
            var A = int.Parse(line[0]);
            var B = int.Parse(line[1]);

            graph[A].Add(B);
            graph[B].Add(A);
        }

        var dist = new List<int>(distBase);
        var prev = new List<int>(distBase);
        var queue = new Queue<int>();
        var start = 1;
        dist[start] = 0;
        queue.Enqueue(start);

        while (queue.Count != 0)
        {
            var v = queue.Dequeue();
            foreach (var nv in graph[v])
            {
                if (dist[nv] != -1) continue;

                dist[nv] = dist[v] + 1;
                prev[nv] = v;

                queue.Enqueue(nv);
            }
        }

        if (prev.Count(x => x != -1) != N - 1)
        {
            Console.WriteLine("No");
        }
        else
        {
            Console.WriteLine("Yes");
            for(int i = 2; i <= N; i++)
            {
                Console.WriteLine(prev[i]);

            }
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
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, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

template<int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(i64 a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (i64) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt operator-() { return ModInt(-this->x); }
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  #define op(o) bool operator o(ModInt that) const { return x o that.x; }
    op(==) op(!=) op(<) op(<=) op(>) op(>=)
  #undef op
};

using mint = ModInt<1000000007>;

void solve() {
  int N, M; cin >> N >> M;
  if (abs(N - M) > 1) {
    cout << 0 << '\n';
    return;
  }
  if (abs(N - M) == 0) {
    mint a = 1;
    reps(i, N) a *= i;
    cout << power(a, 2) * 2 << '\n';
  } else {
    // 1
    mint a = 1, b = 1;
    reps(i, N) a *= i;
    reps(i, M) b *= i;
    cout << a * b << '\n';
  }
}


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

vector<long long> convert2num(vector<string> A);
bool is_contained(int M, int dx, int dy, const vector<long long> &A, const vector<long long> &B);

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N, "");
    vector<string> B(M, "");
    for (auto & s : A) cin >> s;
    for (auto & s : B) cin >> s;
    auto A01 = convert2num(A);
    auto B01 = convert2num(B);
    for (int dx = 0; dx <= N - M; ++dx){
        for (int dy = 0; dy <= N - M; ++dy){
            if (is_contained(M, dx, dy, A01, B01)){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

vector<long long> convert2num(vector<string> A){
    vector<long long> A01;
    for (const auto &s : A){
        long long val = 0;
        for (const auto c : s){
            val <<= 1;
            if (c == '#') ++val;
        }
        A01.push_back(val);
    }
    return A01;
}

bool is_contained(int M, int dx, int dy, const vector<long long> &A, const vector<long long> &B){
    long long mask = (1LL << (M + dy)) - 1LL;
    for (const auto b : B){
        if (b != ((A[dx++] & mask) >> dy)) return false;
    }
    return true;
}

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

ll n, arr[MAXN];

void solve()
{
	cin>>n;
	ll xorr=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		xorr^=arr[i];
	}
	for(ll i=0;i<n;i++) cout<<(xorr^arr[i])<<" ";
	cout<<endl;
}

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

Measured memory_bytes: 5196
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int v[1000010];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        char c;
        cin >> c;
        a[i] = c - '0';
    }
    if (n == 2) {
        cout << abs(a[0] - a[1]) << endl;
        return 0;
    }
    rep(i, n - 1) a[i] = abs(a[i + 1] - a[i]);
    
    rep2(i, 2, n) {
        v[i] = v[i - 1];
        int ni = i;
        while (~ni & 1) {
            ni /= 2;
            v[i]++;
        }
    }
    // C(N-2,i) mod 2
    auto comb = [&](int i) {
        int now = v[n - 2];
        now -= v[i];
        now -= v[n - 2 - i];
        assert(now >= 0);
        if (now > 0) return 0;
        else return 1;
    };
    
    int sum;
    int cnt = 0;
    rep(i, n - 1) if (a[i] == 1) {
        sum += comb(i);
        cnt++;
    }
    sum %= 2;
    if (sum == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (cnt > 0) {
        cout << 0 << endl;
        return 0;
    }
    rep(i, n - 1) a[i] /= 2;
    sum = 0;
    rep(i, n - 1) if (a[i] == 1) sum += comb(i);
    sum %= 2;
    cout << sum * 2 << endl;
}

Measured memory_bytes: 11116
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const int Nmaxx = 1e5 + 5;

vector<vii> g(Nmaxx);
vector<ll> ans(Nmaxx);

void dfs(int u, int p, bool color)
{
	for(ii b : g[u])
	{
		if(b.first == p )
			continue;
		ans[b.first] = (int)((!(b.second&1))?color:!color);
		dfs(b.first,u,ans[b.first]);
	}
}

int main()
{
	int n; cin>>n;
	for(int i = 1; i <n ; i++)
	{
		ll a,b,w; cin>>a>>b>>w;
		g[a].push_back({b,w});
		g[b].push_back({a,w});
	}
	dfs(1,0,false);
	for(int i = 1; i <=n ;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 11008
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = 100 + 10;
char s[maxn];

int read() {
  if (scanf("%s", s) < 1) {
    return 0;
  }
  return 1;
}

void solve() {
  int n = (int) strlen(s);
  char q[] = "CF";
  int pos = 0;
  for (int i = 0; i < n; ++i) {
    if (q[pos] == s[i]) {
      ++pos;
      if (pos == 2) {
        printf("Yes\n");
        return;
      }
    }
  }
  printf("No\n");
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pair<int,int>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e2+10;

int main(int argc,const char** argv){

	fastio;

	ll n,k,ans;

	cin >> n >> k;

	ans = min(n - (n/k * k),(n/k*k + k) - n);

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1;rrp(i,n-r+1,n+1){ans*=i;ans%=mod;}return ans/=fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 char s[300000];
 sc(s);
 ll len=strlen(s);
 vector<ll>l,r;
 map<ll,ll>map;

 rep(i,0,len-1){
  if(s[i]=='R'&&s[i+1]=='L'){
   push(r,i);push(l,i+1);
  }
  //cout<<i<<" "<<distance(all(l))<<endl;
 }

 ll cnt=0,tmp=0;
 //rが偶数回移動したときの場所を求める
 rep(i,0,len){
  while(s[i]=='R'&&i<len){
   cnt++;i++;
  }
  if(cnt!=0){
   map[r[tmp]]+=cei(cnt,2);
   map[l[tmp]]+=cnt/2;
   cnt=0;tmp++;
  }
 }
 //rep(i,0,len)pr(map[i]);pnn;
 //lが偶数回移動したときの場所を求める
 tmp=distance(all(l))-1;
 rrp(i,len,0){
  while(s[i]=='L'&&i>=0){
   cnt++;i--;
  }
  if(cnt!=0){
   map[l[tmp]]+=cei(cnt,2);
   map[r[tmp]]+=cnt/2;
   cnt=0;tmp--;
  }
 }
 rep(i,0,len)cout<<map[i]<<" ";pnn;
return 0;}


Measured memory_bytes: 10316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll n,m;
	priority_queue<pair<ll,ll>>moto;
	priority_queue<ll>q;
	cin>>n>>m;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		x*=-1;
		moto.push(make_pair(x,y));
	}
	ll ans=0;
	for(ll i=1;i<=m;i++){
		bool ch=true;
		while(ch&&moto.size()!=0){
			ch=false;
			ll nexd=moto.top().first;
			ll nexy=moto.top().second;
			nexd*=-1;
			if(nexd<=i){
				moto.pop();
				q.push(nexy);
				ch=true;
			}
		}
		if(q.size()!=0){
		ans+=q.top();
		q.pop();
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include<cstdio>
#include <cstring>
#include <map>
#define maxn 3000000+5
using namespace std;
const long long mod = 200907;
int main()
{
    int n1,n2,n3,n4;
    scanf("%d%d%d%d",&n1,&n2,&n3,&n4);
    map<int,int>m;
    m[n1]++,m[n2]++,m[n3]++,m[n4]++;
    if(m[1]&&m[9]&&m[7]&&m[4]){
        printf("YES\n");
    }
    else printf("NO\n");


    return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;

int main(){
  int x, a;
  cin >> x >> a;
  if (x < a) cout << 0 << endl;
  else cout << 10 << endl;
  
}


Measured memory_bytes: 256
from collections import deque

n,m=map(int,input().split())
g=[[]for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

mark=[-1]*n
mark[0]=0
check=[0]*n
check[0]=1

que=deque()
que.append(0)

while que:
    p=que.popleft()
    for i in g[p]:
        if check[i]:
            continue
        check[i]=1
        mark[i]=p+1
        que.append(i)

if -1 in mark:
    print("No")
else:
    print("Yes")
    print(*mark[1:],sep="\n")

Measured memory_bytes: 97180
n = int(input())
a = list(map(int,input().split()))
check = 0
counter = 0
for k in range(30):
	for i in range(n):
		if a[i] %2 == 1:
			check += 1
	if check == 0:
		counter += 1
		for i in range(n):
			a[i] = a[i]/2
	else:
		break
print(counter)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n; cin >> n;
    vl a(n),ans(n);
    rep(i,n){
        cin >> a[i];
        ans[a[i]-1] = i+1;
    }
    rep(i,n) cout << ans[i] << " ";
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
//=============================
void input()
{
    cin>>N;
}
//=============================
void func(){}
//=============================
void solve()
{
    int ans = 0;
    for (int i = 1; i<=N; i += 2){
        int yks = 0;
        for(int j = 1; j <= i; ++j){
            if (i%j==0)yks++;
        }
        if (yks==8)ans++;
    }

    cout<<ans<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256