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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  long long N, M; cin >> N >> M;
  vector<long long> v;
  for(int i = 1; i <= sqrt(M); ++i) {
    if(M % i == 0){
      v.emplace_back(i);
      v.emplace_back(M/i);
    }
  }
  sort(v.begin(), v.end());
  long long ans = 1;
  for(auto itr = v.begin(); itr != v.end(); ++itr) {
    if(*itr <= M/N) ans = *itr;
  }
  cout << ans << endl;

  return 0;
}


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

int main(void)
{
    int i;
    vector<int> v(3);

    cin >> v[0] >> v[1] >> v[2];

    sort(v.begin(), v.end());

    /*for (int x : v){
        if (x == v[2]){
            cout << x << "\n";
            break;
        }
        cout << x << " ";
    }*/

    for (i = 0; i < 2; i++){
        cout << v[i] << " ";
    }

    cout << v[2] << "\n";

    return (0);
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int main(){
    int n;
    int a = 2;
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    while(a * 2 <= n){
        a*=2;
    }
    cout << a << endl;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.trim().split("\n");
  var N = parseInt(input[0], 10);
  var A = input[1]
    .split(" ")
    .map((n) => parseInt(n, 10))
    .sort((a, b) => a - b);
  var B = input[2]
    .split(" ")
    .map((n) => parseInt(n, 10))
    .sort((a, b) => a - b);
  var C = input[3]
    .split(" ")
    .map((n) => parseInt(n, 10))
    .sort((a, b) => a - b);

  //２分探索 昇順である前提
  //mode="low"で求めたい数以下の数
  function serch2bu(list, num, mode) {
    var index = -1;
    var head = 0;
    var tail = list.length;
    if (mode == "low") {
      while (head <= tail) {
        var center = Math.floor((head + tail) / 2);
        var centerVal = list[center];

        if (centerVal < num) {
          head = center + 1;
        } else {
          tail = center - 1;
        }
      }
    } else if (mode == "high") {
      while (head <= tail) {
        var center = Math.floor((head + tail) / 2);
        var centerVal = list[center];

        if (centerVal <= num) {
          head = center + 1;
        } else {
          tail = center - 1;
        }
      }
    }
    return head;
  }
  var ans = 0;
  for (var i = 0; i < N; i++) {
    var a = serch2bu(A, B[i], "low");
    var b = N - serch2bu(C, B[i], "high");
    ans += a * b;
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n; cin >> n;
  vector<lint> a(n); for(lint i=0;i<n;i++) { cin >> a[i]; }
  
  lint b=0;
  for(int i=0;i<n;i++) { b ^= a[i]; }
  for(int i=0;i<n;i++) { cout << (b^a[i]) << " "; }
  cout << endl;
  return 0;
}


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

int main()
{
	int a[3],n;
	cin>>n;
	while(n>0){
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);

		if(a[0]*a[0] +a[1]*a[1]==a[2]*a[2]){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		n--;
	}
	return 0;
}

Measured memory_bytes: 3012
#include <cstdio>
using namespace std;

int main (void)
{
	int a, b, r, d;
	double f, i, j;

	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;

	i = a;
	j = b;

	f = i / j;

	printf("%d %d %lf\n", d, r, f);

	return 0;
}

Measured memory_bytes: 1064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <tuple>
#include <map>
using namespace std;

string S; int t = 0, maxn = 0;

int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
			t++; maxn = max(maxn, t);
		}
		else t = 0;
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

const int N=5e5+5;
int n,a[N];
char s[N];
long long ans;

signed main(){
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++) if(s[i]=='<')
		a[i+1]=a[i]+1;
	for(int i=n-1;i>=0;i--) if(s[i]=='>')
		a[i]=max(a[i],a[i+1]+1);
	for(int i=0;i<=n;i++) ans+=a[i];
	write(ans);
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX/2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}



template< typename T >
struct edge {
  int to,cap,rev;

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;

//-----CODE------//
//-----CODE------//

int DFS(vector<Edges<int> > & G, vector<bool> & used,int v,int t,int f)
{
  if(v == t) return f;
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++)
  {
    edge<int> &e = G[v][i];
    if(!used[e.to] && e.cap>0)
    {
      int d = DFS(G,used,e.to,t,min(f,e.cap));
    
    if(d > 0)
    {
      e.cap -= d;
      // DEBUG(e.cap);
      G[e.to][e.rev].cap += d;
      return d;
    }
    }
  }
  
  return 0;
}

