akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
      assert(n < mod);
      fact[0] = 1;
      for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
      ifact[n] = fact[n].inv();
      for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
      if (k < 0 || k > n) return 0;
      return fact[n]*ifact[k]*ifact[n-k];
    }
  };

int main () {
    int n, m; cin >> n >> m;
    V<int> p;
    int cnt = 0;
    while (m % 2 == 0) {
        m /= 2;
        cnt++;
    }
    if (cnt > 0) p.push_back(cnt);
    for (int i = 3; i*i <= m; i += 2) {
        cnt = 0;
        while (m % i == 0) {
            m /= i;
            cnt++;
        }
        if (cnt > 0) p.push_back(cnt);
    }
    if (m > 1) p.push_back(1);
    int l = p.size();
    mint ans = 1;
    combination c(1e5 + 40);
    rep(i, l) {
        ans *= c(p[i] + n - 1, p[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4812
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

l = 0
r = N-1
p = []
ans = 0
while l < r:
    p.append(A[r])
    p.append(A[l])
    r -= 1
    l += 1
if N % 2 == 1:
    p.append(A[r])

p.append(p[0])
q = []
for i in range(len(p)-1):
    q.append(abs(p[i] - p[i+1]))

ans = sum(q)-min(q)

l = 0
r = N-1
p = []
while l < r:
    p.append(A[l])
    p.append(A[r])
    r -= 1
    l += 1
if N % 2 == 1:
    p.append(A[r])

p.append(p[0])
q = []
for i in range(len(p)-1):
    q.append(abs(p[i] - p[i+1]))

print(max(ans,sum(q)-min(q)))

Measured memory_bytes: 17844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());
typedef long long ll;
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

int main()
{
  int N, K;
  cin >> N >> K;
  ll all_gcd = 1;
  ll maxA = 0;
  vector<ll> A(N);
  rep(i, N)
  {
    cin >> A[i];
    all_gcd = A[i];
    maxA = max(maxA, A[i]);
  }
  rep(i, N)
  {
    all_gcd = gcd(all_gcd, A[i]);
  }
  if (K % all_gcd == 0 && K <= maxA)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

using namespace std;

constexpr long long MOD = 1e9 + 7;
using Chars = enum {
    A, C, G, T, W, CharsCount
};

class S {
public:
    long long dp[101][CharsCount][CharsCount][CharsCount];
    long long results[101];

    constexpr S() : dp(), results() {
        dp[0][W][W][W] = 1;
        for(int i = 1; i <= 100; i++){
            for(int c1 = A; c1 <= W; c1++){
                for(int c2 = A; c2 <= W; c2++){
                    for(int c3 = A; c3 <= W; c3++){
                        if(dp[i - 1][c1][c2][c3] == 0){
                            continue;
                        }
                        for(int c0 = A; c0 <= T; c0++){
                            if(c2 == A and c1 == G and c0 == C or
                               c2 == A and c1 == C and c0 == G or
                               c2 == G and c1 == A and c0 == C or
                               c3 == A and c1 == G and c0 == C or
                               c3 == A and c2 == G and c0 == C){
                                continue;
                            }
                            else{
                                (dp[i][c0][c1][c2] += dp[i - 1][c1][c2][c3]) %= MOD;
                            }
                        }
                    }
                }
            }
        }

        for(int n = 3; n <= 100; n++){
            for(int c1 = A; c1 <= T; c1++){
                for(int c2 = A; c2 <= T; c2++){
                    for(int c3 = A; c3 <= T; c3++){
                        (results[n] += dp[n][c1][c2][c3]) %= MOD;
                    }
                }
            }
        }
    }
};


int main(){
    constexpr auto s = S();

    static_assert(s.results[3] == 61 and s.results[4] == 230 and s.results[100] == 388130742, "WA");

    int N;
    scanf("%d", &N);

    printf("%lld", s.results[N]);

    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;

    if(a==b&&b==c) cout << 1 << endl;
    else if(a==b||b==c||c==a) cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}


Measured memory_bytes: 3592
//                 _                      
//                (_)                     
// _ __ ___   __ _ _  ___  _ __ _ __ ___  
//| '_ ` _ \ / _` | |/ _ \| '__| '__/ _ \ 
//| | | | | | (_| | | (_) | |  | | | (_) |
//|_| |_| |_|\__,_| |\___/|_|  |_|  \___/ 
//               _/ |                     
//              |__/                      
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
  
typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vbl;
typedef tree<
    pll,
    null_type,
    less<pll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;

#define majorro cout.precision(20); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define forn(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define fornm(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define rfornm(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define readvec(vector, n) {ll temp_vec_val;forn(inc, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(elementvec, length_of_vector){cout << vector[elementvec] << delimeter;}}
#define printarr(arr, length, delimeter) {forn(elementarr, length){cout << arr[elementarr] << delimeter;}}
#define all(vector) (vector).begin(), (vector).end()
#define rall(vector) (vector).rbegin(), (vector).rend()
#define endl "\n"
  
struct pair_hash
{
    template <class T1, class T2>
    std::size_t operator() (const std::pair<T1, T2>& pair) const
    {
        return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
    }
};
 
const ldbl EPS = 1e-6;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const ll MOD = 3037000499;
// const ull MOD = 1000000000000000003;
const ll INF = 1e18;
const ldbl pi = 2 * acos(0.0);
ll n, m, k, p, q, t, sum = 0, cnt= 0;
ll mx = -INF;
ll mn = INF;
bool flag = 0;
vll v;
str s = "", s1, s2;
char c;
 
void bad_solve(){}

void solve() //set.merge() -> c++17
//DELET DEBUG OUTPUT!11!1
//"YES"/"NO" OUTPUT!!!!
//__builtin_popcountll() -> __popcnt64() from <intrin.h>
{
    cin >> s1 >> s2;
    n  = s1.size();
    forn(i,n)
    {
        if(s1[i]!=s2[i]) ++cnt;
    }
    cout << cnt;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("F:\\repos\\projects\\contests_vsc\\in.txt", "r", stdin);
    freopen("F:\\repos\\projects\\contests_vsc\\out.txt", "w", stdout);
#endif
    majorro
    
    solve();
  
    // freopen("test.txt", "w", stdout);
    // bad_solve();
  
//  memset(v, INT_MAX, 1000*2000*sizeof(int));
  
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  
  else
    cout << "consonant" << endl;
}

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

using namespace std;

typedef long long ll;

ll fib(int n) {
    vector<ll> memo(n + 1, 0);
    for (int i = 0; i < n + 1; i++) {
        if (i == 0 || i == 1) {
            memo[i] = 1;
        }
        else {
            memo[i] = memo[i - 1] + memo[i - 2];
        }
    }
    
    return memo[n];
}

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

    cout << fib(n) << endl;

    return 0;
}


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

using namespace std;

namespace {

    struct Edge {
        int from, to, cost;
        Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
    };

    int N;
    vector<int> C;
    vector< vector<Edge> > G;

    void input() {
        cin >> N;
        C.clear(); C.resize(N, 0);
        for (int i = 1; i < N; i++) cin >> C[i];
        G.resize(N);
        for (int i = 0; i < N - 1; i++) {
            int u, v, p; cin >> u >> v >> p;
            G[u].push_back(Edge(u, v, p));
            G[v].push_back(Edge(v, u, p));
        }
    }

    int dfs(int v, int prev, int cost) {
        if (C[v]) { return cost; }
        int ret = 0;
        for (int i = 0; i < G[v].size(); i++) {
            Edge& e = G[v][i];
            if (e.to == prev) continue;
            ret += dfs(e.to, v, e.cost);
        }
        return min(ret, cost);
    }

    void solve() {
        int ans = 0;
        for (int i = 0; i < G[0].size(); i++) {
            Edge& e = G[0][i];
            ans += dfs(e.to, 0, e.cost);
        }
        cout << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

Measured memory_bytes: 1264
#include <iostream>

using namespace std;

int main(){
  int N, i, ans=0, max;
  cin >> N;
  int H[N];
  for(i=0; i<N; i++) cin >> H[i];
  for(i=0; i<N; i++){
    if(i==0){
      max = H[i];
      ans++;
    }
    if(i != 0 && max<=H[i]){
      max = H[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

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

int main(){
int N, M, X, A;
  cin >> N >> M >> X;
int cnt = 0;
  for(int i = 0;i < N;i++){
  cin >> A;
  if(A < X) cnt++;    
  }
  
  cout << min(cnt, M - cnt) << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int c[200001], size[200001] = {};
long long ans[200001] = {};
list *adj[200001] = {}, *L[200001] = {}, d[200001] = {};

int DFS(int u)
{
	if (d[u].v != 0) return 0;
	
	int tmp;
	list *p, *q;
	d[u].v = u;
	d[u].next = L[c[u]];
	L[c[u]] = &(d[u]);
	for (p = adj[u]; p != NULL; p = p->next) {
		tmp = DFS(p->v);
		size[u] += tmp;
		for (q = L[c[u]]; q->v != u; q = q->next) tmp -= size[q->v];
		L[c[u]] = q;
		ans[c[u]] += (long long)tmp * (tmp + 1) / 2;
	}
	return ++size[u];
}

int main()
{
	int i, u, w, N;
	list e[400001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(c[i]));
	for (i = 0; i < N - 1; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	int tmp;
	list *p;
	DFS(1);
	for (i = 1; i <= N; i++) {
		tmp = N;
		for (p = L[i]; p != NULL; p = p->next) tmp -= size[p->v];
		ans[i] += (long long)tmp * (tmp + 1) / 2;
		printf("%lld\n", (long long)N * (N + 1) / 2 - ans[i]);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 29936
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,a,b;cin>>n>>a>>b;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    ll left=-1,right=1e9;
    while(right-left>1){
        ll mid=(right+left)/2;
        ll tot=0;
        rep(i,n){
            ll buf=h[i]-b*mid;
            chmax(buf,(ll)0);
            tot+=(buf+a-b-1)/(a-b);
        }
        if(tot>mid)left=mid;
        else right=mid;
    }
    cout<<right<<endl;
}

Measured memory_bytes: 4036
/* ex 9_1
   yy8332 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//スタックに格納するデータの最大数
#define SIZE 100

//スタックの定義
typedef struct stack{
  int size;
    int count;
    char data[SIZE];
    char *top;
  } stack;

//スタックの初期化
void initialize_stack(stack *stk){
  stk->count = 0;
  stk->size = SIZE;
  stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
  if(stk->count >= stk->size){
    fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
    exit(1);
  }
  else{
    stk->top--;
    *(stk->top) = elem;
    stk->count++;
  }
}

//データの取り出し
char pop(stack *stk){
  char latest;
  if(stk->count <= 0){
    fprintf(stdout, "Error: stack underflow.\n");
    exit(1);
  }
  else{
    latest = *(stk->top);
    stk->top++;
    stk->count--;
    return latest;
  }
}

int main(void){
  stack stk;
  char input[11], str1[11], str2[11];
  int len1, len2, i;
  //スタックを初期化（ポインタ渡しで関数にわたすこと）
  initialize_stack(&stk);

  //入力読み取り
  scanf("%s", &input);

  //入力文字列の長さ取得
  len1 = strlen(input);

  //入力で場合分けしてstackを操作
  for(i = 0; i < len1; i++){
    if(input[i] == 'B' && stk.count != 0){
      pop(&stk);
    }
    else if(input[i] == '0' || input[i] == '1'){
      push(&stk, input[i]);
    }
  }

  //出力文字列の長さ取得
  len2 = stk.count;

  //出力
  for(i = 0; i < len2; i++){
    str1[i] = pop(&stk);
  }
  for(i = 0; i < len2; i++){
    str2[i] = str1[(len2 - 1) - i];
  }
  str2[len2] = '\0';

  printf("%s\n", str2);

  return 0;
}


Measured memory_bytes: 1620
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

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

ll arr[100000];
ll _left[100000];
ll _right[100000];
int main() {
	cin >> N;
	rep(i, N) {
		cin >> arr[i];
	}
	_left[0] = arr[0];
	_right[N - 1] = arr[N - 1];
	rep(i, N - 1) {
		_left[i + 1] = gcd(_left[i], arr[i + 1]);
		_right[N - i - 2] = gcd(_right[N - i - 1], arr[N - i - 2]);
	}
	ll maxv = _right[1];
	rep(i, N - 2) {
		maxv = max(maxv, gcd(_left[i], _right[i + 2]));
	}
	maxv = max(maxv, _left[N - 2]);
	cout << maxv;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c; cin >> a >> b >> c;

  int ans5 = 0;
  int ans7 = 0;

  if(a == 5) ans5++;
  if(b == 5) ans5++;
  if(c == 5) ans5++;

  if(a == 7) ans7++;
  if(b == 7) ans7++;
  if(c == 7) ans7++;

  if(ans5 == 2 and ans7 == 1) YES;
  else NO;

  return 0;
}


Measured memory_bytes: 3584
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    rep(i,s.size()){
        rep(j,s.size()-i){
            string s1=s;
            s1.erase(i,j);
            if(s1=="keyence"){
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
}


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

int K, S;

int main(){
    scanf("%d%d", &K, &S);
    int cnt=0;
    for(int i=0; i<=K; i++){
        for(int j=0; j<=K; j++){
            if(0<=S-i-j && S-i-j<=K) cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

int main()
{
    long long a,b,c,k;cin>>a>>b>>c>>k;

    for(int i=0;i<k;i++)
    {
        if(b<=a)
        {
            b=(b*2);
        }
        else
        {
            if(c<=b)
                c=(c*2);
        }
    }

    if(a<b && b<c)
        cout<<"Yes"<<endl;
    else
        cout << "No" << endl;


    return 0;
}


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

int main(){
  ll N,M;

  cin >> N >> M;
  vector<bool> A(N+1,true);
  vector<ll> ct(N+1,1);
  vector<vector<ll>> g(N+1);
  ll i,j,a,b;
  for(i=1;i<=M;i++){
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<ll> q;
  for(i=1;i<=N;i++){
    if (A[i]){
      A[i] = false;
      q.push(i);
      while (q.size()>0){
        ll v = q.front();
        q.pop();
        for(j=0;j<g[v].size();j++){
          if (A[g[v][j]]){
            q.push(g[v][j]);
            A[g[v][j]] = false;
            ct[i]++;
          }
        }
      }
    }
  }
  
  ll res = 0;
  for(i=1;i<=N;i++)
    res = max(res,ct[i]);
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 18588
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+205;
void solve(){
	int n,k; 
	cin>>n>>k;
	string s; 
	cin>>s; 
	s[k-1] = tolower(s[k-1]);
	cout<<s<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = 1 << 29;
const ll INF2 = 9000000000000000000LL;
const double INF3 = 900000000000000;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()

struct edge { ll to, cap, rev; };

vector<edge>g[101000];
bool used[101000] = {0};

void add(ll from, ll to, ll cap) {
	g[from].push_back(edge { to, cap, (ll)g[to].size() });
	g[to].push_back(edge { from, (ll)0, (ll)g[from].size() - 1 });
}

ll dfs(ll v, ll t, ll f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0;i < g[v].size();i++) {
		edge &e = g[v][i];
		if (!used[e.to] && e.cap > 0) {
			ll 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;
}

ll max_flow(ll s, ll t) {
	ll flow = 0;
	for (;;) {
		fill(used, used + 20010, 0);
		ll f = dfs(s, t, INF);
		if (f == 0)return flow;
		flow += f;
	}
}


int main() {
	int H, W;
	char a[110][110];
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			for (int k = 1; k <= W; k++) {
				add((i - 1)*W + j + H*W, (i - 1)*W + k, INF);
			}
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= H; j++) {
			for (int k = 1; k <= W; k++) {
				add((i - 1)*W + k + H*W, (j - 1)*W + k, INF);
			}
		}
	}

	int s, t;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (a[i][j] == 'o') {
				add((i - 1)*W + j, (i - 1)*W + j + H*W, 1);
			}
			if (a[i][j] == 'S')s = (i - 1)*W + j + H*W;
			if (a[i][j] == 'T')t = (i - 1)*W + j;
		}
	}
	int ans = max_flow(s, t);
	if (ans >= INF)cout << -1 << endl;
	else cout << ans << endl;

}

Measured memory_bytes: 125440
/*
  AOJ 1076
  Title:Time manipulation
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <float.h>

int N,M,p[20];

int gcd(int a, int b)
{
        int c;
        while (b > 0) {
                c = a % b;
                a = b;
                b = c;
        }
        return a;
}
int lcm(int a, int b)
{
  return a/gcd(a,b)*b;
}
long long sum_baisuu(long long n,long long b)
{
  return((n+b)*((n-b)/b+1)/2);
}
int sum_kosuu(int n,int b)
{
  return(n/b);
}
int count_parity(int x)
{
  int i,b,ret;
  for(i=ret=0,b=1;i<M;i++,b<<=1)
    ret += (x&b)?1:0;
  return (ret&1)?(-1):1;
}

void solve()
{
  int i,j,lcms,kosuu_;
  long long sum_;
  double ans;

  sum_=kosuu_=0;
  for(i=0;i<(1<<M);i++)
    {
      lcms=1;
      for(j=0;j<M;j++)
	if((i & (1 << j)))
	  lcms=lcm(lcms,p[j]);
      sum_   +=count_parity(i)*sum_baisuu(N,lcms);
      kosuu_ +=count_parity(i)*sum_kosuu (N,lcms);
      
#ifdef DEBUG
      printf("p)%d\n",count_parity(i));
      printf("1)%d %d => %lld\n",N,lcms,sum_baisuu(N,lcms));
      printf("2)%d %d => %d\n",N,lcms,sum_kosuu (N,lcms));
#endif
    }
  if(sum_)
    {
      ans=(double)sum_/(double)kosuu_;
#ifdef DEBUG2
      printf("*)%lld / %d \n",sum_,kosuu_);
#endif
      printf("%lf\n",ans);
    }
  else
    printf("%lf\n",0.0);
}

main()
{
  int i,ret;
  
  while(scanf("%d %d",&N,&M)  && (N||M))
    {
      for(i=0;i<M;i++)
	scanf("%d",&p[i]);
      solve();
    }
  
  return(0);
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define pow POW
int main(){
    int n,a,b,c,d;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    LL now=a;
    for(int i = 2;i<=n;i++){
        if(now+c>b){
            now-=d;
        }
        else{
            now+=c;
        }
    }
    if(b-now<=(n-1)*(d-c)){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}
/*
7 7
1 1 4 7
1 1 2 5
1 2 6 7
1 1 5 8
1 1 3 6
1 3 7 5
0 1 6 7
d-1 2-d 3-d=d
d-1 2-d 3-d 4-d
12 02 0 1
a1 a2 a3 a4
a1-a2-a3-a4
a1-a2-a3+a4
a1-a2+a3-a4
a1-a2+a3+a4
a1-a2-a3+a4
a1-a2+a3-a4
*/
//a+a+1=10a+1
//3a+2=10a+2

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;
  int n = sz(s);
  const int M = 26;

  VV lc(M, V(1, -1));

  rep(i, n) {
    int x = s[i] - 'a';
    lc[x].push_back(i);
  }

  int ans = INF;
  for (auto &v : lc) {
    int now = 0;
    v.push_back(n);
    rep(j, sz(v)-1) chmax(now, v[j+1] - v[j] - 1);
    chmin(ans, now);
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
// const ll MOD = 1000000007;
const ll inf = 999999999999;

vector< ll > divisor(ll n) {
    vector< ll > ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
} 

int main() {
    ll n; cin >> n;
    vector<ll> v = divisor(n);
    int ans = divisor(n-1).size() - 1;
    for (int i = v.size() - 1; i > 0; i--) {
        ll tmp = n / v[i];
        while (v[i] <= tmp) {
            if (tmp % v[i]) tmp %= v[i];
            else tmp /= v[i];
        } 
        if (tmp == 1) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
//=========================================\\   
  //          @Author : SajidZakaria           \\
 //     @File Created : 2020-05-31 18:31:14     \\
//===============================================\\

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	ll n;
	cin >> n;

	ll tot = 0;
	for(int i=2; i<=sqrt(n); i++) {
		int cnt = 0;
		while(n % i == 0) n /= i, cnt++;
		ll ans = 0;
		while((ans+1)*(ans+2)/2 <= cnt) ans++;
		tot += ans;
	}

	if(n > 1) tot++;

	cout << tot << endl;
	
	return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a[n-1]-a[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc136/tasks/abc136_c
 */
public class Main {

  private static void answer(long[] hs) {
    if (hs.length <= 1) {
      System.out.println("Yes");
      return;
    }
    
    long prev = hs[0] - 1;
    for (int i = 1; i < hs.length; i++) {
      long h = hs[i];
      if (prev < h) {
        prev = h - 1;
      }
      
      if (prev > h) {
        System.out.println("No");
        return;
      }
    }

    System.out.println("Yes");
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] hs = new long[n];
    for (int i = 0; i < n; i++) {
      hs[i] = scan.nextLong();
    }
    scan.close();

    answer(hs);
  }
}


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

int main() {
	int n, m; cin >> n >> m;
	vector<vector<int>>path(n,vector<int>(n,0));
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		path[a - 1][b - 1] = 
		path[b - 1][a - 1] = 1;
	}

	vector<int>g; for (int i = 0; i < n - 1; i++)g.push_back(i + 1);
	
	int ans = 0;
	do {
		bool ok = true;
		int now = 0;
		for (int i = 0; i < n - 1; i++) {
			if (!path[now][g[i]])ok = false;
			now = g[i];
		}
		if (ok)ans++;
	} while (next_permutation(g.begin(), g.end()));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

class unionfind {
    std::vector<int> parents;
    std::vector<int> sizes;
    public:
        unionfind(int n) : parents(n), sizes(n, 1) {
            iota(begin(parents), end(parents), 0);
        }
        int root(int x) {
            if (parents[x] == x)
                return x;
            else
                return parents[x] = root(parents[x]);
        }
        bool is_same(int x, int y) {
            return root(x) == root(y);
        }
        void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx == ry)
                return;
            parents[rx] = ry;
            sizes[ry] += sizes[rx];
            sizes[rx] = 0;
        }
        // root size
        int size(int x) {
            return sizes[x];
        }
};

int main() {
    fastio;
    ll N,M,K;
    cin >> N >> M >> K;
    vector<pair<int,int>> m(M), k(K);
    map<int,set<int>> friends, blocks;
    unionfind fg(N);
    rep(i,M) {
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        m[i] = {a, b};
        friends[a].insert(b);
        friends[b].insert(a);
        fg.unite(a, b);
    }
    rep(i,K) {
        int c,d;
        cin >> c >> d;
        --c;
        --d;
        k[i] = {c, d};
        blocks[c].insert(d);
        blocks[d].insert(c);
    }
    rep(i,N) {
        ll nom = fg.size(fg.root(i));
        for (auto& f : friends[i]) {
            if (fg.is_same(i, f))
                --nom;
        }
        for (auto& b : blocks[i]) {
            if (fg.is_same(i, b))
                --nom;
        }
        --nom;
        cout << nom << " ";
    }
    cout << endl;
}


Measured memory_bytes: 44340
#include <bits/stdc++.h>
#define sc1(x) scanf("%lld",&x)
#define sc2(x,y) scanf("%lld%lld",&x,&y)
#define sc3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pb push_back
#define MX 400005
using namespace std;

typedef long long int ll;

int main()
{
    ll ok=1;
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        if(x%2==0)
        {
            if(x%3!=0&&x%5!=0)
                ok=0;
        }
    }
    if(ok)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
    return 0;
}


Measured memory_bytes: 256
import heapq

n,m = map(int,input().split())
ab=[[] for _ in range(m)]
for i in range(n):
    a,b=map(int,input().split())
    if a < m+1:
        ab[a-1].append(-b)

h=[]
ans=0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(h,j)
    if len(h)==0:
        continue
    ans+=heapq.heappop(h)*(-1)
print(ans)

Measured memory_bytes: 72608
object Main {
  def main(args: Array[String]): Unit = {
    val factor_length = io.StdIn.readInt() 
    val factors = io.StdIn.readLine.split(" ").map{_.toInt}
    var min_num = 9999999
    var count   = 0

    factors.foreach{ i =>
      if( min_num > i ) {
        count += 1
        min_num = i
      }
    }

    println( count )
  }
}

Measured memory_bytes: 54412
import           Data.List (minimumBy)
import           Data.Ord  (comparing)

main :: IO ()
main = do
  n <- readLn
  as <- take n . map read . words <$> getLine
  print $ f n as

-- foldl で書いてみたい
f :: Int -> [Int] -> Int
f n as =
  fst .
  minimumBy (comparing (abs . subtract sum' . (n *) . snd)) .
  zip [0..] $ as
  where
    sum' = sum as


Measured memory_bytes: 1020
#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; 

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)5e3+11;
ll const LG=(ll)log2(N)+1;
ll X=0,Y=0;
ll dp[N][N][2];
ll sol(vll &a,ll i,ll j,ll fl){
        if(j<i)return 0;

        ll &ans=dp[i][j][fl];
        if(ans!=-1)return ans;

        if(!fl)
                ans=max(sol(a,i+1,j,!fl)+a[i],sol(a,i,j-1,!fl)+a[j]);
        else
                ans=min(sol(a,i+1,j,!fl)-a[i],sol(a,i,j-1,!fl)-a[j]);
        return ans;

}
void solve(){
        ll i,j,k,l,n,m,x,y,z,r;

        cin>>n;
        vll a(n+2);
        for(i=1;i<=n;i++){
                cin>>a[i];
        }
        memset(dp,-1,sizeof(dp));
        cout<<sol(a,1,n,0);
        // cout<<dp[1][n][0]<<endl;



}   
int main(){
        FS;
       // #ifndef ONLINE_JUDGE
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        //#endif
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;

        if(m%2==0)return pow1((n*n)%mod,m/2,mod);

        return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
        while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
        }
        return ans;
}


Measured memory_bytes: 392832
import java.util.Scanner;
 
public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String Q = sc.next();
    String T = sc.next();
    boolean OK = false;
    int insertT =0, lenT = T.length(), lenQ = Q.length();
    for (int i = lenQ -lenT; i>=0; i--) {
      int count =0;
      for (int j = lenT - 1; j>=0; j--) {
        if (Q.charAt(i+j) == T.charAt(j) || Q.charAt(i+j) == '?' ) {
          count++;
        }
      }
      if (count == lenT) {
        OK = true;
        insertT = i;
        break;
      }
    }
    StringBuilder S = new StringBuilder(Q);
    S.replace(insertT,insertT + lenT , T);
    for (int i =0; i<Q.length(); i++) {
      if (S.charAt(i) == '?') {
        S.replace(i,i+1,"a");
      }
    }
    if (OK) {
      System.out.println(S);
    } else {
      System.out.println("UNRESTORABLE");
    }
  }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std; 
int main(){
	string P[4] = {"aabc", "ddbc", "bcaa", "bcdd"}; 
	string Q[5] = {"aabbc", "b.ddc", "bd..a", "cd..a", "caabb"}; 
	string R[6] = {"abba..", "a.ca..", "ddc.cc", "a..abb", "a..a.c", ".bbddc"}; 
	string S[7] = {".aa.aab", "a..a..b", "a..a..c", ".aa.aac", "a..a..b", "a..a..b", "bbccbb."}; 
	int N; cin >> N; 
	if(N == 2){
		cout << -1 << endl; return 0; 
	}
	else if(N == 3){
		cout << "aa." << endl; 
		cout << "..b" << endl; 
		cout << "..b" << endl; 
		return 0; 
	}
	char ans[1010][1010] = {}; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			ans[i][j] = '.'; 
		}
	}
	int q = (N - 4) / 4; int r = N - 4 * q; 
	if(r == 4){
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				ans[i][j] = P[i].at(j); 
			}
		}
	}
	if(r == 5){
		for(int i = 0; i < 5; i++){
			for(int j = 0; j < 5; j++){
				ans[i][j] = Q[i].at(j); 
			}
		}
	}
	if(r == 6){
		for(int i = 0; i < 6; i++){
			for(int j = 0; j < 6; j++){
				ans[i][j] = R[i].at(j); 
			}
		}
	}
	if(r == 7){
		for(int i = 0; i < 7; i++){
			for(int j = 0; j < 7; j++){
				ans[i][j] = S[i].at(j); 
			}
		}
	}
	for(int t = 0; t < q; t++){
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				ans[r + 4*t + i][r + 4*t + j] = P[i].at(j); 
			}
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cout << ans[i][j]; 
		}
		cout << endl; 
	}
}

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

class Program
{
	static void Main()
	{
        int N = int.Parse(Console.ReadLine());
        bool able = false;
        for (int i = 1; i <= 9; i++)
        {
            if (N % i == 0)
            {
                int m = N / i;
                if (1 <= m && m <= 9)
                {
                    able = true;
                    break;
                }
            }
        }

        if (able)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
	}

	static string[] InStrs()
	{
		return Console.ReadLine().Split(' ');
	}
	static IEnumerable<int> InInts()
	{
		return Console.ReadLine().Split(' ').Select(x => int.Parse(x));
	}
	static IEnumerable<long> InLongs()
	{
		return Console.ReadLine().Split(' ').Select(x => long.Parse(x));
	}
}

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

using namespace std;

const int INF = 1 << 29;
const pair< int, int > wait = {INF, -INF};

string S;
pair< int, int > dp[200][200];

inline void merge(pair< int, int > &s, pair< int, int > t)
{
  s.first = min(s.first, t.first);
  s.second = max(s.second, t.second);
}


pair< int, int > rec(int l, int r)
{
  if(dp[l][r] != wait) return (dp[l][r]);
  if(l == r) return (dp[l][r] = make_pair(S[l] - '0', S[l] - '0'));
  if(S[l] == '(' && r - l > 2) merge(dp[l][r], rec(l + 1, r));
  if(S[r] == ')' && r - l > 2) merge(dp[l][r], rec(l, r - 1));
  for(int i = l + 1; i < r; i++) {
    if(S[i] != '+' && S[i] != '-') continue;
    auto p = rec(l, i - 1), q = rec(i + 1, r);
    if(S[i] == '+') merge(dp[l][r], {p.first + q.first, p.second + q.second});
    else merge(dp[l][r], {p.first - q.second, p.second - q.first});
  }
  return (dp[l][r]);
}

int main()
{
  fill_n(*dp, 200 * 200, wait);
  cin >> S;
  cout << rec(0, S.size() - 1).second << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vc(n);
  vector<bool> is_push(n, false);
  int count = 0;
  
  for(int i=0; i<n; i++){
    cin >> vc[i];
  }
  
  
  int pre_b = vc[0];
  is_push[0] = true;
  count += 1;
  int b;
  do{
    if(pre_b == 2){
      cout << count << endl;
      return 0;
    } else{
      b = vc[pre_b-1];
      count += 1;
      is_push[pre_b-1] = true;
      pre_b = b;
    }
  }while(!is_push[b-1]);
  cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);
#define MAX 

void printString(ll n) 
{ 
    string s; 
    ll i = 0LL; // To store current index in str which is result 
  
    while (n > 0LL) { 
        // Find remainder 
        ll rem = n % 26LL; 
  
        // If remainder is 0, then a 'Z' must be there in output 
        if (rem == 0LL) { 
            s+='z'; 
            n = (n / 26) - 1; 
        } 
        else // If remainder is non-zero 
        { 
            s+=((rem - 1) + 'a'); 
            n = n / 26; 
        } 
    } 

  
    // Reverse the string and print result 
    reverse(s.begin(),s.end()); 
    cout << s << endl; 
  
    return; 
} 
  

int main()
{
	ll n;
	lsc(n);
	printString(n);
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int N;
    ll Y;
    cin >> N >> Y;

    for (int x = 0; x <= N; x++){
        for (int y = 0; y <= N-x; y++) {
            int z = N-x-y;
            if (x*10000 + y*5000 + z*1000 == Y) {
                cout << x << " " <<  y << " " <<  z << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
}

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

int main(){
    long n,k;
    while(cin >> n >> k && (n!=0 && k!=0)){
        long a[n],s[n];
        F(i,0,n){
            cin >> a[i];
        }
        s[0]=a[0];
        F(i,1,n){
            s[i]=s[i-1]+a[i];
        }
        long ans=0;
        F(i,0,n-k){
            ans=max(ans,s[i+k]-s[i]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4568
from itertools import permutations
foods = [int(input()) for i in range(5)]
ans = 1230
for i in permutations(foods):
    tmp = 0
    for j in range(4):
        tmp += -(-i[j] // 10)
    tmp *= 10
    tmp += i[4]
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 3188
#include <cstdio>
/*
agc*
021
acg*
012
gac*
201
ag*c
a*gc
*/

long long dp[101][4][4][4];
int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 4; ++j)
      for (int k = 0; k < 4; ++k)
      {
        int a = i << 8 | j << 4 | k;
        if (a == 0x012 || a == 0x021 || a == 0x201) continue;
        dp[3][k][j][i] += 1;
      }
  for (int p = 3; p < n; ++p)
  {
    for (int i = 0; i < 4; ++i)
      for (int j = 0; j < 4; ++j)
        for (int k = 0; k < 4; ++k)
          for (int l = 0; l < 4; ++l)
          {
            int a = j << 8 | k << 4 | l;
            if (a == 0x012 || a == 0x021 || a == 0x201) continue;
            if (i == 0 && j == 2 && l == 1) continue;
            if (i == 0 && k == 2 && l == 1) continue;
            (dp[p + 1][l][k][j] += dp[p][k][j][i]) %= 1000000007;
          }
  }
  int ans = 0;
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 4; ++j)
      for (int k = 0; k < 4; ++k)
        (ans += dp[n][k][j][i]) %= 1000000007;
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    //freopen("/Users/qianjay/Documents/apac/in", "r", stdin);
    char s[1024],s1[1024],s2[1024];
    scanf("%s%s%s",s,s1,s2);
    cout<<(char)toupper(s[0])<<(char)toupper(s1[0])<<(char)toupper(s2[0])<<endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin


def pow_mod(base, exp, mod):
    if exp == 0:
        return 1

    if exp % 2 == 0:
        t = pow_mod(base, exp/2, mod)
        return t*t % mod
    else:
        # ans=pow_mod(base, exp-1, mod)
        return (base*pow_mod(base, exp-1, mod)) % mod


def modinv(base, mod):
    return pow_mod(base, mod-2, mod)


def cmb(n, k, mod):
    p = 1
    for i in range(n-k+1, n+1):
        p = (p * i) % mod
    d = 1
    for i in range(1, k+1):
        d = (d * i) % mod
    return (p * modinv(d, mod)) % mod


mod = 7+10**9

# S = stdin.readline().rstrip().split()
# N = [int(x) for x in stdin.readline().rstrip().split()][0]
n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
ans = pow_mod(2, n, mod)
ans = (ans-cmb(n, a, mod)) % mod
ans = (ans-cmb(n, b, mod)) % mod
print(ans-1)
# print(cmb(n, b, p))
# print()


Measured memory_bytes: 3064