akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<string> v;
    for (int i=0; i < s.size(); i++){
        string p = "";
        for (int j=0; j < 5; j++){
            if (i+j == s.size()) break;
            p += s[i+j];
            v.push_back(p);
        }
    }
    sort(v.begin(), v.end());
    vector<string> x;
    x.push_back(v[0]);
    for (int i=1; i < v.size(); i++) if (v[i] != v[i-1]) x.push_back(v[i]);
    cout << x[k-1];
}


Measured memory_bytes: 1916
#include<stdio.h>
int main(void)
{
	int n,i,a[10000],min,max;
	long sum = 0;
	
	scanf("%d",&n);
	
	scanf("%d",&a[0]);
	min = a[0];
	max = a[0];
	sum += a[0];
	
	for(i = 1;i < n;i++){
		scanf("%d",&a[i]);
		if(a[i] > max) max = a[i];
		if(a[i] < min) min = a[i];
		sum += a[i];
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    vector<ll> ans(1e4+1, 0);
    for(ll i=1;i<=1e2;++i){
        for(ll j=i;j<=1e2;++j){
            for(ll k=j;k<=1e2;++k){
                ll m = i * i + j * j + k * k + i * j + j * k + k * i;
                if(m > 1e4){
                    continue;
                }
                if(i == j and j == k){
                    ans[m]++;
                }else if(i != j and j != k and i != k){
                    ans[m] += 6;
                }else{
                    ans[m] += 3;
                }
            }
        }
    }

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

Measured memory_bytes: 3568
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N, K = isRaw()
    As = isRaw()
    ts = [0]*N
    now = 0
    lstart = 0
    lsize = 0
    d = {}
    for i in range(N):
        ts[i]=now
        d[now]=i
        now = As[now]-1
        if now in d:
            lstart=d[now]
            lsize=i-d[now]+1
            break
    if K < lstart:
        return ts[K]+1
    return ts[((K-lstart) % lsize)+lstart]+1

print(main())


Measured memory_bytes: 115384
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;


int wlim = 100010;

void push(vector<P>& res, const P& p) {
    if (res.size() == 0 || p.second > res[(int)res.size() - 1].second) {
        res.push_back(p);
    }
}

vector<P> update(const vector<P>& lis, int v, int w) {
    int sz = lis.size();
    int p1 = 0, p2 = 0;
    vector<P> res;
    while (p1 < sz || p2 < sz) {
        if (p2 == sz) {
            push(res, lis[p1]);
            ++p1;
        }
        else if (p1 == sz) {
            if (lis[p2].first + w >= wlim) break;
            push(res, { lis[p2].first + w, lis[p2].second + v });
            ++p2;
        }
        else {
            if (lis[p1].first < lis[p2].first + w) {
                push(res, lis[p1]);
                ++p1;
            }
            else if (lis[p1].first > lis[p2].first + w) {
                push(res, { lis[p2].first + w, lis[p2].second + v });
                ++p2;
            }
            else {
                push(res, { lis[p1].first, max(lis[p1].second, lis[p2].second + v) });
                ++p1;
                ++p2;
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i] >> w[i];
    }
    int q;
    cin >> q;
    vector<vector<P>> que(n, vector<P>());
    for (int i = 0; i < q; ++i) {
        int u, l;
        cin >> u >> l;
        --u;
        que[u].push_back({ l, i });
    }
    int lm = 1 << 11;
    vector<vector<P>> vs(lm);
    vs[0] = { { 0, 0 } };
    vector<int> ans(q);
    for (int i = 0; i < n; ++i) {
        if (i < lm) {
            vs[i] = update(vs[(i - 1) / 2], v[i], w[i]);
            for (auto& p : que[i]) {
                int ma = 0;
                for (auto& j : vs[i]) {
                    if (j.first <= p.first) {
                        ma = max(ma, j.second);
                    }
                }
                ans[p.second] = ma;
            }
        }
        else {
            int a = i;
            vector<P> lis = { { 0, 0 } };
            while (a >= lm) {
                lis = update(lis, v[a], w[a]);
                a = (a - 1) >> 1;
            }

            for (auto& p : que[i]) {
                int l = p.first;
                int k = (int)vs[a].size() - 1;
                int ma = 0;
                for (int j = 0; j < (int)lis.size(); ++j) {
                    while (k >= 0 && lis[j].first + vs[a][k].first > l) {
                        --k;
                    }
                    if (k < 0) break;
                    ma = max(ma, lis[j].second + vs[a][k].second);
                }
                ans[p.second] = ma;
            }
        }
    }
    for (auto& i : ans) {
        cout << i << '\n';
    }
    return 0;
}


Measured memory_bytes: 36972
#include <iostream>
#include <string>
#include <list>
using namespace std;
int main(void){
  int n;
  string c;
  list<int> l;
  list<int>::iterator j;
  cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>c;
    if(c=="insert"){
      int x;
      cin>>x;
      l.push_front(x);
    }
    if(c=="delete"){
      int x;
      cin>>x;
      for(j=l.begin();j!=l.end();j++){
	     if(*j==x){
	       l.erase(j);
	       break;
	     }
      }
    }
    if(c=="deleteFirst")l.pop_front();
    if(c=="deleteLast")l.pop_back();
  }
  
  int f=0;
  for(j=l.begin();j!=l.end();j++){
    if(f)
      cout<<" ";
    cout<<*j;
    f++;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 34304
from collections import deque

n = int(input())

G = [[] for _ in range(n)]

for _ in range(n-1):
    s, t, w = map(int, input().split())
    G[s].append((t, w))
    G[t].append((s, w))

def bfs(s):
    visited = [0]*n
    C = [float("inf")]*n
    queue = deque([(s, 0)])
    visited[s] = 1

    while queue:
        x, c = queue.popleft()
        C[x] = c
        for node, cost in G[x]:
            if visited[node] == 0:
                queue.append((node, c+cost))
                visited[node] = 1
                
    return max(C), C.index(max(C)) 
    
m, index = bfs(0)
ans, index = bfs(index)

print(ans)
    



Measured memory_bytes: 45936
#include<iostream> 
using namespace std;
typedef long long ll;
int main() {
    int n; cin >> n;
    int t[n], a[n];
    for (int i = 0; i < n; ++i) {
        cin >> t[i] >> a[i];
    }
    ll tt = 1;
    ll aa = 1;
    for (int i = 0; i < n; ++i) {
        ll j = max((tt + t[i] - 1) / t[i], (aa + a[i] - 1) / a[i]);
        tt = t[i] * j;
        aa = a[i] * j;
        //cout << tt << " " << aa << endl;
    }
    ll ans = tt + aa;
    cout << ans << endl;
    return 0;
}


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

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

    int sum = 0;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    int popular = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] * 4 * m >= sum) {
            popular++;
        }
    }

    cout << (popular >= m ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>


using namespace std;

int main(){
  int N,W;
  cin >> N >> W;
  int w[N];
  int v[N];
  for(int i = 0 ; i < N; i++) cin >> w[i] >> v[i];
  long long dp[100002];
  for(int i = 0 ; i < 100002; i++) dp[i] = LLONG_MAX/2;
  dp[0] = 0;
  for(int i = 0 ; i < N; i++){
     for(int j = 100001-v[i]; j >= 0 ; j--){
        dp[j+v[i]]=min(dp[j+v[i]], dp[j]+w[i]);
     }
  }
  long long ans = 0;
  for(int i = 0 ; i <=100001; i++){
     if(dp[i] <= W) ans = i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll m = 1e9 + 7;
ll mul(ll x, ll y) {
  ll ans = (x * 1ll * y) % m;
  while(ans < 0) ans += m;
  return ans;
}
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ll n = 0, k = 0;

  cin >> n >> k;

  vector<ll> a(n), pos, neg, ppos, pneg;

  for(ll i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] >= 0) pos.pb(a[i]);
    else neg.pb(a[i]);
  }

  sort(all(a));

  if(n == k) {
    ll ans = 1;
    for(auto& x : a) ans = mul(ans, x);
    cout << ans;
    return 0;
  }

  if(!pos.size()) {
    ll ans = 1;
    if(k % 2 == 0) {
      for(ll i = 0; i < k; i++) ans = mul(ans, a[i]);
    } else {
      for(ll i = 0; i < k; i++) ans = mul(ans, a[n - i - 1]);
    }
    cout << ans;
    return 0;
  }

  sort(rall(pos)); sort(all(neg));

  ppos.resize(pos.size() + 1); pneg.resize(neg.size() + 1);

  ppos[0] = 1; pneg[0] = 1;

  for(ll i = 1; i <= pos.size(); i++) ppos[i] = mul(ppos[i - 1], pos[i - 1]);

  for(ll i = 1; i <= neg.size(); i++) pneg[i] = mul(pneg[i - 1], neg[i - 1]);

  ll posp = min((ll)pos.size(), k);

  ll negp = k - posp;

  if(negp % 2 == 1) {
    negp++;
    posp--;
  }

  while(negp + 2 <= neg.size() && posp >= 2 && pos[posp - 1] * pos[posp - 2] < neg[negp] * neg[negp + 1]) {
    negp += 2;
    posp -= 2;
  }

  cout << mul(ppos[posp], pneg[negp]);

  return 0;
}
/*

*/


Measured memory_bytes: 8072
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    s = S()
    s1 = s[:n]
    s2 = s[n:][::-1]
    d1 = collections.defaultdict(int)
    d2 = collections.defaultdict(int)
    for i in range(2**n):
        t = t2 = ','
        for j in range(n):
            if 2**j & i:
                t += s1[j]
            else:
                t2 += s1[j]
        d1[t+t2] += 1
    for i in range(2**n):
        t = t2 = ','
        for j in range(n):
            if 2**j & i:
                t += s2[j]
            else:
                t2 += s2[j]
        d2[t+t2] += 1
    r = 0
    for k in d2.keys():
        r += d1[k] * d2[k]


    return r


print(main())


Measured memory_bytes: 156216
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> da(n);
    rip(i,n,0){
        cin >> da[i];
        da[i] --;
    }
    map<int,vector<int>> mp;
    mp[0] = vector<int>(1,0);
    int now = 0;
    rip(i,n,0){
        now = (now + da[i]) % k;
        if(mp.count(now)){
            mp[now].push_back(i + 1);
        }
        else{
            mp[now] = vector<int>(1, i + 1);
        }
    }
    ll ans = 0;
    for(auto i:mp){
        if(i.second.size() <=1){
            continue;
        }
        int fo = 1, ba = 0;
        while(fo < i.second.size()){
            if(i.second[fo] - i.second[ba] > k - 1){
                ba++;
            }
            else{
                ans += fo - ba;
                fo ++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 22912
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;



int main()
{
        int N;
        cin >> N;
        vector<int> B(N-1);
        int A = 0;
        for(int i=0; i<N-1; i++){
                cin >> B[i];
                if(i==0) A += B[i];
                else A += min(B[i], B[i-1]);
        }
        cout << A+B[N-2];

}      

Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    w = float(N[l])
    if w <= 48.0:
        ans = "light fly"
    elif w <= 51.0:
        ans = "fly"
    elif w <= 54.0:
        ans = "bantam"
    elif w <= 57.0:
        ans = "feather"
    elif w <= 60.0:
        ans = "light"
    elif w <= 64.0:
        ans = "light welter"
    elif w <= 69.0:
        ans = "welter"
    elif w <= 75.0:
        ans = "light middle"
    elif w <= 81.0:
        ans = "middle"
    elif w <= 91.0:
        ans = "light heavy"
    else:
        ans = "heavy"
    print(ans)


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

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n >= m) {
        ans = m / 2;
    } else {
        ans += n;
        m -= 2 * n;
        ans += m / 4;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    vector<vector<int>> A(N, vector<int>(M));
    loop(n, N){
        loop(m, M){
            scanf("%d", &(A[n][m]));
            getchar();
        }
    }
    vector<char> flag(M, true);
    int result = N;
    vector<int> Ai(N, 0);
    loop(i, M - 1){
        unordered_map<int, int> count;
        loop(j, N){
            while (!flag[A[j][Ai[j]] - 1]) ++Ai[j];
            ++count[A[j][Ai[j]]];
        }
        int max_num = 0;
        int max_sports;
        for (auto& e : count){
            if (max_num < e.second){
                max_num = e.second;
                max_sports = e.first;
            }
        }
        result = min(result, max_num);
        flag[max_sports - 1] = false;
    }
    printf("%d\n", result);
}


Measured memory_bytes: 640
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def patition(a, p, r):
    x = a[r][0]
    i = p - 1
    for j in range(p, r):
        if a[j][0] <= x:
            i += 1
            a[i], a[j] = a[j], a[i]
    a[i+1], a[r] = a[r], a[i+1]
    return i + 1


def quick_sort(a, p, r):
    if p < r:
        q = patition(a, p, r)
        quick_sort(a, p, q-1)
        quick_sort(a, q+1, r)


n = int(stdin.readline())
data = []
s = set()
for i in range(n):
    c, num = stdin.readline().split()
    data.append((int(num), c))
    s.add(int(num))
output = data[:]
quick_sort(output, 0, n-1)
for i in s:
    if [d for d in data if d[0] == i] != [d for d in output if d[0] == i]:
        print('Not stable')
        break
else:
    print('Stable')
for num, c in output:
    print(c, num)

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


int main()
{
	ll n;
	cin >> n;
	ll i,j;
	ll div[n+5];
	memset(div,0LL,sizeof(div));
	for(i=1;i<=n;i++)
	{
		for(j=i;j<=n;j+=i)
		{
			div[j]++;
		}
	}
	ll ans=0LL;
	for(i=1;i<=n;i++)
	{
		ans+=(i*div[i]);
	}
	cout << ans ;
    return 0;
}


Measured memory_bytes: 81732
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

V,E=get_i
g=array(V)
ind=array(V,0)
E.times do|i|
  s,t=get_i
  g[s]=[] if g[s].nil?
  g[s].push(t)
  ind[t]+=1
end
$seen=array(V,false)
def tps(g,ind)
  queue=[]
  V.times do|i|
      queue.push(i) if ind[i].zero?
  end
  ans=[]
  until queue==[]
    curr=queue.shift
    ans.push(curr)
    next if g[curr].nil?
    g[curr].each do|v|
        ind[v]-=1
        queue.push(v) if ind[v].zero?
    end
  end
  return ans
end
ans=tps(g,ind)
if ans.size==V
    puts 0
else
    puts 1
end



Measured memory_bytes: 8908
k = int(input())
ans = [i for i in range(1,10)]

i = 0

for i in range(k):
    now = ans[i]
    if str(now)[-1] == '0':
        ans.append(now*10)
        ans.append(now*10+1)
    elif str(now)[-1] == '9':
        ans.append(now*10+8)
        ans.append(now*10+9)
    else:
        ans.append(now*10+now%10-1)
        ans.append(now*10+now%10)
        ans.append(now*10+now%10+1)
    if len(ans) > k:
        break

print(ans[k-1])


Measured memory_bytes: 7188
x,y = map(int,input().split())

A =[1,3,5,7,8,10,12]
B =[4,6,9,11]
C =[2]

if x in A and y in A:
  print('Yes')
elif x in B and y in B:
  print('Yes')
elif x in C and y in C:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
num = 0
for a in range(1,k+1):
    for b in range(a,k+1):
        for c in range(b,k+1):
          x = gcd(a,b,c)
          bai = sum([a==b,b==c,a==c])
          if bai == 0:
            num += x*6
          elif bai == 1:
            num += x*3
          else:
            num += x
            
print(num)



Measured memory_bytes: 9632
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    int A, B;
    rep(i, 0, M) {
        cin >> A >> B;
        --A, --B;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }
    vector<bool> visited(N, false);
    vector<int> ans(N, -1);
    queue<int> que;
    que.push(0);
    visited[0] = true;
    while (!que.empty()) {
        int node = que.front();
        que.pop();
        for (auto& next_node : graph[node]) {
            if (visited[next_node]) {
                continue;
            }
            ans[next_node] = node;
            que.push(next_node);
            visited[next_node] = true;
        }
    }
    cout << "Yes" << endl;
    rep(i, 1, N) {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10340
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
int main(){
     string s ; cin >> s ;
     int x = s.size();
     int cnt = 0 ;
     for(int i = 0 ; i < x/2 ; i++){
     	  if(s[i] != s[x-i-1])
     	     cnt++;
	 }
	 cout << cnt ;
}



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

int main()
{
	int p, s;
	char comma;
	vector<pair<int, int> > v;
	while (cin >> p >> comma >> s, p != 0 || s != 0) {
		v.push_back(pair<int, int>(s, p));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());//?????°????????????????????????
	/*
		cout << "--------------------------------" << endl;
		for (int i = 0; i < v.size(); i++) {
			cout << v[i].first << "   " << v[i].second << endl;
		}
		cout << "--------------------------------" << endl;
	*/
	int input;
	int score = 0;
	while (cin >> input) {
		//input????????????
		for (int i = 0; i < v.size(); i++) {
			if (v[i].second == input) {
				score = v[i].first;
			}
		}
		//??????
		int cnt = 1;
		int k = -1000;
		for (int i = 0; i < v.size(); i++) {
			if (score == v[i].first) {//?±???????score????????´
				cout << cnt << endl;
				break;
			}
			if (k != v[i].first) {//score != v && ???????????????????????????
				k = v[i].first;
				cnt++;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

int dh[] = { -1,0,1,0 };
int dw[] = { 0,1,0,-1 };
void solve() {
	int H, W; cin >> H >> W; if (H == 0) exit(0);
	ll L; cin >> L;
	vector<string> vs(H); for (int i = 0; i < H; i++) cin >> vs[i];
	vector<vector<int>> to(62, vector<int>(H * W * 4));
	for (int i = 0; i < H * W * 4; i++) {
		int d = i / (H * W);
		int h = (i % (H * W) / W);
		int w = i % W;
		int nd = d;
		int nh = h + dh[nd];
		int nw = w + dw[nd];
		if (vs[h][w] == '#') continue;
		int cnt = 0;
		while (nh < 0 or nh >= H or nw < 0 or nw >= W or vs[nh][nw] == '#') {
			cnt++;
			if (cnt >= 5) break;
			nd += 1; if (nd >= 4) nd -= 4;
			nh = h + dh[nd];
			nw = w + dw[nd];
		}
		to[0][i] = nd * H * W + nh * W + nw;
		if (cnt >= 5) to[0][i] = 0;
	}
	for (int i = 1; i < 62; i++) for (int j = 0; j < H * W * 4; j++) to[i][j] = to[i - 1][to[i - 1][j]];
	char c[] = { 'N','E','S','W' };
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) for (int k = 0; k < 4; k++) {
		if (vs[i][j] == c[k]) {
			int s = k * H * W + i * W + j;
			for (int bit = 0; bit < 62; bit++) {
				if (L >> bit & 1) {
					s = to[bit][s];
				}
			}
			int d = s / (H * W);
			int h = (s % (H * W)) / W;
			int w = s % W;
			cout << h + 1 << " " << w + 1 << " " << c[d] << "\n";
			return;
		}
	}
}

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int kkt = 89;
	while (kkt) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 13148
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[500101];
int l[500111];
int j[201001];

long long x,y,z,mod=998244353;
string r;
//char r[2];

P u[500101];
priority_queue<P> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<P> v;


bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y>b.y;
}

int f(P s)
{
  //if((s.x!=0&&s.x!=a)||(s.y!=0&&s.y!=b)) return -1;
  if(s.x==0) return s.y;
  if(s.y==b) return s.x+b;
  if(s.x==a) return a+b+b-s.y;
  if(s.y==0) return a*2+b*2-s.x;
  return -1;
}

int main()
{
  scanf("%d %d %d",&a,&b,&c);
  for(int t=1;t<=c;t++)
  {
    scanf("%d %d",&n,&m);
    e=f({n,m});
    scanf("%d %d",&n,&m);
    d=f({n,m});
    if(e>d) swap(e,d);
    //printf("%d %d\n",e,d);
    if(e>=0&&d>=0)
    {
      q.push({t,e});
      q.push({t,d});
    //v.push_back({e,d});
    }
  }
  for(;q.size();q.pop())
  if(s.size()&&s.top()==q.top().x) s.pop();
  else s.push(q.top().x);
  if(s.size()==0) puts("YES");
  else puts("NO");
}
//10




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

#ifdef LOCAL
  #include <contest/local.hpp>
#else
  #define LOG(...) do {} while (false)
#endif

#define REP(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) (x).begin (), (x).end ()

using namespace std;

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

  int n, d;
  cin >> n >> d;
  cout << ceil (n / (2.0 * d + 1.0)) << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define LATTE 1000000000

struct data{
    int x,d;
    data(){}
    data(int _x,int _d){
        x=_x; d=_d;
    }
};

int abso(int n){
    if(n<0) return n*-1;
    return n;
}

const int dir[2] = {0,1};
int dp[152][1001][76];

int main(){
    int N,M,K;
    data in;
    while(cin>>N>>M,N||M){
        vector<data> stone[152];
        stone[0].push_back(data(0,0));
        stone[N+1].push_back(data(0,0));
        for(int i=1;i<=N;i++){
            cin>>K;
            for(int j=0;j<K;j++){
                cin>>in.x>>in.d;
                stone[i].push_back(in);
            }
        }
        for(int i=0;i<=N+1;i++)for(int j=0;j<=1000;j++)for(int k=0;k<=M;k++)
            dp[i][j][k]=LATTE;
        dp[0][0][0]=0;
        for(int i=0;i<=N;i++){
            for(int j=0;j<stone[i].size();j++){
                for(int k=0;k<=M;k++){
                    //printf("%d ",dp[i][j][k]);
                    for(int kind=0;kind<2;kind++){
                        if(k+dir[kind]>M || i+dir[kind]+1>N+1) continue;
                        for(int l=0;l<stone[i+dir[kind]+1].size();l++){
                            int latte =
                                dp[i][stone[i][j].x][k]+
                                (stone[i][j].d+stone[i+dir[kind]+1][l].d)*
                                abso(stone[i][j].x-stone[i+dir[kind]+1][l].x);
                            //printf("%d\n",latte);
                            if(i==0 || i+dir[kind]+1==N+1) latte=dp[i][stone[i][j].x][k];
                            dp[i+dir[kind]+1][stone[i+dir[kind]+1][l].x][k+dir[kind]] =
                                min(dp[i+dir[kind]+1][stone[i+dir[kind]+1][l].x][k+dir[kind]],latte);
                        }
                    }
                }//puts("");
            }//puts("");
        }
        int ans=LATTE;
        for(int i=0;i<=M;i++){
            ans = min(ans,dp[N+1][stone[N+1][0].x][i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 46380
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll X, Y;
  cin >> X >> Y;
  for (ll i = 0; i <= X; ++i) {
    if (i * 2 + (X - i) * 4 == Y) {
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

long dp[100001][10];

long nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}

string s_sort(string s){
  char tmp;
  for(int i=0; i<s.length(); i++){
    for(int j=s.length()-1; j>i; j--){
      if(s[j] < s[j - 1]) {
        tmp = s[j]; s[j] = s[j-1]; s[j-1] = tmp;
      }
    }
  }
  return s;
}

int main(){
  long long int N, i, cnt=0, sub_cnt=0;
  cin >> N;
  string s[N], tmp;
  for(i=0; i<N; i++) cin >> s[i];
  for(i=0; i<N; i++) s[i] = s_sort(s[i]);
  //cout << endl;
  sort(s, s+N);
  //for(i=0; i<N; i++) cout << s[i] << endl;
  for(i=0; i<N-1; i++){
    if(s[i] == s[i+1]){
      sub_cnt++;
    }else{
      if(sub_cnt > 0) cnt += nCr(sub_cnt+1, 2);
      sub_cnt = 0;
    }
  }
  if(sub_cnt > 0) cnt += nCr(sub_cnt+1, 2);
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 19840
#include <iostream>
#include <map>
#include <string>

int main()
{
    int N;
    std::map<std::string, int> data;

    std::cin >> N ;
    int max = 0;

    for( int n = 0 ; n < N; n++ ) {
        std::string str; 
        std::cin >> str;

        if( data.count( str ) <= 0 ){
            data[str] = 1;
        } else {
            data[str]++;
        }
        if( data[str] > max ) {
            max = data[str];
        }
    }

    for( auto iter = data.begin(); iter != data.end(); iter++ ) {
        if( iter->second == max) {
            std::cout << iter->first << std::endl;
        }
    }
    
    return 0;
}

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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   int a,b;
   char c;
   cin >> a >> c >>  b;
   if(c=='+')cout << a+b;
   else cout << a-b;
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
vector<string> v;
int xx=0,yy=0,z=0,w=0,n=0,m=0;
vector<int> y_vec = {1, 0, -1, 0};
vector<int> x_vec = {0, +1, 0, -1};

struct Corr {
    int y;
    int x;
    int depth;
};
queue<Corr> q;
int y, x, depth;
int bfs() {
    while (!q.empty()) {
        Corr now = q.front(); q.pop();
        y = now.y, x = now.x, depth = now.depth;
        v[y][x]='x';
        for (int i = 0; i < 4; ++i) {
            Corr next = {y + y_vec[i], x + x_vec[i], depth + 1};
            if (0 <= next.y && next.y <= xx-1 && 0 <= next.x && next.x <= yy-1 && v[next.y][next.x] == '.') {
                v[next.y][next.x] = 'x';
                q.push(next);
            }
        }
    }
    return depth;
}
signed main()
{

std::cin >> xx>>yy;
v.resize(xx);
rep(i,xx){
std::cin >> v[i];
}
std::vector<string> vv(xx);
vv=v;
rep(i,xx){
  Rep(j,yy){
    if(v[i][j]=='#')continue;
    v=vv;
    Corr start = {i,j, 0};
    q.emplace(start);
    m=bfs();
    if(w<m)w=m;
  }
}
  cout << w << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b[100005],sum=0;
    cin>>n;
    memset(b,0,sizeof(b));
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a>100000) sum++;
        else b[a]++;
    }
    for(int i=0;i<100005;i++)
    {
        if(b[i]<i) sum+=b[i];
        if(b[i]>i) sum+=(b[i]-i);
    }
    cout<<sum;
}

Measured memory_bytes: 640
//C-Alchemist
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<stdio.h>
int compare(const void *a,const void *b){
	return *(int*)b-*(int*)a;
}
int main(void){
    int n,i;
    double b=0;
    scanf("%d",&n);
    int v[n];
    for(i=0;i<n;i++){
        scanf("%d",&v[i]);
    }
	qsort(v,n,4,compare);
    //printf("%d",v[0]);
    for(i=0;i<n-1;i++){
        if(i==0){
            b= (double) (v[n-1]+v[n-2])/2;
        }
        if(i!=0){
            b= (double) (b+v[n-2-i])/2;
        }
    }
    printf("%f\n",b);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ii, ll>;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
// const ll N = ;

ll a, b, temp;

ll factorize(ll x) {
    ll ret = 1;
    for(ll i = 2; i * i <= x; i++) {
        if(x % i == 0) {
            ret++;
            while(x % i == 0) x /= i;
        }
    }
    if(x > 1) ret++;
    return ret;
}

void solve() {
    cin >> a >> b;
    temp = __gcd(a, b);
    cout << factorize(temp) << "\n";
}

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

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A,B,Q;
ll s[(ll)(1e5+5)],t[(ll)(1e5+5)];
ll bisect(ll *to_search,ll l,ll r,ll r_max,ll num){
    if(num>to_search[r_max]) return r_max;
    if(num<to_search[0]) return 0;
    if(r-l<=50){
        ll ret=LLONG_MAX;
        for(int i=l;i<=r;i++){
            if(to_search[i]<=num) ret=i;
        }
        if(ret+1!=r_max+1)
            if(num-to_search[ret]>to_search[ret+1]-num){
                return ret+1;
            } 
        return ret;
    }
    if(num>=to_search[(l+r)/2]){
        return bisect(to_search,(l+r)/2,r,r_max,num);
    }
    else return bisect(to_search,l,(l+r)/2,r_max,num);
}
int main(){ 
    cin>>A>>B>>Q; getchar();
    for(int i=0;i<A;i++) {cin>>s[i]; getchar();}
    for(int i=0;i<B;i++) {cin>>t[i]; getchar();}
    for(int i=0;i<Q;i++){
        ll x;
        cin>>x; getchar();
        ll a=bisect(s,0,A-1,A-1,x);
        ll ans1=abs(s[a]-x)+abs(s[a]-t[bisect(t,0,B-1,B-1,s[a])]);

// cout<<"1."<<ans1<<endl;

        ll b=bisect(t,0,B-1,B-1,x);
        // cout<<ans1<<endl;
        ll bj=b;
        ll ans2=min(ans1,abs(t[(b)]-x)+abs(t[(b)]-s[bisect(s,0,A-1,A-1,t[b])]));
        if(s[a]==x){
            ll xyz=abs(t[b]-s[a]);
        } 
        //找s经过t
        //1.s
        if(s[a]<x){
            if(t[b]>x) b--;
            if(b==-1) b++;
            else if(t[b]>s[a]) ans2=min(ans2,x-min(s[a],t[b]));
        }
        // cout<<"b="<<b<<endl;
    else    if(s[a]>x){
            if(t[b]<x) b++;
            if(b==B) b--;
            else if(t[b]<s[a]) ans2=min(ans2,max(s[a],t[b])-x);
        } 

        b=bj;
        if(s[a]>=x)
        a--;
        else a++;
        if(a==-1) a++;
        if(a==A) a--;


ans2=min(ans2,abs(s[a]-x)+abs(s[a]-t[bisect(t,0,B-1,B-1,s[a])]));
// cout<<"4."<<ans2<<endl;
        if(s[b]>=x)
        b--;
        else b++;
        if(b==-1) b++;
        if(b==B) b--;

ans2=min(ans2,abs(t[(b)]-x)+abs(t[(b)]-s[bisect(s,0,A-1,A-1,t[b])]));
// cout<<"5."<<ans2<<endl;
b=bj;
if(s[a]<x){
            if(t[b]>x) b--;
            if(b==-1) b++;
            else if(t[b]>s[a]) ans2=min(ans2,x-min(s[a],t[b]));
        }
        // cout<<"b="<<b<<endl;
    else    if(s[a]>x){
            if(t[b]<x) b++;
            if(b==B) b--;
            else if(t[b]<s[a]) ans2=min(ans2,max(s[a],t[b])-x);
        } 
cout<<ans2<<endl;
    }
    return 0;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

ll min3(ll a, ll b, ll c){
    ll temp = min(a, b);
    return min(temp, c);
}

// BAを核とする
ll calc1(ll BA, ll _A, ll B_){
    ll plus = 0;
    ll mi = min3(BA, _A, B_);
    plus += mi * 2;
    BA -= mi;
    _A -= mi;
    B_ -= mi;

    if(BA==0){
        plus += min(_A, B_);
    }
    else if(_A==0){
        plus += min(BA, B_);
    }
    else if(B_==0){
        plus += min(BA, _A);
    }
    return plus;
}

// B, A でまず作る
ll calc2(ll BA, ll _A, ll B_){
    ll count = 0;
    ll mi = min(_A, B_);
    count += mi;
    _A -= mi;
    B_ -= mi;
 
    if(B_>0){
        ll rest = max(_A, B_);
        mi = min(rest, BA);
        count += mi;
    }
    else if(_A>0){
        if(BA>0) _A++;
 
        ll rest = max(_A, B_);
        mi = min(rest, BA);
        count += mi;
    }
    return count;
}

// BAでまず作る
ll calc3(ll BA, ll _A, ll B_){
    ll count = 0;
    if(BA>0){
        count += BA-1;

        if(_A==0 && B_==0) return count;

        _A++;
        B_++;
    }

    count += min(_A, B_);
    return count;
}


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

    // input
    ll N;
    cin >> N;

    ll BA = 0;
    ll _A = 0;
    ll B_ = 0;

    ll count = 0;
    FOR(i, 0, N){
        string s;
        cin >> s;

        if(s[0]=='B' && s.back()=='A'){
            BA++;
        }
        else if(s[0]=='B'){
            B_++;
        }
        else if(s.back()=='A'){
            _A++;
        }

        ll L = s.size();
        FOR(i, 0, L-1){
            if(s[i]=='A' && s[i+1]=='B'){
                count++;
            }
        }
    }

    ll ans1 = calc1(BA, _A, B_) + count;
    ll ans2 = calc2(BA, _A, B_) + count;
    ll ans3 = calc3(BA, _A, B_) + count;

    // pn(ans1);
    // pn(ans2);
    // pn(ans3);
    
    ll ma = max(ans1, ans2);
    ma = max(ma, ans3);
    p(ma);

    
    return 0;
}

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

using namespace std;

int64_t f(int64_t b, int64_t n) {
    if(n < b) {
        return n;
    } else {
        return f(b, n/b) + n%b;
    }
}

int main(void) {
    int64_t n, s;
    cin >> n >> s;

    int64_t ans = numeric_limits<int64_t>::max();
    for(int64_t b=2; b*b<=n; b++) {
        if(f(b, n) == s) {
            ans = min(ans, b);
            // cout << b << endl;
            // return 0;
        }
    }

    if(n == s) {
        ans = min(ans, n+1);
        // cout << n+1 << endl;
        // return 0;
    }

    for(int64_t i=1; i*i<=n; i++) {
        int64_t j = s - i;
        if((n-j) % i == 0) {
            int64_t b = (n-j) / i;
            if(b < 2) continue;
            if(i >= b || j >= b || j < 0) continue;
            // cerr << i << ' ' << j << endl;
            ans = min(ans, b);
            // cout << (n-j) / i << endl;
            // return 0;
        }
    }

    if(ans == numeric_limits<int64_t>::max()) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int T = sc.nextInt();
        int S = sc.nextInt();
        if(T * S >= D){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35608
#include <stdio.h>

void trace(int *a, int n)
{
    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
}

void insertionSort(int *a, int n)
{
    for (int i = 1; i < n; i++) {
        int key = a[i];
        int p = i - 1;
        while (p >= 0 && a[p] > key) {
            a[p+1] = a[p];
            p--;
        }
        a[p+1] = key;
        trace(a, n);
    }
}

int main()
{
    int n, a[110];

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

    trace(a, n);
    insertionSort(a, n);

    return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }

int main()
{
    string s;
    cin>>s;
    red(i,s.size())if((i%2 && s[i]=='R')||(i%2==0 && s[i]=='L')) yn(0),exit(0);
    yn(1);
    return 0;
}

Measured memory_bytes: 256
L,R = map(int,input().split())
a = [False for i in range(2019)]

for i in range(L,min(L+2019,R)+1):
    a[i%2019] = True
ans = 4000
for i in range(2019):
    if not a[i]:
        continue
    for j in range(i+1,2019):
        if not a[j]:
            continue
        ans = min(ans,i*j%2019)
print(ans)


Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()
print("Yes" if sum(map(int, list(N)))%9 == 0 else "No")


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

using namespace std;

#define int long long

constexpr int INF = 1LL << 60;
constexpr double EPS = 1.0e-11;

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

constexpr int MAX_N = 605;
constexpr int MAX_M = MAX_N * MAX_N / 2;

int n, m;
double dp[MAX_N][MAX_N];
vector<int> G[MAX_N];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(16);
    cout << fixed;

    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int s, t;
        cin >> s >> t;
        G[s].emplace_back(t);
    }

    fill(dp[0], dp[MAX_N], INF);

    double ans = INF;
    for (int node = 0; node < n; node++)
    {
        if (node != 0 && G[node].size() <= 1) continue;
        dp[node][n] = dp[node][n] = 0;
        for (int i = n - 1; 1 <= i; i--)
        {
            int rm = INF;
            double maxRm = -INF;
            if (i == node)
            {
                for (const auto t : G[i])
                {
                    if (maxRm < dp[node][t])
                    {
                        maxRm = dp[node][t];
                        rm = t;
                    }
                }
            }
            double res = 0;
            double p = i == node ? (1.0 / (G[i].size() - 1.0)) : (1.0 / G[i].size());
            for (const auto t : G[i])
            {
                if (t == rm) continue;
                res += (dp[node][t] + 1.0) * p;
            }

            dp[node][i] = min(dp[node][i], res);
        }
        ans = min(ans, dp[node][1]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;


int main()
{
  fastio
  int t;
  cin >> t;
  set<string> s;
  while(t--)
  {
    string k;
    cin >> k;
    s.insert(k);

  }
  cout << s.size();


  return 0;
}




Measured memory_bytes: 19200