void solve(void)
{
  int V,E;
  cin>>V>>E;
  vector<Edges<int> > EDGE(V);
  for (int i = 0; i < E; i++)
  {
    int A,B,C;
    cin>>A>>B>>C;
    edge<int> e;
    e.to = B;
    e.cap = C;
    e.rev = EDGE[B].size();

    EDGE[A].push_back(e);
    e.to = A;
    e.cap = 0;
    e.rev = EDGE[A].size()-1;
    EDGE[B].push_back(e);
  }
  
  int flow = 0;
  while(true)
  {

    vector<bool> used(V,false);
    int f = DFS(EDGE,used,0,V-1,INF);

    if(f == 0) break;
    flow += f;
  }
  
  cout<<flow<<endl;
  return; 
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}



Measured memory_bytes: 3240
from math import ceil

def main():
    N = int(input())
    AB = [list(map(int,input().split())) for _ in range(N-1)]

    Edge = [[] for _ in range(N + 1)]

    for i in range(N-1):
        a,b = AB[i]
        Edge[a].append((b,i))
        Edge[b].append((a,i))
    Ans = [-1]*N

    stack = [1]
    gone = [False]*(N + 1)
    gone[1] = True
    ans = 0
    Index = {1:0}
    while len(stack) > 0:
        color = 1
        start = stack.pop(-1)
        parent = Index[start]
        for e,index in Edge[start]:
            if not(gone[e]):
                Index[e] = start
                stack.append(e)
                gone[e] = True
                if parent == color:
                    color += 1
                    Ans[index] = color
                    Index[e] = color
                else:
                    Ans[index] = color
                    Index[e] = color
                color += 1
        ans = max(ans,color-1)
    print(ans)
    print(*Ans[:-1],sep="\n")
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 61752
import itertools
import copy
h, w, k = map(int, input().split())
lis = [list(map(str, *input().split())) for _ in range(h)]
gyo = list(itertools.product([0,1], repeat=h))
retu = list(itertools.product([0,1], repeat=w))
l = copy.deepcopy(lis)
ans =0
for i in gyo:
    for j in retu:
        scount = 0
        for x in range(h):
            if i[x] == 1:
                l[x] = ["."]*w
        for y in range(w):
            if j[y] == 1:
                for z in range(h):
                    l[z][y] = "."
        for p in range(h):
            scount += l[p].count("#")
        if scount == k:
            ans +=1
        l = copy.deepcopy(lis)
print(ans)


Measured memory_bytes: 73268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 998244353;

/* BIT: RAQ対応BIT
    初期値は a_1 = a_2 = ... = a_n = 0
    ・add(l,r,x): [l,r) に x を加算する
    ・sum(i): a_1 + a_2 + ... + a_i を計算する
    計算量は全て O(logn)
*/
template <typename T>
struct BIT {
    int n;             // 要素数
    T MOD;
    vector<T> bit[2];  // データの格納先
    BIT(int n_, T MOD_) { 
        init(n_); 
        MOD = MOD_;
    }
    void init(int n_) {
        n = n_ + 1;
        for (int p = 0; p < 2; p++) bit[p].assign(n, 0);
    }
    void add_sub(int p, int i, T x) {
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[p][idx] = (bit[p][idx] + x) % MOD;
        }
    }
    void add(int l, int r, T x) {  // [l,r) に加算
        add_sub(0, l, (-x * (l - 1) + MOD) % MOD);
        add_sub(0, r, ( x * (r - 1) + MOD) % MOD);
        add_sub(1, l, x);
        add_sub(1, r, (-x + MOD) % MOD);
    }
    T sum_sub(int p, int i) {
        T s(0);
        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s = (s+bit[p][idx])%MOD;
        }
        return s;
    }
    T sum(int i) { 
        return (sum_sub(0, i) + sum_sub(1, i) * i + MOD) % MOD; 
    }

    T get(int i){
        return (sum(i) - sum(i-1)+MOD) % MOD;
    }
};

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> L(K), R(K);
    for(int i = 0; i < K; i++) cin >> L[i] >> R[i];
    vector<ll> DP(N+1), DP2(N+1);
    DP[1] = 1; DP2[1] = 1;
    vector<ll> V;
    for(int i = 0; i < K; i++){
        for(int j = L[i]; j <= R[i]; j++) V.push_back(j);
    }


    BIT<ll> tree(N+1, MOD);
    tree.add(1, 2, 1LL);


    for(int i = 1; i < N; i++){
        ll SUM = tree.get(i);
        for(int k = 0; k < K; k++){
            // [L[k], R[k]]の区間の更新
            tree.add(i+L[k], i+R[k]+1, SUM);
        }
    }



    cout << tree.get(N) << endl;


}


Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b, c;
	cin >> a >> b >> c;
	int maxi = max(a, max(b, c));
	int sum = a + b + c;
	if(maxi == sum - maxi){
			cout << "Yes" << endl;
	}else{
			cout << "No" << endl;
	}
	return 0;
}


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

