akhauriyash/Code-Regression huggingface dataset:
#ALDS1_3-C Elementary data structures - Doubly Linked List
import collections
import sys
q = collections.deque()
n=int(input())
_input = sys.stdin.readlines()
cmds={"insert":lambda cmd: q.appendleft(cmd[1]),
      "delete":lambda cmd: q.remove(cmd[1]) if (q.count(cmd[1]) > 0) else "none",
      "deleteFirst":lambda cmd: q.popleft(),
      "deleteLast": lambda cmd: q.pop()
     }

for i in range(n):
    cmd=_input[i].split()
    cmds[cmd[0]](cmd)
print(*q)

Measured memory_bytes: 214356
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int k; cin >>k;
  if(k%2==0 or k%5==0){
    print(-1); return 0;
  }
  int r=0,cnt=0;
  rep(i,k+1){
    (r*=10)+=7;
    r%=k;
    cnt++;
    if(r==0)break;
  }
  print(cnt);
}


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

int main(){
  string s;
  cin >> s;
  
  int cnt = 0;
  for (int i = 0; i < s.size(); i++){
    if ((i+1 != s.size())&&(s.at(i) == s.at(i+1))){
      cnt++;
    }
  }
  
  if (cnt == 0){
    cout << "Good" << endl;
  }
  else {
    cout << "Bad" << endl;
  }
  
}


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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;

int main() {
	speed;
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int count = 0;
	bool flag = false;
	rep(i, 3) {
		if (a[i] == 5)count++;
		if (a[i] == 7)flag = true;
	}
	if (flag&&count == 2) { c("YES"); }
	else c("NO");
	
	ed;
	return 0; 
}



Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

N, W = geta(int)
cur = [0] * (W+1) 

for i in range(N):
    w, v = geta(int)
    update = cur[:]
    for j in range(w,W+1):
        tmp = cur[j-w] + v
        if tmp > cur[j]: update[j] = tmp
    
    cur = update

print(cur[W])


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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long int lli;

int main()
{
	fio;
	int n;
	cin>>n;
	if(n<=999) cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
	cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    for(int i = 0; i < n; i++) scanf("%d", &b[i]);
    long long sma = 0, smb = 0;
    for(int i = 0; i < n; i++){
        sma += a[i];
        smb += b[i];
    }
    long long times = smb - sma;
    if(times < 0) return 0 * puts("No");
    vector<int> ad, bd;
    long long dec = 0;
    for(int i = 0; i < n; i++){
        if(a[i] > b[i]) dec += a[i] - b[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i] < b[i]){
            int mxdec = (b[i] - a[i]) / 2;
            int taken = min(1ll * mxdec, dec);
            b[i] -= 2 * taken;
            dec -= taken;
        }
    }
    if(dec == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout(s) cout<<s<<"\n";
#define debug() if(true)
#else
#define dout(s)
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n);
typedef long long ll;
typedef unsigned long long ull;

struct KOZO {
public:
	int B;
	int C;
};

bool hikaku(const KOZO& kozo1, const KOZO& kozo2) {
	return (kozo1.C>kozo2.C);
}

void Main() {
	int A, P;
	cin >> A >> P;
	cout << ((A*3+P)/2) << "\n";
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ii = pair<int,int>;
using ll = long long;
using pll = pair<ll,ll>;
constexpr int MAXN = 5+2e5;
constexpr int MOD = 7 + 1000000000;

ll gcd(ll a, ll b) {
  return b ? gcd(b, a % b) : a;
}

int mul(int a, int b) {
  return (int)((1LL*a*b)%MOD);
}

int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}

int sub(int a, int b) {
  int ans = a - b;
  if (ans < 0) ans += MOD;
  return ans;
}

int fpow(int b, int e) {
  int ans = 1, p = b;
  for (; e; e >>= 1) {
    if(e & 1) ans = mul(ans, p);
    p = mul(p, p);
  }
  return ans;
}

int f[MAXN];
int choose(int n, int k) {
  return mul(f[n], fpow(mul(f[k], f[n-k]), MOD-2));
}

struct F {
  ll a,b;
  F(ll x, ll y) {
    ll g = max(1LL, gcd(abs(x),abs(y)));
    tie(a,b) = pll{x/g, y/g};
  }
  pll get() {
    return pll{abs(a), abs(b)};
  }
};

