akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        int N = c.length;
	        int[] m = new int[N];
	        for(int i=0;i<N;i++) {
	        	m[i] = c[i]-'0';
	        }
	        
	        long ans=0;
	        long k=1;
	        for(int i=0;i<1<<(N-1);i++) {
		        long tmp=m[N-1];
	        	for(int j=N-2;j>=0;j--) {
	        		if(((i>>j)&1)==1) {
	        			k=k*10;
	        			tmp=tmp+m[j]*k;
	        		} else {
	        			k=1;
	        			ans=ans+tmp;
	        			tmp=m[j];
	        			k=1;
	        		}
	        	}
	        	ans=ans+tmp;
	        	tmp=0;
	        	k=1;
	        }
	        
	        System.out.println(ans);
	        
	    }
	}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <algorithm>
#define R register
using namespace std;
typedef long long LL;
const int MAXN=100100;
int d[MAXN],pmt[MAXN];

void permute(int a[],int b[],int n)
{
	int t[MAXN];
	for(R int i=1;i<=n;++i)
	  t[i]=a[i];
	for(R int i=1;i<=n;++i)
	  a[i]=t[b[i]];
}

void fpow(int a[],LL y,int n)
{
	while(y)
	{
		if(y&1)permute(d,a,n);
		permute(a,a,n),y>>=1;
	}
}


int main()
{
	int n;
	scanf("%d",&n);
	LL l;
	int t1,t2;
	scanf("%lld",&l);
	t1=l;
	for(R int i=2;i<=n;++i)
	{
		scanf("%d",&t2);
		d[i]=t2-t1;
		t1=t2;
	}
	for(R int i=1;i<=n;++i)
	  pmt[i]=i;
	int m;
	LL k;
	scanf("%d%lld",&m,&k);
	for(R int i=1;i<=m;++i)
	{
		scanf("%d",&t1);
		swap(pmt[t1],pmt[t1+1]);
	}
	fpow(pmt,k,n);
	for(R int i=1;i<=n;++i)
	{
		l+=d[i];
		printf("%lld\n",l);
	}
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
const int N(2222);
int a[N], mn[N];
int main() {
    int n, x;
    cin >> n >> x;
    for(int i(0); i < n; i++) {
        cin >> a[i];
    }
    fill(mn, mn + n, 1e9);
    long long ans(1e18);
    for(int i(0); i < n; i++) {
        for(int j(0); j < n; j++) {
            mn[j] = min(mn[j], a[(j - i + n) % n]);
        }
        long long tmp((long long)i * x);
        for(int j(0); j < n; j++) {
            tmp = tmp + mn[j];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n, k, i=0;
	double maxx=-1;
	cin>>n>>k;
	double a[n+1], fix[n+1];
	fix[0]=0;
	for(i=1; i<=n; i++){
		cin>>a[i];
		a[i]=(a[i]+1)/2;
		fix[i]=fix[i-1]+a[i];
	}
	for(i=k; i<=n; i++){
		if(fix[i]-fix[i-k]>maxx)
		maxx=fix[i]-fix[i-k];
	}
	printf("%.8lf",maxx);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) { cin >> a[n - 1 - i]; }
    vector<int> l;
    l.eb(a[0]);
    rep3(i, 1, n) {
        auto it = upper_bound(all(l), a[i]) - l.begin();
        if (it == SZ(l)) {
            l.eb(a[i]);
        } else {
            l[it] = a[i];
        }
    }
    out(SZ(l));
}


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

void print(ll x[], ll n)
{
	for(int i = 0; i < n; i++)
		cout << x[i] << " ";
	cout << endl;
}
int x[4][100009], n;
ll dp[4][100009];
ll happy(int prev, int i)
{
	if(i==n)
		return 0;
	if(prev != -1 && dp[prev][i] != -1)
		return dp[prev][i];
	ll ans = -10000000;
	for(int act = 1; act < 4; act++)
	{
		if(act != prev)
			ans = max(ans, x[act][i] + happy(act, i+1));
	}
	dp[prev][i] = ans;
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < n; i++)
		cin >> x[1][i] >> x[2][i] >> x[3][i];
	cout << happy(0, 0) << endl;

	return 0;
}

Measured memory_bytes: 12800
class Unionfind:
    decks = None
    Values = None

    def __init__(self, N, H):
        self.decks = [0 for i in range(int(N))]
        self.Values = [int(H[i]) for i in range(int(N))]

    def Connect(self, A, B):
        if self.Values[int(A) - 1] > self.Values[int(B) - 1]:
            if self.decks[int(A) - 1] >= 0:
                self.decks[int(A) - 1] = 1
                self.decks[int(B) - 1] = -1
            else:
                self.decks[int(B) - 1] = -1

        elif self.Values[int(A) - 1] < self.Values[int(B) - 1]:
            if self.decks[int(B) - 1] >= 0:
                self.decks[int(B) - 1] = 1
                self.decks[int(A) - 1] = -1
            else:
                self.decks[int(A) - 1] = -1
        else:
            self.decks[int(A) - 1] = -1
            self.decks[int(B) - 1] = -1

    def GoodDeckCount(self):
        return len([i for i in self.decks if i >= 0])


N, M = input().split()
H = input().split()
j = [input().split() for i in range(int(M))]

uni = Unionfind(N, H)
for bridge in j:
    uni.Connect(bridge[0], bridge[1])

print(uni.GoodDeckCount())


Measured memory_bytes: 50812
#include<stdio.h>

int main(){
  int n;
  int i;
  int v[20];
  int c[20];
  int ans = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &v[i]);
  }
  for(i = 0; i < n; i++){
    scanf("%d", &c[i]);
  }

  for(i = 0; i < n; i++){
    if(v[i] > c[i]){
      ans += v[i] - c[i];
    }
  }

  printf("%d\n", ans);

  return 0;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &a : A)
    cin >> a;
  ll sum = pow(3, N);
  ll ng = 1;
  for (int i = 0; i < N; i++)
  {
    if (A[i] % 2 == 0)
      ng *= 2;
    else
      ng *= 1;
  }
  ll ans = sum - ng;
  cout << ans << endl;
  return 0;
}