#define ll long long

int main() {
	ll n, a, b, max, min;
	cin >> n >> a >> b;
	if (n == 1 && b - a == 0)cout << 1 << endl;
	else if (n == 1 && b - a != 0)cout << 0 << endl;
	else if (b - a < 0)cout << 0 << endl;
	else if (n == 2)cout << 1 << endl;
	else {
		max = b * (n - 2);
		min = a * (n - 2);
		cout << max - min + 1 << endl;
	}
	return 0;
}

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

int dir[]{-1, 1, 0, 0};

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

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

    mf_graph<int> G(n * m + 2);
    int from = n * m, to = n * m + 1;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if(grid[i][j] == '#') continue;
            if((i + j) % 2 == 0) {
                G.add_edge(from, i * m + j, 1);
                for (int d = 0; d < 4; ++d) {
                    int y = i + dir[d];
                    int x = j + dir[3-d];
                    if(y < 0 || y >= n || x < 0 || x >= m) continue;
                    if(grid[y][x] == '#') continue;
                    G.add_edge(i * m + j, y * m + x, 1);
                }
            } else {
                G.add_edge(i * m + j, to, 1);
            }
        }
    }

    cout << G.flow(from, to) << endl;

    vector<mf_graph<int>::edge> E = G.edges();

    for (int i = 0; i < E.size(); ++i) {
        if(E[i].flow == 0) continue;
        if(E[i].from == from || E[i].to == to) continue;
        pair<int, int> a(E[i].from / m, E[i].from % m);
        pair<int, int> b(E[i].to / m, E[i].to % m);
        if(a > b) swap(a, b);
        if(a.first + 1 == b.first) {
            grid[a.first][a.second] = 'v';
			grid[b.first][b.second] = '^';
        } else {
            grid[a.first][a.second] = '>';
            grid[b.first][b.second] = '<';
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << grid[i] << endl;
    }
}