int s(ll x) {
  if (x == 0) return 0;
  return x < 0 ? -1 : 1;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  f[0] = 1;
  foi(i,1,MAXN) {
    f[i] = mul(i, f[i-1]);
  }

  int n; cin >> n;

  vector<F> v; v.reserve(n);
  foi(i,0,n) {
    ll a,b;
    cin >> a >> b;
    v.push_back(F(a,b));
  }

  map<pll, ii> pos;
  int ind = 0;

  for (auto x : v) {
    int s1 = s(x.a), s2 = s(x.b);
    if (s1 != 0 && s2 != 0) {
      if (s1 == s2) {
        pos[x.get()].first++;
      } else {
        auto w = x.get();
        swap(w.first, w.second);
        pos[w].second++;
      }
    } else {
      if (s1 == 0 && s2 == 0) {
        ind++;
      } else if (s1 == 0) {
        pos[{0,0}].first++;
      } else if (s2 == 0) {
        pos[{0,0}].second++;
      }
    }
  }

  int ans = 1;
  for (auto x : pos) {
    auto cnt = x.second;
    int maxi = max(cnt.first, cnt.second);
    int tot = 1;
    for (int i = 1; i <= maxi; ++i) {
      if (i <= cnt.first) {
        tot = add(tot, choose(cnt.first, i));
      }
      if (i <= cnt.second) {
        tot = add(tot, choose(cnt.second, i));
      }
    }
    ans = mul(ans, tot);
  }

  cout << add(sub(ans, 1), ind) << '\n';
  return 0;
}


Measured memory_bytes: 19452
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  string n;
  cin >> n;
  
  if(n=="ABC")cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
}



Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <cstdlib>
#include <iomanip>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <iterator>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <cstring>
#include <sstream>
#include <stack>
#include <random>

using namespace std;

#define vi vector<int> 
#define vvi vector<vi>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define io ios::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(a) int((a).size()) 
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define loop(i,b) for (int i = 0; i < b; ++i)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define INF numeric_limits<int>::max()
#define LLINF numeric_limits<ll>::max()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define F first
#define S second
#define MOD 1000000007
#define cflout(x) cout << fixed << setprecision(8) << x << endl
#define setzero(x) memset(x, 0, sizeof(x))

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

random_device _random_device;
default_random_engine _generator(_random_device());
uniform_int_distribution<long long unsigned> _distribution(0, 0xFFFFFFFFFFFFFFFF);

inline long long unsigned get_random_number() {
    return _distribution(_generator);
}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

inline ll nxt() {
	ll x;
	cin >> x;
	return x;
}

namespace aux {	
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) {
		v.emplace_back(x);
    }
    return v;
}
}

int main() {
	io;
	int x, t;
	cin >> x >> t;

	cout << max(0, x-t) << endl;



	return 0;
}


















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};

int N;
vector<ll> A;

bool impossible(){
  // 葉ではないノードの子は1つか2つのどちらかであるが、
  // とりあえず子が2つずつだと仮定してノード数を計算していき、
  // 途中で0以下になったらその深さにノードが存在できないのでアウト
  ll nodes = 1;
  for (int i=0; i<=N; i++){
    // 深さiのノードは現在 nodes 個存在する。
    nodes -= A[i]; // 葉の数は A[i] 。この分だけサヨナラすると考える
    // 現時点で子(深さi+1)を持てるノードは nodes 個存在する。
    nodes *= 2; // とりあえず全部双子と仮定
    if (nodes > 100100100100100) return false;
  }
  return nodes < 0;
}