// 全体から全て奇数の場合を引けばいい？


Measured memory_bytes: 640
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)

constexpr int MAX_V = 10000;
int  V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void init(int n) {
	V = n;
	rep(i, n) G[i].clear();
}

void add_edge(int a, int b){
	G[a].emplace_back(b);
	G[b].emplace_back(a);
}

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

int bipartie_matching(){
	int res = 0;
	memset(match, -1, sizeof(match));
	rep(v, V) {
		if(match[v] == -1) {
			memset(used, 0, sizeof(used));
			if(dfs(v)) ++res;
		}
    }
    return res;
}

struct point {
	int x, y;
	explicit point(int x_, int y_):x(x_), y(y_) {}
};

struct segment {
	point a, b;
	segment(const point &a_, const point &b_):a(a_), b(b_) {}
};

bool in_range(int x, int l, int r) {
	return l <= x && x <= r;
}

bool intersect(const segment &hor, const segment &ver) {
	return in_range(ver.a.x, hor.a.x, hor.b.x) && in_range(hor.a.y, ver.a.y, ver.b.y);
}

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

	for(int h, w; cin >> h >> w && h;) {
		vector<vector<int>> choco(h, vector<int>(w, 0));
		rep(i, h) {
			string line;
			cin >> line;

			rep(j, w) {
				if(line[j] == '#') choco[i][j] = 1;
			}
		}

		int cnt = 0;
		vector<segment> hor, ver;
		rep(y, h - 1) {
			rep(x, w - 1) {
				if(choco[y][x] + choco[y + 1][x] + choco[y][x + 1] + choco[y + 1][x + 1] == 3) {
					const point p(x, y);
					++cnt;

					if(!choco[y][x] || !choco[y + 1][x]) { // horizontal
						REP(nx, x, w - 1) {
							if(!choco[y][nx + 1] || !choco[y + 1][nx + 1]) {
								if(choco[y][nx + 1] + choco[y + 1][nx + 1] == 1) {
									hor.emplace_back(p, point(nx, y));
								}
								break;
							}
						}
					}

					if(!choco[y][x] || !choco[y][x + 1]) { // vertical
						REP(ny, y, h - 1) {
							if(!choco[ny + 1][x] || !choco[ny + 1][x + 1]) {
								if(choco[ny + 1][x] + choco[ny + 1][x + 1] == 1) {
									ver.emplace_back(p, point(x, ny));
								}
								break;
							}
						}
					}
				}
			}
		}

		const int n = hor.size();
		const int m = ver.size();
		init(n + m);

		rep(i, n) {
			rep(j, m) {
				if(intersect(hor[i], ver[j])) add_edge(i, j + n);
			}
		}

		cout << cnt + 1 - (n + m - bipartie_matching()) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

vector<vector<int>> G;
vector<int> c;
vector<int> d;
int ind=0;

void dfs(int cu,int pa){
    d[cu]=c[ind];
    ind++;
    for(auto nv : G[cu]){
        if(nv==pa) continue;
        dfs(nv,cu);
    }
}

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

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

    int ans=0;
    c.resize(n);
    d.resize(n);
    rep(i,n){
        cin>>c[i];
        ans+=c[i];
    }

    sort(all(c));
    reverse(all(c));
    ans-=c[0];

    dfs(0,-1);

    cout<<ans<<endl;
    rep(i,n) cout<<d[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 4372
#include<iostream>
#include <math.h>
#include <set>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

    set<int> s;

    REP(i, n) {
        int d;
        cin >> d;
        s.insert(d);
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define dbprint(s) {cout<<"db:"<<s<<endl;}
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
  int N; cin>>N;
  vector<int> vec(4);
  vec[0] = N % 10;
  vec[1] = N / 10 % 10;
  vec[2] = N / 10 / 10 % 10;
  vec[3] = N / 10 / 10 / 10 % 10;

  int match = 0;
  int tmp = -1;
  for (int i = 0; i < 4; i++) {
    if (vec[i] == tmp) {
      match++;
      if (match >= 3) break;
    } else {
      match = 1;
      tmp = vec[i];
    }
  }

  if (match >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> Edge;

struct UnionFind {
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) par[i] = i;
  }

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

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] > sizes[y]) swap(x, y);

    par[x] = y;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int n; cin >> n;
  int x[n], y[n];
  vector<int> v(n), w(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    v[i] = w[i] = i;
  }

  sort(v.begin(), v.end(), [&](int a, int b) {
    return x[a] < x[b];
  });
  sort(w.begin(), w.end(), [&](int a, int b) {
    return y[a] < y[b];
  });

  auto f = [&](Edge e) {
    int ex = abs(x[e.first] - x[e.second]);
    int ey = abs(y[e.first] - y[e.second]);
    return min(ex, ey);
  };

  int en = n * 2 - 2;
  Edge edges[en];
  int cost[en];
  vector<int> u(en);
  for (int i = 0; i < en/2; i++) {
    edges[i] = Edge(v[i], v[i+1]);
    cost[i] = f(edges[i]);
    u[i] = i;
  }
  for (int i = en/2; i < en; i++) {
    edges[i] = Edge(w[i-en/2], w[i+1-en/2]);
    cost[i] = f(edges[i]);
    u[i] = i;
  }

  sort(u.begin(), u.end(), [&](int a, int b) {
    return cost[a] < cost[b];
  });

  long long ans = 0;
  UnionFind uf(en);
  for (int i : u) {
    int p = edges[i].first;
    int q = edges[i].second;
    if (!uf.same(p, q)) {
      uf.unite(p, q);
      ans += cost[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
# -*- coding:utf-8 -*-

def solve():
    N = int(input())

    # どの桁帯にいるかを求める
    b = 1
    d = 26
    num = 26
    while N > num:
        b += 1
        d *= 26
        num += d

    N = N - (num - d)
    N -= 1  # 0-indexedにする

    # 26進数で答えを求める
    ans = ""
    for i in range(b-1, -1, -1):
        a = N//(26**i)
        ans += chr(97+a)
        N -= (26**i)*a

    print(ans)


if __name__ == "__main__":
    solve()


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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
#define R0F(i, a) for (int i = a; i >= 0; i--)
#define GO(i, a) for (auto i : a)

#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
typedef vector<vi64> vvi64;
typedef vector<vpi64> vvpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, +30, +31, +30, +31, +31, +30, +31, +30, +31};
const int rm[] = {+1, +4, +5, +9, +10, +40, +50, +90, +100, +400, +500, +900, +1000};

int Get (int numero) {
  int ans = -1;
  while (numero) {
    ans = numero % 10;
    numero /= 10;
  }
  return ans;
}

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  i64 tot = 0;
  map<pii, int> dig;
  FOR (i, 1, n + 1) {
    int primeiro = Get (i);
    int ultimo = i % 10;
    dig[{primeiro, ultimo}]++; 
  }
  FOR (i, 1, n + 1) {
    int primeiro = Get (i);
    int ultimo = i % 10;
    tot += dig[{ultimo, primeiro}];
  }
  cout << tot << '\n';
  return 0;
}



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

const int MAXN = 8;

int n;
int x[MAXN], y[MAXN], p[MAXN];

double dist(int i, int j) {
	return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		p[i] = i;
	}
	double sum = 0;
	int cnt = 0;
	do {
		for (int i = 0; i < n - 1; i++) {
			sum += dist(p[i], p[i + 1]);
		}
		cnt++;
	} while (next_permutation(p, p + n));
	cout << fixed << setprecision(10) << sum / cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (int)(n);i++)
typedef long long ll;
using namespace std;
int n;
vector<pair<int, int> > tasks;
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else{
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
INF = 10 ** 10

dp = [[None] * 2 for _ in range(n)]
for i in range(n - 1, -1, -1):
    dp[i][0] = -INF
    y = a[i-1] if i else w
    dp[i][0] = max(dp[i][0], abs(y - a[-1]))
    for j in range(i + 1, n):
        dp[i][0] = max(dp[i][0], dp[j][1])

    dp[i][1] = INF
    x = a[i-1] if i else z
    dp[i][1] = min(dp[i][1], abs(x - a[-1]))
    for j in range(i + 1, n):
        dp[i][1] = min(dp[i][1], dp[j][0])

ans = dp[0][0]
print(ans)


Measured memory_bytes: 3368
#include <iostream>

int main() {
    int N;
    std::cin >> N;

    int A = 0;
    int C = 1;
    int G = 2;
    int T = 3;

    int dp[101][4][4][4] = {};
    for (int c1 = 0; c1 < 4; ++c1) {
        for (int c2 = 0; c2 < 4; ++c2) {
            for (int c3 = 0; c3 < 4; ++c3) {
                dp[3][c1][c2][c3] = 1;
            }
        }
    }
    dp[3][A][G][C] = 0;
    dp[3][G][A][C] = 0;
    dp[3][A][C][G] = 0;

    for (int n = 3; n < N; ++n) {
        for (int c1 = 0; c1 < 4; ++c1) {
            for (int c2 = 0; c2 < 4; ++c2) {
                for (int c3 = 0; c3 < 4; ++c3) {
                    for (int c4 = 0; c4 < 4; ++c4) {
                        bool ok = true;
                        ok = ok && !(c2 == A && c3 == G && c4 == C); //  AGC
                        ok = ok && !(c1 == A && c3 == G && c4 == C); // A?GC
                        ok = ok && !(c2 == G && c3 == A && c4 == C); //  GAC
                        ok = ok && !(c2 == A && c3 == C && c4 == G); //  ACG
                        ok = ok && !(c1 == A && c2 == G && c4 == C); // AG?C
                        if (ok) {
                            dp[n + 1][c2][c3][c4] += dp[n][c1][c2][c3];
                            dp[n + 1][c2][c3][c4] %= 1000000007;
                        }
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int c1 = 0; c1 < 4; ++c1) {
        for (int c2 = 0; c2 < 4; ++c2) {
            for (int c3 = 0; c3 < 4; ++c3) {
                ans += dp[N][c1][c2][c3];
                ans %= 1000000007;
            }
        }
    }

    std::cout << ans << "\n";
    return 0;
}


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

public class Main {
  private static int solve(int n, int[] ds) {
    Set<Integer> set = new HashSet<>();
    for (int d : ds) {
      set.add(d);
    }
    return set.size();
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] ds = reader.nextInt(n);
    out.println(solve(n, ds));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21332
import sys
from itertools import accumulate

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

    R = [0] + list(accumulate(A))
    left = 0
    for i in range(n):
        if R[i] * 2 < A[i]:
            left = i
    print(n - left)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 20448
/**
 * Created by hiramekun at 20:58 on 2020-05-03.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, m;
    cin >> n >> m;
    vl h(n);
    cin >> h;

    vl g[n];
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].eb(b), g[b].eb(a);
    }


    ll ans = 0;
    rep(i, n) {
        bool plus = true;
        each(e, g[i]) {
            if (h[i] <= h[e]) plus = false;
        }
        if (plus) ans++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 9856
#include <stdio.h>
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))

int gcd(int x, int y){
	int ans = 0;
	int m = max(x,y);
	int n = min(x,y);
	while(n != 0){
		int temp = n;
		n = m % n;
		m = temp;
	}
	ans = m;
	return ans;
}


int main(){
	int N;
	int A[100000] = {};
	int max = -1;
	scanf("%d",&N);
	for(int i = 0; i < N; i ++){
		scanf("%d",&A[i]);
	}

	int head[100000] = {};
	int back[100000] = {};
	head[0] = back[N - 1] = 0;

	for(int i = 0; i < N - 1; i ++){
		head[i + 1] = gcd(head[i],A[i]);
	}

	for(int i = N - 1; i > 0; i --){
		back[i - 1] = gcd(back[i],A[i]);
	}

	for(int i = 0; i < N; i ++){
		if(max < gcd(head[i],back[i])){
			max = gcd(head[i],back[i]);
		}
	}

	printf("%d",max);

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];
    int cnt = 0;

    REP(m, 1, n - 1) {
        int l = m - 1, r = m + 1;

        if ((p[l] < p[m] && p[m] < p[r]) || (p[l] > p[m] && p[m] > p[r])) cnt++;

    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        if n < r:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

def main():
    S = int(input())
    MOD = 10 ** 9 + 7
    if S <= 2:
        print(0)
        exit()
    ans = 0
    comb = Combination(10000)
    for i in range(1,S//3+1):
        n = S - (3 * i)
        ans += comb(n+i-1,n)
        ans %= MOD
    print(ans)

    



if __name__ == "__main__":
    main()

Measured memory_bytes: 67984
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()
	fmt.Println(min(a, b) + min(c, d))
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

// Manages Union-Find Forest.
class UnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;

public:
  // Initialize forest.
  // parent_[i]=i, rank_[i]=0, size_[i]=1.
  UnionFindForest(const int &n);
  // Get the number of the root of the node q.
  int Root(const int &q);
  // Return true if the roots of x and y is same.
  bool IsSame(const int &x, const int &y);
  // Unite the tree x and tree y.
  void Unite(int x, int y);
  // Get the number of nodes which are the same group as node q.
  int Size(const int &q);
};
UnionFindForest::UnionFindForest(const int &n) {
  parent_.resize(n);
  rank_.resize(n);
  size_.resize(n);
  for (int i = 0; i < n; i++) {
    parent_[i] = i;
    rank_[i]   = 0;
    size_[i]   = 1;
  }
}
int UnionFindForest::Size(const int &q) {
  return size_[Root(q)];
}

int UnionFindForest::Root(const int &q) {
  if (parent_[q] == q) {
    return q;
  } else {
    return parent_[q] = Root(parent_[q]);
  }
}

bool UnionFindForest::IsSame(const int &x, const int &y) {
  return Root(x) == Root(y);
}

void UnionFindForest::Unite(int x, int y) {
  x = Root(x);
  y = Root(y);
  if (x == y) return;
  if (rank_[x] < rank_[y]) {
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n,m;
  cin>>n>>m;
  std::vector<std::pair<int,int>> rest;
  for(int i=0;i<m;i++){
    int c,d;
    cin>>c>>d;
    rest.push_back(std::make_pair(c,d));

  }

  UnionFindForest uf(m);
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      if(i==j) continue;
      if(rest[i].first<=rest[j].first&&
      rest[j].first<=rest[i].second&&
      rest[i].second<=rest[j].second){
        uf.Unite(i,j);
      }else if(rest[i].first<=rest[j].first&&
      rest[j].second<=rest[i].second){
        uf.Unite(i,j);
      }
    }
  }

  int samegroup_left[1000];
  for(int i=0;i<1000;i++){
    samegroup_left[i]=9999;
  }
  int samegroup_right[1000]={};
  for(int i=0;i<m;i++){
    samegroup_left[uf.Root(i)]=std::min(samegroup_left[uf.Root(i)],rest[i].first);
    samegroup_right[uf.Root(i)]=std::max(samegroup_right[uf.Root(i)],rest[i].second);

  }

  int result=n+1;
  for(int i=0;i<m;i++){
    if(samegroup_left[i]!=9999&&samegroup_right[i]!=0){
      result+=(samegroup_right[i]-samegroup_left[i])*2;
    }
  }
  cout<<result<<endl;



  return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define ll long long
#define  f first
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define mp make_pair
#define  s second

using namespace std;

ll mod=1e9+7;
ll dp[20001];

int main(){
    ll s;cin>>s;
    dp[0]=1;
    dp[3]=1;
    dp[4]=1;
    dp[5]=1;
    
    for(ll i=6;i<=s;i++){
    	for(ll j=i-3;j>=0;j--){
    		dp[i]+=dp[j];
    		dp[i]%=mod;
		}
	}
    cout<<dp[s];
	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

int main() {
	int num[3];
	int friend = 0;
	for(int i = 0; i < 3; i++) {
		scanf("%d", &num[i]);
	}

	for(int i = 1; i < 3; i++) {
		if(num[0] == num[i]) {
			friend++;
		}
	}

	if(num[1] == num[2]) {
		friend++;
	}

	if(friend == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int dp[100100];
vector<int> G[100100];

int rec(int x) {
    if(dp[x]!=-1) return dp[x];
    int res = 0;
    for(auto v: G[x]) {
        chmax(res, rec(v)+1);
    }
    return dp[x] = res;
}

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

    int ans = 0;
    for(int i = 0; i < n; i++) chmax(ans, rec(i));
    cout << ans << endl;
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var size = Console.ReadLine().ToInt();
		var s = Input().ToInt();
		var t = Input().ToInt();
		Console.WriteLine(Math.Abs(GetDictionaryIndex(t, size) - GetDictionaryIndex(s, size)));
	}
	
	private static int GetDictionaryIndex(int[] array, int max)
	{
		bool[] flag = new bool[max];
		long q = 1;
		for(int i = 1; i <= array.Length; i++)
			q *= i;
		
		int r = 0;
		for(int i = 0; i < array.Length; i++)
		{
			int c = 0;
			for(int j = 0; j < array[i]; j++)
			{
				if(!flag[j])c++;
			}
			flag[array[i]-1] = true;
			q /= (max - (i));
			r += (int)((c-1) * q);
		}
		return r;
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}
const int n_max = 5e5+10;
vector<Mint<int>> fac(n_max+1),inv(n_max+1);
Mint<int> comb(int m, int n){
  return fac[m]*inv[n]*inv[m-n];
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  Mint<int> nn,mm;
  nn = n;
  mm = m;
  fac[0] = inv[0] = 1;
  rep(i,m){
    fac[i+1] = fac[i] * (Mint<int> (i+1));
    inv[i+1] = (Mint<int> (1)) / fac[i+1];
  }
  // cout << comb(m,n) << " " << fac[n]<< endl;
 
  Mint<int> cnt = comb(m,n) * fac[n] * comb(m,n) * fac[n];
  Mint<int> coef = comb(m,n) * fac[n];

  rep1(i,n){
    // cout << i << " " << cnt << endl;
    if(i%2==0) cnt += comb(n,i) * comb(m-i,n-i) * fac[n-i] * coef;
    else cnt -= comb(n,i) * comb(m-i,n-i) * fac[n-i] * coef;
  }
  
  cout << cnt << endl;
  return 0;
    

}


Measured memory_bytes: 7044
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        double s[n];
        int sum = 0;
        double m, a;
        double k = 0.0;
        for(int i = 0; i < n; i++){
            cin >> s[i];
            sum += s[i];
        }
        m = 1.0*sum/n;
        for(int j = 0; j < n; j++){
            k += (s[j] - m)*(s[j] - m);
        }
        a = 1.0*k/n;
        printf("%lf\n", sqrt(a));
    }
    return 0;
}



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

int main(){
	long k;
	string s; cin >> s >> k;
	for (int i = 0; i < k; i ++){
		if (s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << "1" << endl;
return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
if s[0] == s[1]:
    print(1, 2)
    exit()
for i, (af, s, bf) in enumerate(zip(s, s[1:], s[2:])):
    if af == s or af == bf or s == bf:
        print(i + 1, i + 3)
        exit()
print(-1, -1)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    char a;
    cin >> a;
    if(0<=(int)(a-'a') && int(a-'a')<=25) cout << 'a' << endl;
    else cout << 'A' << endl;
}
    

Measured memory_bytes: 3608
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range (0, N):
	A[i] = (A[i]+1)/2

sumK = sum(A[0:K])

L = [sumK]

for i in range (0, N-K):
	sumK = sumK + A[K+i] - A[i]
	L.append(sumK)

print(max(L))

Measured memory_bytes: 32060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
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 (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll a, b;
  cin >> a >> b;
  if (a <= b) {
    cout << a << endl;
  } else {
    cout << a-1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  long double inv = 0;
  rep(i,n){
    long double a;
    cin >> a;
    inv += 1/a;
  }
  long double ans = 1/inv;
  printf("%.10Lf\n",ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long int
#define INF 1000000005
#define MOD 1000000007
#define FF first
#define pb push_back
#define SS second
#define double long double
#define int long long int

using namespace std;
typedef long long ll;

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

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll modx(ll Base, ll exponent)
{
  ll ans = 1;
  if(Base == 1)
    return Base;
  while(exponent)
  {
    if(exponent & 1)
      ans = (ans * Base)%MOD;
    Base = (Base * Base)%MOD;
    exponent = exponent >> 1;
  }
  return ans;
}

ll inmodx(ll num)
{
  return (modx(num, MOD-2LL));
}

bool cmp(pii loc, pii b)//true for loc before b
{
  if(loc.SS < b.SS)
    return 1;
  if(loc.SS > b.SS)
    return 0;
  if(loc.FF <= b.FF)
    return 1;
  return 0;
}
int n;
vector<int> adj[100005];
int vis[100005];
int dp[100005][2];
// 0--> white 1-->black
void dfs(int s,int par)
{
  vis[s]=1;
  dp[s][0]=1;
  dp[s][1]=1;
  for(int i=0;i<adj[s].size();i++)
  {
    if(vis[adj[s][i]]==1)
    {
      continue;
    }
    dfs(adj[s][i],s);
    dp[s][0]*=(dp[adj[s][i]][0]+dp[adj[s][i]][1])%MOD;
      dp[s][1]*=(dp[adj[s][i]][0])%MOD;
      dp[s][0]%=MOD;
      dp[s][1]%=MOD;

  }

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

    cin>>n;
    for(int i=0;i<n-1;i++)
    {
      int x,y;
      cin>>x>>y;
      adj[x].pb(y);
      adj[y].pb(x);
    }
    dfs(1,1);
    cout<<(dp[1][0]+dp[1][1])%MOD<<endl;
    return 0;
}



    

Measured memory_bytes: 14976
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

void solve() {
    string s;
    cin >> s;
    int n = s.length();
    int sum = 0;
    for(int i=0;i<n;i++) {
        sum += s[i] - '0';
    }
    cout << ((sum % 9) ? "No" : "Yes") << endl;
    return;
} 
 
int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}

Measured memory_bytes: 3784
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      int n = Integer.parseInt(st.nextToken());
      long m = Long.parseLong(st.nextToken());
      
      int[] array = new int[n+1];
      st = new StringTokenizer(f.readLine());
      
      int[] next = new int[n+1];
      HashMap<Integer,Integer> last = new HashMap<Integer,Integer>();
      
      //stores first instance of each number
      HashMap<Integer,Integer> indexof = new HashMap<Integer,Integer>();
      
      for(int k = 0; k < n; k++){
         array[k] = Integer.parseInt(st.nextToken());
         next[k] = -1;
         if(last.containsKey(array[k])){
            next[last.get(array[k])] = k;
         }
         last.put(array[k],k);
         
         if(!indexof.containsKey(array[k])){
            indexof.put(array[k],k);
         }
         
      }
      
      next[n] = -1;
      array[n] = -1;
      
      
      ArrayList<Integer> before = new ArrayList<Integer>();
      
      before.add(-1);
      
      int i = 0;
      while(next[i] != -1){
         i = next[i]+1;
      }
      if(i >= n){
         out.close();
         System.exit(0);
      }
      before.add(array[i]);
      
      int start = indexof.get(array[i])+1;
      while(start < n){
         
         i = start;
         while(next[i] != -1){
            i = next[i]+1;
         }
         if(array[i] == -1) break;
         before.add(array[i]);
         start = indexof.get(array[i])+1;
      }

      
      
      int index = (int)(m % (long)before.size())-1;
      if(index == -1){
         index = before.size()-1;
      }
      
      ArrayList<Integer> answer = new ArrayList<Integer>();
      start = before.get(index);
      if(start != -1) index = indexof.get(start)+1;
      else index = 0;
      while(index < n){
         
         if(next[index]!=-1)index=next[index]+1; 
         else{
            answer.add(array[index]);
            index++;
         }
      }
      
      for(int a : answer){
         out.print(a + " ");
      }
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 101540
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

from bisect import bisect_left, bisect

ans = 0
for i in range(N):
    b = B[i]
    a = bisect_left(A,b)
    c = bisect(C,b)
    #print(b,a,c)
    #print(b,A[:a],C[c:])
    ans += a*(N-c)
print(ans)

Measured memory_bytes: 23160
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int C[MAX_N], S[MAX_N], F[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N - 1) cin >> C[i] >> S[i] >> F[i];
	rep(i, 0, N - 1) {
		int ans = 0;
		rep(j, i, N - 1) {
			if(ans < S[j]) ans = S[j] + C[j];
			else ans = ((ans + F[j] - 1) / F[j]) * F[j] + C[j];
		}
		cout << ans << "\n";
	}
	cout << "0" << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int zero = 0;
	int one = 0;
	string S;
	cin >> S;
	rep(i, S.size()){
		if(S[i] == '0')zero++;
		else one++;
	}
	cout << min(zero, one) * 2 << endl;
}

Measured memory_bytes: 512