Measured memory_bytes: 5488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define for1(i, m, n) for (int i = m; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a[100000];
    cin >> n;
    ll sum = 0, max = -1000000, min = 1000000;
    rep(i, n) {
        cin >> a[i];
        if (a[i] > max) {
            max = a[i];
        }
        if (a[i] < min) {
            min = a[i];
        }
        sum += a[i];
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 171, task a, 2020/06/21
//ms,
/*
*/

int main(void){
  char alpha;
  cin >>alpha;
  if('a'<=alpha) cout<<'a';
  else cout <<'A';
  return 0;
}
/*
*/


Measured memory_bytes: 3620
import numpy as np

N, Y = map(int,input().split())

n_max10000 = int(Y / 10000)

ans = '-1 -1 -1'
for i in range(n_max10000 + 1): #10000札をi枚
  n_max5000 = int((Y - 10000 * i) / 5000)
  for j in range(n_max5000 + 1): #5000札をj枚
    if 10000*i + 5000*j + 1000*(N-i-j) == Y: 
      n_bill = [i, j, N-i-j]
      ans = str(n_bill[0]) +' '+ str(n_bill[1]) +' '+ str(n_bill[2])
      
print(ans)

Measured memory_bytes: 12504
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

bool dp[110][110][15];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    rep(i,110)rep(j,110)rep(k,15) dp[i][j][k] = false;
    int N;
    cin >> N;
    vector<int> x(N);
    for(int i=0; i<N; i++){
        cin >> x[i];
    }
    int M;
    cin >> M;
    vector<int> a(M),b(M),c(M);
    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i] >> c[i];
        b[i]--;c[i]--;
    }
    for(int i=0; i<N; i++){
        for(int k=0; k<M; k++){
            if(a[k] == x[i]){
                dp[i][i+1][k] = true;
            }
        }
    }
    for(int i=2; i<=N; i++){
        for(int l=0; l<=N-i; l++){
            for(int m=l+1; m<l+i; m++){
                for(int k=0; k<M; k++){
                    dp[l][l+i][k] |= dp[l][m][b[k]] & dp[m][l+i][c[k]];
                    // if(dp[l][l+i][k]){
                    //     cout << l << " " << l+i << " " << k << "\n";
                    // }
                }
            }
        }
    }
    // for(int i=0; i<=N; i++){
    //     for(int j=i+1; j<=N; j++){
    //         for(int k=0; k<M; k++){
    //             cout << i << " " << j << " " << k << "\n";
    //             cout << dp[i][j][k] << "\n";
    //         }
    //     }
    // }
    if(dp[0][N][0]){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 3392
import java.util.Scanner;

/**
 * Created by kyosuke on 2016/05/27.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int num = sc.nextInt();
            if (num == 0) break;
            System.out.println(prime(num * 2) - prime(num));
        }

    }

    public static int prime(int num) {
        // ?´???°??????????????°
        boolean isPrime = false;
        if (num == 1) {
            return 0;
        } else if (num == 2) {
            return 1;
        }

        // ?´???°?????°???????????????
        int count = 2; // 2,3?????\?????????????????§???????????????????????¨????????????????????????
        // 4????´???°??§??????????????§?¨?????????????
        // i += 2 ??????????????¨??§??¶??°????´???°?¨????????????????2??\????????¶??°????´???°??§??????????????????
        for (int i = 5; i <= num; i += 2) {
            // ?´???°??????????±?(i)????´???°??????????±?(j)??????????????\?????§????????????
            for (int j = 2; j * j <= i; j++) {
                // ????????§????????´???????´???°??§????????????????????????????????????
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
                isPrime = true;
            }
            if (isPrime) {
                count++; // ?´???°???????????????
                // ?????????????????§??????????????¢??????
                // System.out.println("PrimeNumber -> " + i);
            }
        }
        return count;
    }
}

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

int main(){
  int x;
  char s[100];
  stack<int> STK;
  int a,b;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        a = STK.top();
        STK.pop();
        b = STK.top();
        STK.pop();
        STK.push( b + a );
    } else if ( s[0] == '-' ){
        a = STK.top();
        STK.pop();
        b = STK.top();
        STK.pop();
        STK.push( b - a );
    } else if ( s[0] == '*' ){
        a = STK.top();
        STK.pop();
        b = STK.top();
        STK.pop();
        STK.push( b * a );
    } else {
        x = atoi(s);
        STK.push(x);
    }
    //cout << STK.top() << endl;
  }

  printf("%d\n",STK.top());

  return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
long long a,b,k;
int main(){
    cin>>k>>a>>b;
    if(k<=a){
        cout<<"1"<<endl;return 0;
    }
    else if(a<=b){
        cout<<"-1"<<endl;return 0;
    }
    else cout<<(((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mx = 1e9+5;
int main()
{
	//freopen("in", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin>>n>>k;
	ll ar[n], dp[n];
	for(int i = 0; i<n; i++){cin>>ar[i];}
	memset(dp, mx, sizeof(dp));
	dp[0]=0;
	for(int i = 0; i<n; i++){
		for(int j=i+1; j<=i+k; j++){
			if(j<n){
				dp[j] = min(dp[j], dp[i]+abs(ar[j]-ar[i]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
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;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  vector<int> dp(n,INF);
  dp[0]=0;
  for(int i=1; i<n; i++){
    chmin(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
    if(i>1) chmin(dp[i],dp[i-2]+abs(a[i]-a[i-2])); 
  }
  cout << dp[n-1] << endl;
}


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

public static class Program
{
    public static void Main(string[] args)
    {
        var inputs1 = Console.ReadLine().Trim().Split(' ');
        var inputs2 = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(inputs1[0]);
        var k = int.Parse(inputs1[1]);

        var count = 0;
        for (var i = 0; i < n; i++)
        {
            var h = int.Parse(inputs2[i]);
            if (h >= k) count++;
        }
        Console.WriteLine(count.ToString());
    }
}

Measured memory_bytes: 17504
#include<bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long double ld;
const ld E = 1E-6;
struct pnt{
	ld x, y;
	pnt(){}
	pnt(ld x, ld y) : x(x), y(y) {}
	bool operator<(const pnt &b){
		return (abs(x - b.x) > E)? x < b.x : y < b.y;
	}
	pnt operator+(const pnt &b){
		return pnt(x + b.x, y + b.y);
	}
	pnt operator-(const pnt &b){
		return pnt(x - b.x, y - b.y);
	}
	pnt operator*(ld a){
		return pnt(a * x, a * y);
	}
	ld operator%(const pnt &b){
		return x * b.y - b.x * y;
	}
};
struct line{
	pnt p, v; //(x, y) = p + t * v
	line(){}
	line(pnt a, pnt b){
		v = b - a;
		p = b;
	}
	pnt operator*(line b) { //Intersección (Antes de debe comprobar de que se intersectan)
		pnt c = p - b.p, d = b.v - v; //d = (d.x * t, d.y * t)
		ld t = (b.v.y * (p.x - b.p.x) - (p.y - b.p.y) * b.v.x) / (v.y * b.v.x - b.v.y * v.x);
		//cout<<"El t es: "<<t<<"\n";
		return p + (v * t);
	}
};
ld direction(pnt a, pnt b, pnt c){
	a = b - a;
	b = c - b;
	return a % b;
}
ld area(vector<pnt> &poly){
	int n = poly.size() - 1;
	ld ret = 0;
	//poly.push_back(poly[0]);
	forn(i, n){
		//cout<<poly[i].x<<" "<<poly[i].y<<"\n";
		ret += poly[i] % poly[i + 1];
	}
	return abs(ret) / 2;
}
int main(){
	int n, q;
	pnt aux;
	cin>>n;
	vector<pnt> poly(n);
	forn(i, n) cin>>poly[i].x>>poly[i].y;
	poly.push_back(poly[0]);
	//aux = line(pnt(0, 2), pnt(7, 4)) * line(pnt(1, 5), pnt(5, 1));
	//cout<<aux.x<<" "<<aux.y<<"\n";
	cin>>q;
	while(q--){
		pnt a, b;
		vector<pnt> res;
		cin>>a.x>>a.y>>b.x>>b.y;
		forn(i, n){
			ld v = direction(a, b, poly[i]);
			ld w = direction(a, b, poly[i + 1]);
			//cout<<i<<" "<<v<<" "<<w<<"\n";
			//Tres casos posibles
			if(v >= 0 && w >= 0){ //Si ambos están dentro
				//cout<<i<<" Ambos dentro\n";
				res.push_back(poly[i]);
			} else if(v >= 0 && w < 0){ //Si el primero está adentro y el siguiente afuera
				//cout<<i<<" Primero dentro\n";
				res.push_back(poly[i]);
				aux = line(poly[i], poly[i + 1]) * line(a, b);
				//cout<<aux.x<<" "<<aux.y<<"\n";
				res.push_back(aux);
			} else if(v < 0 && w >= 0){ //Si el primero está afuera y el siguiente adentro
				//cout<<i<<" Segundo dentro\n";
				aux = line(poly[i], poly[i + 1]) * line(a, b);
				//cout<<aux.x<<" "<<aux.y<<"\n";
				res.push_back(aux);
			} else{
				//cout<<i<<" Ambos fuera\n";
			}
		}
		if(!res.size()){
			cout<<fixed<<setprecision(8)<<0.0<<"\n";
			continue;
		}
		res.push_back(res[0]);
		cout<<fixed<<setprecision(8)<<area(res)<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3324
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import sys
#input=sys.stdin.readline
sys.setrecursionlimit(3000)
import re
import math
import itertools
import collections
import bisect
import fractions
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.1415926535897932
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
# fractions.gcd(x,y)
def lcm(a,b): return a*b//fractions.gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def eof(t): print(t); exit()


h,w,k=map(int,input().split())
d=[input() for i in range(h)]
ans=0
chk=2**(h+w)
for i in range(chk):
    a="000000000000"+bin(i)[2:]
    a=a[::-1]
    cnt=0
    for j in range(h*w):
        y=j//w
        x=j%w
        if a[y]=="0" and a[h+x]=="0" and d[y][x]=="#":
            cnt+=1
    if cnt==k:
        ans+=1


print(ans)

Measured memory_bytes: 79156
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 1005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,m; ll ar[N]; vector<ll> vc[N]; ll dp[N][(1LL<<13)];
ll maxval(ll i,ll mask){
	if(__builtin_popcountll(mask)==n) return 0;
	if(i==m+1){
		return 1e15;
	}
	if(dp[i][mask]!=-1){
		return dp[i][mask];
	}
	ll a,b;
	a=maxval(i+1,mask);
	ll new_mask=mask;
	for(auto it:vc[i]){
		ll k=(1LL<<(it-1));
		new_mask=(new_mask|k);
	}
	b=maxval(i+1,new_mask)+ar[i];
	return dp[i][mask]=min(a,b);	
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(i=1;i<=m;i++){
		cin>>ar[i]>>k;
		for(j=1;j<=k;j++){
			cin>>l;
			vc[i].ps(l);
		}
	}

	ll an=maxval(1,0);
	if(an>=1e15){
		cout<<"-1";
	}
	else cout<<an;
	return 0;
}

Measured memory_bytes: 64884
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}


int main() {
    string s;
    cin >> s;

    V flag(2, true);

    string ss[2] = {"RUD", "LUD"};

    rep(i, s.size()) {
        bool ok = false;
        rep(j, 3) {
            if (s[i] == ss[i%2][j]) {
                ok = true;
            }
        }
        if (!ok) flag[i%2] = false;
    }

    bool pass = true;
    rep(i, 2) {
        if(!flag[i]) {
            pass = false;
        }
    }
    
    if(pass) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  for {
    h := nextInt()
    w := nextInt()
	if h == 0 && w == 0 {
		break
	}
	for i := 0; i < h; i++ {
		line := ""
		for j := 0 ; j < w; j++ {
			if i == 0 || i == h -1 {
		        line += "#"
			} else {
		        if j == 0 || j == w -1{
		          line += "#"
		        } else {
		          line += "."
		        }
		    }
		}
		fmt.Println(line)
	}
	fmt.Println()
  }

}

func getStdin() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 3520
import Control.Arrow (second)
import Data.Bits
import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B

solve :: Int -> V.Vector Int -> Int
solve k xs = maximum
  [ f c | i <- [0 .. sizeOf k], let c = candidate i, c <= k ]
 where
  sizeOf x = finiteBitSize x - countLeadingZeros x

  minority :: Int -> V.Vector Int -> Int
  minority i =
    (\(count0, count1) -> if count0 <= count1 then 0 else 1) . V.foldl'
      ( \(count0, count1) b ->
        if testBit b i then (count0, count1 + 1) else (count0 + 1, count1)
      )
      (0, 0)

  maxF :: Int
  maxF = V.foldl' (\acc m -> acc * 2 + m) 0 $ V.unfoldrN
    (sizeOf k)
    (\i -> if i < 0 then Nothing else Just (minority i xs, i - 1))
    (sizeOf k - 1)

  trailing1Bit n = 2 ^ n - 1

  f n = V.sum $ V.map (`xor` n) xs

  candidate n =
    let top    = k .&. foldl' (.|.) 0 (map bit [n .. sizeOf k])
        buttom = maxF .&. foldl' (.|.) 0 (map bit [0 .. (n - 1)])
    in  top + buttom

main = do
  nk <- V.unfoldrN 2 (fmap (second B.tail) . B.readInt) <$> B.getLine
  xs <- V.unfoldrN (nk V.! 0) (fmap (second B.tail) . B.readInt) <$> B.getLine
  print $ solve (nk V.! 1) xs


Measured memory_bytes: 14716
K = int(input())

total_n = 9
n = K
A = list(range(1,10))

for i in range(1000):
    if total_n >= K:
        break

    else:
        n -= len(A)
        temp = []
        for num in A:
            amari = int(str(num)[-1])
            moto = num * 10
            if amari !=0 and amari % 10 != 9:
                temp.extend([moto + amari - 1, moto+amari, moto + amari + 1]) 
                total_n += 3
            elif amari == 0:
                temp.extend([moto+amari, moto + amari + 1])
                total_n += 2
            else:
                temp.extend([moto + amari - 1, moto+amari])
                total_n += 2
        A = temp

print(A[n-1])




Measured memory_bytes: 46684
/* minmaxsum.cc
 */
#include <iostream>
using namespace std;

int N, A[10010]; // ?°?????????????????????????

int min() {
  int min = A[0];
  for (int i = 0; i < N; ++i)
    if (A[i] < min)
      min = A[i];	  
  return min;
}

int max() {
  int max = A[0];
  for (int i = 0; i < N; ++i)
    if (A[i] > max)
      max = A[i];
  return max;
}

 long long sum() {
   long long sum = 0;
   for (int i = 0; i < N; ++i)
     sum = sum + A[i];
  return sum;
}

int main() {
  cin >> N;
  for (int i=0; i<N; ++i)
    cin >> A[i];
  cout << min() << " " << max() << " " << sum() << endl;
}

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

int main(){
    int n,m;
    cin>>n;
    vector<int>d(n);
    for(int i=0; i<n; i++) scanf("%d", &d[i]);
    cin>>m;
    vector<int> t(m);
    for(int i=0; i<m; i++) scanf("%d", &t[i]);
    map <int,int> mpd,mpt;
    for(int i=0; i<n; i++) mpd[d[i]]++;
    for(int i=0; i<m; i++) mpt[t[i]]++;
    for(int i=0; i<m; i++) {
        if(mpt[t[i]] > mpd[t[i]]) {
            cout<<"NO"<<"\n";
            return 0;
        }
    }
    cout<<"YES"<<"\n";
}

Measured memory_bytes: 20608
#include <iostream>
using namespace std;
int main() {
	int N, a;
	int max = -1;
	int min = 1001;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> a;
		if (a > max)
			max = a;
		if (a < min)
			min = a;
	}
	
	cout << max - min << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
const int nax=1e5+7;
int n;
string s;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n>>s;
		char c=s[0];
		int count=1;
		rep(i,1,n) {
			if(s[i]!=c) count++;
			c=s[i];
		}
		cout<<count;
		return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int cnt[50][26];
    memset(cnt,0,sizeof(cnt));
    int n;
    cin>>n;
    string s;
    REP(i,n){
        cin>>s;
        REP(j,s.size())cnt[i][s[j]-'a']++;
    }
    REP(i,26){
        int mi=1e9;
        REP(j,n)mi=min(mi,cnt[j][i]);
        REP(j,mi)printf("%c",'a'+i);
    }cout<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>

using namespace std;

int main() {
 int a,b,c,d;
  cin >> a >>b>>c>>d;
  int e,f;
  e=max(a,c);
  f=min(b,d);
  if(e<f){
    cout << f-e << endl;
  }
  else{
    cout << "0" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int i;
string S;
int A;
int B;
 cin >> S;
 A = (S[0]-'0')*10 + (S[1]-'0');
 B = (S[2]-'0')*10 + (S[3]-'0');
 if((A>12||A<1) && (B>=1 && B<=12))cout << "YYMM" << endl;
 else if((B>12||B<1) && (A>=1 && A<=12))cout << "MMYY" << endl;
 else if((B>=1 && B<=12) && (A>=1 && A<=12))cout << "AMBIGUOUS" << endl;
 else{cout << "NA" << endl;}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long total=0;
        for(int i=1; i<=N; i++){
            for(int j=1; j<=N; j++){
                for(int k=1; k<=N; k++){
                    total += gcd(gcd(i,j),k);
                }
            }
        }
        System.out.println(total);
    }

    static long gcd(long x, long y){
        if(0 == y){
            return x;
        }
        return gcd(y, x%y); 
    }
}

Measured memory_bytes: 35640
k,n=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)
r=k-s
aa=[]
for i in range(n-1):
    aa.append(a[i+1]-a[i])