int main() {
  cin >>N;
  A.assign(N+1, 0); rep(i, N+1) cin >>A[i];
  // if (impossible()){
    // cout <<-1 <<endl; return 0;
  // }

  // とりあえず子が多すぎて親が足りなくなることはない。
  // じゃあ子を過不足なくやるにはどうすればいいか
  // 当然だが葉の総数は A[0] + A[1] + ... + A[N] になる
  vector<ll> Asum(N+2, 0); Asum[N] = A[N];
  rep(i, N){
    Asum[N-1-i] = Asum[N-i] + A[N-1-i];
    // cout <<"Asum[" <<N-1-i <<"] = Asum[" <<N-i <<"] + A[" <<N-1-i <<"];" <<endl;
  }
  // rep(i, N+2){
    // cout <<"Asum[" <<i <<"] = " <<Asum[i] <<endl;
  // }

  ll res = 1;   // 根
  ll nodes = 1; // 深さ0のノードは1個(根)
  for (int i=0; i<=N; i++){
    // 深さiのノードは現在 nodes 個存在する。
    nodes -= A[i];
    // 現時点で子を持てるノードは nodes 個存在する。
    // 各々の子の数の和が深さi+1以降の葉の総数、乃ちAsum[i+1]を超えるとマズい(葉が多くなりすぎる)
    // それを超えないようにできるだけ多くのnodesを確保する
    // cout <<"nodes = " <<nodes <<endl;
    if (nodes < 0){
      cout <<-1 <<endl; return 0;
    }
    if (nodes > Asum[i+1]){
      cout <<-1 <<endl; return 0;
    }
    nodes = min(nodes*2, Asum[i+1]);
    res += nodes;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 4788
n = int(input())
a = [0]*120
for i in range(n):
	b, f, r, v = map(int, input().split())
	t = (b - 1) * 30 + (f - 1) * 10 + r - 1
	a[t] += v
for i in range(120):
	print(' %d'  % a[i], end="")
	if i % 10 == 9:
		print("")
	if i % 30 == 29 and i < 100:
		for c in range(20):
			print("#", end="")
		print("")



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

int N, K;
const long long MOD = 1000000007;
const int MAX = 300000;
long long fac[MAX];
long long finv[MAX];

long long modPow(int a, int n) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    long long t = modPow(a, n / 2);
    return t * t % MOD;
  }
  return modPow(a, n - 1) * a % MOD;
}

void cominit() {
  fac[0] = 1;
  fac[1] = 1;
  finv[0] = 1;
  finv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;  
    finv[i] = finv[i-1] * (modPow(i, MOD - 2) % MOD) % MOD;
  } 
}

long long comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;  
}


void solve() {
  cominit();
  long long ans = 1;
  int max;
  if (N > K) { max = K; }
  else { max = N - 1; }
  for (int i = 1; i <= max; i ++) {
    ans += comb(N, i) * (comb(N - 1, N - i - 1) % MOD) % MOD;
  }

  printf("%lld\n", (ans + MOD) % MOD);
}

int main() {
  cin >> N >> K;

  solve();
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];

    vector<long long> pre(A), post(A);
    FOR(i, 2, N){
        pre[i] += pre[i-2];
        post[N-i-1] += post[N-i+1];
    }

    // dp[i][j] = i 番目を選んで飛ばした個数が j のときの最大値
    vector<vector<long long>> dp(N, vector<long long>(3, -1e+18));
    dp[0][0] = A[0];
    dp[1][1] = A[1];
    if(N%2 == 1) dp[2][2] = A[2];
    REP(i, N){
        if(i >= 2) dp[i][0] = dp[i-2][0] + A[i];
        if(i >= 3) dp[i][1] = max(dp[i-2][1], dp[i-3][0]) + A[i];
        if(N%2 == 1 and i >= 4) dp[i][2] = max({dp[i-2][2], dp[i-3][1], dp[i-4][0]}) + A[i];
    }
    if(N%2 == 0) cout << max(dp[N-2][0], dp[N-1][1]) << endl;
    if(N%2 == 1) cout << max({dp[N-3][0], dp[N-2][1], dp[N-1][2]}) << endl;

    return 0;
}

Measured memory_bytes: 18836
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
#define N 200010
#define M 1010

using namespace std;
int n, m, a[N], fath[N];

int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

int father(int x) {
	if (fath[x] != x) fath[x] = father(fath[x]);
	return fath[x];
}