m=max(aa)
print(min(k-m,k-(a[0]+k-a[-1])))

Measured memory_bytes: 26444
import java.util.*;
public class Main {
	public static void main(String[] args) {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int a=n%10;
      switch(a){
        case 0:
        case 1:
        case 6:
        case 8:
          System.out.println("pon");
          break;
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
          System.out.println("hon");
          break;
        case 3:
          System.out.println("bon");
          break;
      }
	}
}

Measured memory_bytes: 27012
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// namespace
using namespace std;
// type
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
// input
#define INIT              ({ ios::sync_with_stdio(false); cin.tie(0); })
#define VAR(type, ...)    type __VA_ARGS__; var_scan(__VA_ARGS__);
template<typename T>
static void var_scan(T& t)
{
    cin >> t;
}
template<typename T, typename... R>
static void var_scan(T& t, R&... rest)
{
    cin >> t;
    var_scan(rest...);
}
// output
#define OUT(var)          cout << (var)
#define SPC               cout << ' '
#define TAB               cout << '\t'
#define BR                cout << '\n'
#define ENDL              cout << endl
#define FLUSH             cout << flush
// debug
#ifdef DEBUG
#define EPRINTF(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#define DUMP(var)         cerr << #var << '\t' << (var) << '\n'
#define DUMPITERABLE(i) do {                            \
        cerr << #i << '\t';                             \
        for (const auto& it : i) { cerr << it << ' '; } \
        cerr << '\n';                                   \
} while (0)
#define DUMPITERABLE2(i2) do {                          \
        cerr << #i2 << '\t';                            \
        for (const auto& it : i2) {                     \
            for (const auto& it2: it) {                 \
                cerr << it2 << ' ';                     \
            }                                           \
        }                                               \
        cerr << '\n';                                   \
} while (0)
#else
#define EPRINTF(fmt, ...)
#define DUMP(var)
#define DUMPITERABLE(i)
#define DUMPITERABLE2(i)
#endif
// util
// [l, r)
#define REP(i, n)       for (int i = 0; i < (n); i++)
#define RREP(i, n)      for (int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r)    for (int i = (l); i < (r); i++)
#define RFOR(i, r, l)   for (int i = (r)-1; i >= (l); i--)
#define REPLL(i, n)     for (ll i = 0; i < (n); i++)
#define RREPLL(i, n)    for (ll i = (n)-1; i >= 0; i--)
#define FORLL(i, l, r)  for (ll i = (l); i < (r); i++)
#define RFORLL(i, r, l) for (ll i = (r)-1; i >= (l); i--)