int main() {
	n = read(), m = read();
	for (int i = 1; i <= n; i++) fath[i] = i;
	for (int i = 1, x, y; i <= m; i++) {
		x = read(), y = read();
		int fx = father(x), fy = father(y);
		if (fx != fy) fath[fy] = fx;
	}
	for (int i = 1; i <= n; i++) a[father(i)]++;
	int ans = 0;
	for (int i = 1; i <= n; i++) ans = max(a[i], ans);
	cout << ans << "\n";
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int res;
  res = a - 2 * b;
  if (res > 0) {
    cout << res << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"
#define pii         pair<int, int>
#define dint        long double


void solve() {
    int n, m, x; cin >> n >> m >> x;
    int a[n][m];
    int cost[n];
    for(int i=0; i<n; i++) {
        cin >> cost[i];
        for(int j=0; j<m; j++) cin >> a[i][j];
    }
    int mn = 1e9;
    int lim = (1LL << n);
    for(int msk=0; msk<lim; msk++) {
        int b[m]; memset(b, 0, sizeof b);
        int cur = 0;
        for(int i=0; i<n; i++) if((1LL << i) & msk) {
            cur += cost[i];
            for(int j=0; j<m; j++) {
                b[j] += a[i][j];
            }
        }
        bool all = true;
        for(int i=0; i<m; i++) {
            if(b[i] < x) {
                all = false; break;
            }
        }
        if(all) {
            mn = min(mn, cur);
        }
    }
    if(mn == 1e9) {
        cout << -1 << endl;
    } else {
        cout << mn << endl;
    }
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    // cin >> T;
    for(int i=1; i<=T; i++) {
        solve();
    }
    return 0;
}

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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
    if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;
void  solve()
{
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n>0)
    {
        ans++;
        n/=k;
    }  
    cout<<ans<<endl;
}   


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

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int isprime(int x);
int main(void)
{
	int n,A[10000],count,i,j;
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++)
	{
		scanf("%d",&A[i]);
	}
	
	count = 0;
	for(j=0; j<n;j++)
	{
		if(isprime(A[j])==1)
		{
			count++;
		}
	}
	printf("%d\n",count);
	
	return 0;
}
	
int isprime(int x)
{

	int i;	
	if(x==2)
	{
		return 1;
	}
	if(x< 2 || x%2==0)
	{
		return 0;
	}
	
	i = 3;
	
	while(i<= sqrt(x))
	{
		if(x%i==0)
		{
			return 0;
		}
		i+=2;
	}
	return 1;
}
	


Measured memory_bytes: 2044
n = int(input())
a = list(map(int, input().split()))
 
count = 1
k = 0       #break time
 
for i in range(n):
    if a[i] == count:
        count += 1
    else:
        k += 1
 
if k == n:
    k = -1
 
print(k)

Measured memory_bytes: 26140
n = int(input())
s = input()
ans = s.count("R")*s.count("G")*s.count("B")


for i in range(n):
    p = s[i]
    for j in range(i,n):
        if s[j] != p:
            q = s[j]
            if 2 * j - i < n:
                if s[2*j-i] != p and s[2*j-i] != q:
                     ans -= 1

print(ans)