static constexpr int modulo = 1000000007;

static ll powmod(ll x, ll y)
{
    ll r = x;
    REP(i, y-1){
        r = r*x%modulo; // 10^9+7 - 2^31 > 0
    }
    return r;
}

int main(void)
{
    INIT;
    VAR(ll , n);
    ll r = powmod(10,n)-2*powmod(9,n)%modulo;
    if (r < 0) r+=modulo;
    r+=powmod(8,n);
    OUT(r%modulo);
    ENDL;
    return 0;
}


Measured memory_bytes: 3580
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        UnionFind uf=new UnionFind(n+m);
        for(int i=0;i<n;++i){
            int k=sc.nextInt();
            for(int j=0;j<k;++j){
                int x=sc.nextInt()-1;
                uf.unify(i,n+x);
            }
        }
        int hm=-1;
        for(int i=0;i<n;++i){
            int r=uf.root(i);
            if(hm==-1){
                hm=r;
            }else if(hm!=r){
                hm=-1;
                break;
            }
        }
        out.println(hm==-1?"NO":"YES");
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] nextIntArray(int n){
            int[]r=new int[n];
            for(int i=0;i<n;++i)r[i]=nextInt();
            return r;
        }
    }
}
class UnionFind {
    int[] parent;
    int[] rank;
    UnionFind(int n) {
	this.parent = new int[n];
	this.rank = new int[n];
	this.clear();
    }
    void clear() {
	int n = this.parent.length;
	for (int i = 0; i < n; ++i) {
	    this.parent[i] = i;
	    this.rank[i] = 0;
	}
    }
    void unify(int x, int y) {
	int rootX = this.root(x);
	int rootY = this.root(y);
	if (rootX == rootY) {
	    return;
	}
	if (this.rank[rootX] < this.rank[rootY]) {
	    this.parent[rootX] = rootY;
	} else {
	    this.parent[rootY] = rootX;
	    if (this.rank[rootX] == this.rank[rootY]) {
		this.rank[rootX]++;
	    }
	}
    }
    int root(int x) {
	if (this.parent[x] == x) {
	    return x;
	}
	return this.parent[x] = this.root(this.parent[x]);
    }
}


Measured memory_bytes: 42912
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    d = dict(zip([input() for i in range(n)],range(n)))
    print(len(d))
    return

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


Measured memory_bytes: 153584
fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

// 累積和
fun sumList(a: Iterable<Long>): List<Long> {
    val result = mutableListOf(0L)
    var i = 0L
    a.forEach {
        i += it
        result.add(i)
    }
    return result
}

// 要素ごとの数をカウント
fun <A> countList(a: List<A>): Map<A, Long> {
    val result = mutableMapOf<A, Long>()
    a.forEach {
        result[it] = (result[it] ?: 0L) + 1L
    }
    return result
}

fun solve(sc: java.util.Scanner) {
    val N = sc.nextInt()
    val A = Array(N) { sc.nextLong() }

    val S = sumList(A.toList())
    val C = countList(S)
    val result = C.map {
        (it.value * (it.value - 1)) / 2
    }.sum()
    println(result)
}


Measured memory_bytes: 83284
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int a,b;

int main(){
	cin >> a >> b;
	
	if(a<0 and b<0) cout << ((a-b+1)%2?"Negative":"Positive") << endl;
	else if(a<0 and b>0) cout << "Zero" << endl;
	else if(a>0 and b<0) cout << "Zero" << endl;
	else cout << "Positive" << endl;
	return 0;
}



Measured memory_bytes: 256
<?php
  
class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;
$stdin = $sc->next();
$arr = str_split($stdin);
$counter = 0;
for($i = 0; $i < count($arr); $i++){
  if($arr[$i] == 1){
  $counter ++;
  }
}
echo $counter;


Measured memory_bytes: 4856
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define io ios::sync_with_stdio(0),cin.tie(0)
#define ms(arr) memset(arr,0,sizeof(arr))
#define mc(a,b) memcpy(a,b,sizeof(b))
#define inf 0x3f3f3f
#define fin freopen("in.txt", "r", stdin)
#define fout freopen("out.txt", "w", stdout)
typedef long long ll;
typedef unsigned long long ULL;
const int mod=1e9+7;
const int N=1e5+7;
int n;
ll arr[N],sum[N];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&arr[i]);
    sort(arr,arr+n);
    sum[0]=arr[0];
    for(int i=1;i<n;i++)
        sum[i]=sum[i-1]+arr[i];
    int i;
    for(i=n-1;i>0;i--)
    {
        if(sum[i-1]*2<arr[i])
            break;
    }
    int ans=n-i;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792