Measured memory_bytes: 73716
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;
	cin >> n >> a >> b;
	int num = 0;
	int numb = 0;
	string s;
	cin >> s;
	REP(i,n){
		switch (s[i])
		{
			case 'a':
				if(num < a+b){
					cout << "Yes" << endl;
					num++;
				}else cout << "No" << endl;
				break;
			case 'b':
				if(num < a+b && numb < b){
					cout << "Yes" << endl;
					num++;numb++;
				}
				else cout << "No" << endl;
				break;
			default:
				cout << "No" << endl;
				break;
		}
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = (1LL << 60)-1;

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

  int n, k; cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  ll dp[101010] = {};
  rep(i, 101010) dp[i] = INF;
  dp[0] = 0;
  rep(i, n) {
    for(int j = 1; j <= k; j++) {
      dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout << dp[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<set>
using namespace std;
int main()
{
	set<int> s1; 
	set<int> s2; 
	s1.insert(1);
	s1.insert(3);
	s1.insert(5);
	s1.insert(7);
	s1.insert(8);
	s1.insert(10);
	s1.insert(12);
	s2.insert(4);
	s2.insert(6);
	s2.insert(9);
	s2.insert(11);
	int x,y;
	cin>>x>>y;
	if(x==2||y==2)
	{
		cout<<"No"<<endl;
		exit(0);
	}
	else if(s1.find(x)!=s1.end()&&s1.find(y)!=s1.end())
	{
		cout<<"Yes"<<endl;
		exit(0);
	}
	else if(s2.find(x)!=s2.end()&&s2.find(y)!=s2.end())
	{
		cout<<"Yes"<<endl;
		exit(0);
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    n, m = getList()
    nums = getList()
    peaks = [[] for i in range(n)]

    for i in range(m):
        a,b = getZList()
        peaks[a].append(b)
        peaks[b].append(a)
    ans = 0
    for i, num in enumerate(nums):
        flg = True
        for p in peaks[i]:
            if nums[p] >= num:
                flg = False

        if flg:
            ans += 1

    print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 99752
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
//#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <string>
//#include <cstring>
#include <algorithm>
#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod) }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    ll H, W, N;
    cin >> H >> W >> N;

    set<pair<ll, ll>> coords;

    for (int i = 0; i < N; i++)
    {
        pair<ll, ll> aux;
        cin >> aux.second >> aux.first;
        coords.insert(aux);
    }

    vector<ll> count(10);
    count[0] = (H - 2) * (W - 2);

    int adderx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
    int addery[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};

    set<pair<ll, ll>> checked;

    for (auto coord : coords)
    {
        for (int c = 0; c < 9; c++)
        {
            ll x = coord.first + adderx[c];
            ll y = coord.second + addery[c];

            if (x < 2 || x > W - 1 || y < 2 || y > H - 1)
                continue;
            pair<ll, ll> aux(x, y);

            if (checked.find(aux) != checked.end())
                continue;
            checked.insert(aux);

            int surr = 0;

            for (int l = 0; l < 9; l++)
            {
                ll x2 = x + adderx[l];
                ll y2 = y + addery[l];

                if (x2 < 1 || x2 > W || y2 < 1 || y2 > H)
                    continue;

                pair<ll, ll> aux2(x2, y2);

                if (coords.find(aux2) != coords.end())
                {
                    surr++;
                }
            }
            count[surr]++;
        }
    }

    for (int i = 1; i < 10; i++)
    {
        count[0] -= count[i];
    }

    for (int i = 0; i < 10; i++)
    {
        cout << count[i] << "\n";
    }
}


Measured memory_bytes: 62720
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int n, m, x; cin >> n >> m >> x;
	vector<int> a(n+1, 0);
	for(int i = 0; i < m; i++){
		int tmp; cin >> tmp;
		a[tmp]++;
	}
	int sum = accumulate(a.begin(), a.end(), 0);
	int sum_x = accumulate(a.begin()+x, a.end(), 0);
	cout << min(sum_x, sum - sum_x) << endl;
}


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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n)
        cin >> a[i];
    vector<int> cpy = a;
    sort(ALL(cpy));
    REP(i,n) 
    {
        if (a[i] == cpy[n-1]) 
            cout << cpy[n-2] << endl;
        else
            cout << cpy[n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <queue>
using namespace std;
int main()
{
    char ch1[4];
    char ch2[4];
    char ch3[4]={0};//1
    char ch4[4]={0};//2
    scanf("%s %s",ch1,ch2);
    int i;
    for(i=0; i<3; i++)
    {
        ch3[i]=ch1[2-i];
        ch4[i]=ch2[2-i];
    }
    if(strcmp(ch3,ch2)==0&&strcmp(ch4,ch1)==0)
    {
        printf("YES\n");
    }
    if(strcmp(ch3,ch2)!=0||strcmp(ch4,ch1)!=0)
    {
        printf("NO\n");
    }
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (size_t i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

const static int MAX_N = 100010;
vector<vector<pair<int, llong> > > G;
int visit[MAX_N + 1] = {};
llong dist[MAX_N + 1] = {};

void dfs(int s, llong cost) {
    if (visit[s] == 1) return;

    visit[s] = 1;
    for (size_t i = 0; i < G[s].size(); ++i) {
        if (visit[G[s][i].first] == 1) continue;

        dist[G[s][i].first] = G[s][i].second + cost;
        dfs(G[s][i].first, dist[G[s][i].first]);
    }

    return;
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    G.resize(n);
    rep(i, n - 1) {
        int a, b;
        llong c;
        cin >> a >> b >> c;
        G[a - 1].push_back(make_pair(b - 1, c));
        G[b - 1].push_back(make_pair(a - 1, c));
    }

    int q, k;
    cin >> q >> k;

    dfs(k - 1, 0);

    vector<llong> ans(q);
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        ans[i] = dist[x - 1] + dist[y - 1];
    }

    rep(i, q) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 13952
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll A,B,C;
ll dfs(vll &l,ll n,ll a,ll b,ll c,ll cu){
  if(cu==n){
    if(min(min(a,b),c)>0){
    return abs(A-a)+abs(B-b)+abs(C-c)-30;
    }
    else{
      return INF;
    }
  }
  ll w1=dfs(l,n,a,b,c,cu+1);
  ll w2=dfs(l,n,a+l[cu],b,c,cu+1)+10;
  ll w3=dfs(l,n,a,b+l[cu],c,cu+1)+10;
  ll w4=dfs(l,n,a,b,c+l[cu],cu+1)+10;
  return min(w1,min(w2,min(w3,w4)));
}
int main(){
  ll n;
  cin>>n>>A>>B>>C;
  vll l(n);
  rep(i,n) cin>>l[i];
  COUT(dfs(l,n,0,0,0,0));
}

Measured memory_bytes: 256
use proconio::{input, fastout, marker::Chars};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h]
    }

    let mut ans = 0;
    for bit_i in 0..1 << h {
        for bit_j in 0..1 << w {
            let mut n = 0;
            for i in 0..h {
                for j in 0..w {
                    if bit_i & (1 << i) == 0 && bit_j & (1 << j) == 0 && c[i][j] == '#' {
                        n += 1;
                    }
                }
            }
            if n == k { ans += 1 }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        q_2();
    }

    private static void q_1() {
        try (Scanner scan = new Scanner(System.in)) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();

            System.out.println(b / a < c ? b / a : c);
        }
    }

    private static void q_2() {
        try(Scanner scan = new Scanner(System.in)) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int c = scan.nextInt();

            int min = Math.min(a, b);

            int cnt = 0;
            for (; min >= 1; min--) {
                if (a % min == 0 && b % min == 0) {
                    cnt ++;
                    if(cnt == c) {
                        break;
                    }
                }
            }

            System.out.println(min);
        }
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,C;
    cin>>n>>C;
    vector<vector<int>> vec(C+1,vi(100002,0));
    rep(i,n){
        int s,t,c;
        cin>>s>>t>>c;
        vec[c][s-1]+=1;
        vec[c][t]+=-1;
    }
    for (int i=1;i<C+1;i++){
        int now=0;
        for (int j=0;j<100001;j++){
            now+=vec[i][j];
            if (now>0)vec[i][j]=1;
            else vec[i][j]=0;
        }
    }
    int ans=0;
    for (int i=0;i<100001;i++){
        int ans1=0;
        //cout<<i<<endl;
        for (int j=1;j<C+1;j++){
            //cout<<vec[j][i];
            if (vec[j][i])ans1+=1;
        }
        //cout<<endl;
        ans=max(ans,ans1);
    }
    cout<<ans<<endl;
    

    return 0;
}

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


using namespace std;
#define l long long int 
#define vi vector<int>
#define vvi vector<vector<int>>
#define rep(i,n) for (i = 0; i < n; i++) 
#define REP(i,k,n) for (i = k; i <= n; i++) 
#define REPR(i,k,n) for (i = k; i >= n; i--) 
#define pii pair<int,int>

int  main(int arg,char** argc)
{
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);    
    l s,w;
    cin>>s>>w;
    if(s>w)
    {
        cout<<"safe\n";
    }
    else{
        cout<<"unsafe\n";
    }
    return 0;
}


Measured memory_bytes: 3640
from bisect import bisect_left, bisect_right  # return index

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = L[i]+L[j]  # tmpはこの値より短くなくてはいけない

        ### ここから下は二分探索
        ix = bisect_left(L, tmp)
        ans += ix-(j+1)

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int m, d;
	cin >> m >> d;
	int cnt = 0;

	for(int i=1; i<=d; i++) {
		int d1, d2, result;
		d1 = i / 10 ;
		d2 = i % 10;
		result = d1 * d2;
		if (result == 0 || d1 < 2 || d2 < 2) continue;
		if (result <= m) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, d, x;
  cin >> n >> d >> x;
  d--;
  rep(i, n) {
    ll a;
    cin >> a;
    x += d/a + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

vector<int> water;
vector<int> suger;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    rep(i, F + 1) {
        rep(j, F + 1) {
            int wa = (A*i + B*j) * 100;
            if (wa <= F&&wa != 0) {
                water.push_back(wa);
            }
        }
    }

    rep(i, F + 1) {
        rep(j, F + 1) {
            int su = C*i + D*j;
            if (su <= F) {
                suger.push_back(su);
            }
        }
    }

    double macon = 0;
    int masugerwater = 0, masuger = 0;
    rep(i, water.size()) {
        rep(j, suger.size()) {
            if (water[i] + suger[j] <= F) {
                double con = (double)(suger[j] * 100.0 / water[i]);
                if (con <= E&&macon <= con) {
                    macon = con;
                    masugerwater = water[i] + suger[j];
                    masuger = suger[j];
                }
            }
        }
    }
    cout << masugerwater << ' ' << masuger << endl;
}

Measured memory_bytes: 1400
n_s = input()
n = int(n_s)
ans = 0
for i in range(1, len(n_s)):
    if i % 2 == 1:
        ans += 10**i - 10 ** (i-1)
if len(n_s) % 2 == 1:
    ans += 1 + n - 10 ** (len(n_s) - 1)
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  string S;
  cin >> S;
  
  int mm = stoi(S.substr(5,2));
  
  if(mm>4) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }
    
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int>::reverse_iterator rit; for(rit=s.rbegin();rit!=s.rend();rit++)
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e6+8;
inline ll read(){ll s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
using namespace std;

int t,n,m,k,ans=0,cnt=0;
char a[N]={0};
int b[N]={0},dp[N][2]={0};
int main(){
    scanf("%s",a+1);
    int len=strlen(a+1);
    for(int i=1;i<=len;i++) b[i]=a[i]-'0';
    dp[len][0]=b[len],dp[len][1]=10-b[len];
    for(int i=len-1;i>=0;i--){
        dp[i][0]=min(dp[i+1][0]+b[i],dp[i+1][1]+b[i]+1);
        dp[i][1]=min(dp[i+1][0]+10-b[i],dp[i+1][1]+9-b[i]);
    }
    printf("%d\n",min(dp[0][0],dp[0][1]));
    return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
const ll MOD=1000000007;
int V;
const int MAX_V=100000;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
    G[u].pb(v); G[v].pb(u);
}

bool dfs(int v){
    used[v]=true;
    for(int &to : G[v]){
        int w=match[to];
        if(w<0||!used[w]&&dfs(w)){
            match[v]=to;
            match[to]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int res=0;
    memset(match, -1, sizeof(match));
    rep(v,0,V){
        if(match[v]<0){
            memset(used, 0, sizeof(used));
            if(dfs(v)){
                res++;
            }
        }
    }
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>V;
    rep(i,0,V){
        int a,b;
        cin>>a>>b;
        add_edge(a-1, b-1);
    }
    int k=bipartite_matching();
    cout <<(k*2==V?"Second":"First")<<"\n";
}


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

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        //Console.WriteLine("{0}: {1}", n, string.Join(" ", PrimeFactors(n)));
		Console.WriteLine("{0}: {1}", n, string.Join(" ", PrimeFactors(n).Select (x => x.ToString()).ToArray())); //AOJ??¨
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i * i <= n)
        {
            if(tmp % i == 0){
                tmp /= i;
                yield return i;
            }else{
                i++;
            }
        }
		if(tmp != 1) yield return tmp;
    }
}

Measured memory_bytes: 20252
x, y, a, b, c = map(int, input().split())
pqr = [map(int, input().split()) for i in range(3)]

A = []
for i in range(3):
        for j in pqr[i]:
                A.append([j, i])
A.sort(key=lambda x:-x[0])

ans = 0
cnt = 0
for v, t in A:
        if cnt==x+y: break
        if t==0:
                if x:
                        x -= 1
                        ans += v
        elif t==1:
                if y:
                        y -= 1
                        ans += v
        else:
                if x+y>cnt:
                        cnt += 1
                        ans += v
                else: break
print(ans)

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	string s, t;
	cin >> s >> t;

	vector<char> ans;
	rep(i, x){
		ans.push_back(s[i]);
		ans.push_back(t[i]);
	}

	for(auto a : ans) cout << a;
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    st s ;
    cin >> s ;
    int cnt = 0 ;
    for (lli i = 0 ; i < s.size() ; i ++)
    {
        if (s[i] == 'o')cnt ++ ;
    }
    cout << 700 + 100 * cnt ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 1 , 0 } ;
const int dy[] = { 0 , 1 , 0 , -1 } ;

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    string s ;
    cin >> s ;

    set < char > t ;
    for ( auto i : s )
        t.I ( i ) ;

    int z = t.size() ;

    if ( z == 1 ) cout << "No" ;
    else cout << "Yes" ;

    line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 256