akhauriyash/Code-Regression huggingface dataset:
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    n = int(input())
    if n == 1:
        print(0)
        exit()

    d = collections.Counter(prime_factorize(n))
    #print(d)

    ans = 0
    for _, cnt in d.items():
        now = 1
        while cnt >= now:
            #print("cnt:",cnt,"now:",now)
            cnt -= now
            now += 1
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9472
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

typedef pair<ll,ll> pll;

int main(){
    int n,k;cin >> n >> k;
    vector<ll> x(n),y(n);
    vector<pll> p(n);

    rep(i,n){
        cin >> x[i] >> y[i];
        p[i].first = x[i];
        p[i].second = y[i];
    }

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    ll res = 1LL*(x[n-1]-x[0])*(y[n-1]-y[0]);
    for(int l=0;l<n;l++){
        for(int r=l+1;r<n;r++){
            for(int b=0;b<n;b++){
                for(int t=b+1;t<n;t++){
                    int num=0;
                    for(int i=0;i<n;i++){
                        if(x[l]<=p[i].first&&p[i].first<=x[r]&&y[b]<=p[i].second&&p[i].second<=y[t])num++;
                    }
                    if(num>=k)res = min(res,1LL*(x[r]-x[l])*(y[t]-y[b]));
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
from math import gcd
k = int(input())
gcd_2 = []
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        gcd_2.append(gcd(a, b))
for ab in gcd_2:
    for c in range(1, k + 1):
        ans += gcd(ab, c)
print(ans)

Measured memory_bytes: 9428
N = gets.to_i
s_list = N.times.map { gets }
s_with_count = Hash.new(0)
total_count = 0
 
s_list.each do |s|
  c = s_with_count[s.chomp.chars.sort.join] += 1
  total_count += c - 1
end
 
p total_count

Measured memory_bytes: 24572
import sys,math,collections
from collections import defaultdict

#from itertools import permutations,combinations
    
def file():
    sys.stdin = open('input.py', 'r')
    sys.stdout = open('output.py', 'w') 
def get_array():
    l=list(map(int, input().split()))
    return l
def get_ints():   
    return map(int, input().split())
    #return a,b
def get_3_ints():   
    a,b,c=map(int, input().split())
    return a,b,c    
def sod(n):
    n,c=str(n),0
    for i in n: 
        c+=int(i)
    return c    
def isPrime(n):
    if (n <= 1):
        return False
    if (n <= 3):
        return True
    if (n % 2 == 0 or n % 3 == 0):
        return False
    i = 5
    while(i * i <= n):
        if (n % i == 0 or n % (i + 2) == 0):
            return False
        i = i + 6
  
    return True
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    floor = -1
    while left <= right:
        mid = (left + right) // 2
        if A[mid] == x:
            return A[mid]
        elif x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            left = mid + 1
            
    return floor
def chk(aa,bb):
	f=0
	for i in aa:
		for j in bb:
			if(j[0]>=i[0] and j[1]<=i[1]):
				f+=1
			elif(j[0]<=i[0] and j[1]>=i[1]):	
				f+=1
			elif(i[0]==j[1] or i[1]==j[0]):
				f+=1
			else:
				continue
	return f			

#file()
def main():
	a,b,c,d=get_ints()
	
	print(max(a*c,a*d,b*c,b*d))
	





        
            
        























    

    
    

        











        
        

        























































                

            







            
            
































        








if __name__ == '__main__':
    main()

Measured memory_bytes: 9496
import java.util.*;

public class Main {
	
	
    public static void main(String args[]) {
		
	Scanner sc = new Scanner(System.in);
			
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = Integer.valueOf(String.valueOf(a) + String.valueOf(b));
	
	if (isPerfectSquare((double)c)) {
            System.out.print("Yes");
       } else{
            System.out.print("No");
    }
	
	
	}
	
	static boolean isPerfectSquare(double x) 
    {
         
        // Find floating point value of
        // square root of x.
        double sr = Math.sqrt(x);
     
        // If square root is an integer
        return ((sr - Math.floor(sr)) == 0);
    }
	
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;

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

template<class T>
bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return false;
	}
	return true;
}

template<class T>
bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return false;
	}
	return true;
}

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}


ll dp[50][500][500]{};

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N, Ma, Mb; cin >> N >> Ma >> Mb;
	vector<ll> A(N), B(N), C(N);
	REP(i, N) cin >> A[i] >> B[i] >> C[i];

	REP(i, 50)REP(a, 500)REP(b, 500)
	{
		if (a == 0 && b == 0)
			dp[i][a][b] = 0;
		else
			dp[i][a][b] = INF;
	}

	REP(i, N)
	{
		REP(ma, 500)REP(mb, 500)
		{
			chmin(dp[i+1][ma][mb], dp[i][ma][mb]);
			if (ma - A[i] >= 0 && mb - B[i] >= 0) 
				chmin(dp[i+1][ma][mb], dp[i][ma-A[i]][mb-B[i]] + C[i]);
		}
	}

	ll res{INF};
	for (ll i = 1;; i++)
	{
		if (Ma*i >= 500 || Mb*i >= 500) break;
		if (res > dp[N][Ma*i][Mb*i])
		{
			DEBUG(Ma*i);
			DEBUG(Mb*i);
		}
		res = min(res, dp[N][Ma*i][Mb*i]);
	}

	DEBUG(dp[N][3][3]);
	std::cout << ((res == INF) ? -1 : res) << std::endl;
	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  bool flag = false;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i*4 + j*7 == n) flag = true;
    }
  }
  if (flag) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}


Measured memory_bytes: 256
x, n = [int(x) for x in input().split()]

if n == 0:
    print(x)
    exit()

P = [int(x) for x in input().split()]

before = x
after = x
while True:
    if before not in P:
        print(before)
        break
    elif after not in P:
        print(after)
        break
    before -= 1
    after += 1


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    deque<int> ans;
    ans.push_back(vec[0]);
    for (int i = 1; i < n; i++){
        if (i % 2 == 1) ans.push_back(vec[i]);
        else ans.push_front(vec[i]);
    }
    if (n % 2 == 1){
        rep(i,n){
            cout << ans.front() << " ";
            ans.pop_front();
        }
    }
    else{
        rep(i,n){
            cout << ans.back() << " ";
            ans.pop_back();
        }
    }
    cout << endl;
}


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

int main(){
    int h,w,K;
    cin >> h >> w >> K;
    
    vector<string> c(h);
    rep(i,h) cin >> c.at(i);
    
    int ans = 0;
    rep(i, 1 << h) {
        rep(j, 1 << w){
            int cnt = 0;
            rep(k,h){
                rep(l,w){
                    if(!((i>>k) & 1) || !((j>>l) & 1)) continue;
                    if(c.at(k).at(l) == '#') cnt++;
                }
            }
            if(cnt == K) ans++;
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)
#define REPR(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int> > VII;

void solve() {

    int N;
    cin >> N;

    int A[N];
    PII order[N];
    REP(i,0,N) {
        cin >> A[i];
        order[i] = {A[i], i};
    }

    sort(order, order + N);

    set<int> next;
    set<int, greater<int> > prev;
    next.insert(N);
    prev.insert(-1);

    ll res = 0;

    for (auto ai : order) {
        int a = ai.first;
        int pos = ai.second;

/*        cout << "prev:";
        for (auto x : prev)
            cout << " " << x;
        cout << endl;*/

        int lpos = *prev.upper_bound(pos);
        int upos = *next.upper_bound(pos);

        //cout << "pos " << pos << ", lpos " << lpos << ", upos " << upos << endl;

        res += (ll)(pos-lpos)*(upos-pos)*a;
        prev.insert(pos);
        next.insert(pos);
    }
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    solve();

	return 0;
}


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

using namespace std;

struct Pos {
    int y, x, cnt;
};

int main() {

    int w, h, stat;
    int dx[] = {-1, 0, 0, 1};
    int dy[] = {0, -1, 1, 0};

    while(cin >> w >> h, w | h) {

        int graph[h][w][h][w];

        memset(graph, 0, sizeof(graph));

        for(int i = 0; i < w - 1; ++i) {
            cin >> stat;
            graph[0][i][0][i + 1] = graph[0][i + 1][0][i] = stat;
        }

        for(int i = 1; i < h; ++i) {
            for(int j = 0; j < w; ++j) {
                cin >> stat;
                graph[i][j][i - 1][j] = graph[i - 1][j][i][j] = stat;
            }
            for(int j = 0; j < w - 1; ++j) {
                cin >> stat;
                graph[i][j][i][j + 1] = graph[i][j + 1][i][j] = stat;
            }
        }

        queue<Pos> q;
        q.push((Pos){0, 0, 0});

        bool isGoal = false;
        while(!q.empty()) {

            Pos now = q.front(); q.pop();

            if(now.y == h - 1 && now.x == w - 1) {
                cout << now.cnt + 1<< endl;
                isGoal = true;
                break;
            }

            for(int i = 0; i < 4; ++i) {
                int ny = now.y + dy[i];
                int nx = now.x + dx[i];
                if(ny >= 0 && ny < h && nx >= 0 && nx < w && !graph[now.y][now.x][ny][nx]) {
                    graph[now.y][now.x][ny][nx] = graph[ny][nx][now.y][now.x] = 1;
                    q.push((Pos){ny, nx, now.cnt + 1});
                }
            }

        }

        if(!isGoal) cout << 0 << endl;

    }

}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n,k;
  cin>>n>>k;
  vector<int>p(n);
  rep(i,n) cin>>p[i];
  int sum=0;
  sort(all(p));
  rep(i,k) sum+=p[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  string x;
  cin>>x;
  int count;
  if(x[0]=='o')count +=100;
  if(x[1]=='o')count +=100;
  if(x[2]=='o')count +=100;
  cout<<700 + count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    if(x==0)
    cout<<1;
    else 
    cout<<0;
    
    
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

#define N_MAX 100

int main()
{
    int n, i, j, u, k, v;
    int Adj[N_MAX][N_MAX] = {};

    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> u >> k;
        while (k-- > 0) {
            cin >> v;
            Adj[u-1][v-1] = 1;
        }
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < n ; j++) {
            if (j == n - 1)
                cout << Adj[i][j] << endl;
            else
                cout << Adj[i][j] << ' ';
            /*
            cout << Adj[i][j] << ' ';
            if (j == n - 1)
                cout << endl;
            */
        }
    }

    return 0;
}

Measured memory_bytes: 3120
import java.util.*;

public class Main {


    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        A: for(int i = 1; i <= sum / 2; i++) {
            if(sum % i != 0) continue;
            int div = sum / i;

            int minus = 0;
            int plus = 0;

            int[] b = new int[n];


            for(int j = 0; j<n; j++) {
                b[j] = a[j] % div;
            }
            Arrays.sort(b);
            int l = 0;
            int r = n - 1;
            while(l <= r) {
                if (minus < plus) {
                    minus += b[l];
                    if(minus > k) continue A;
                    l++;
                } else {
                    plus += div - b[r];
                    if(plus > k) continue A;
                    r--;
                }
            }
            System.out.println(div);
            return;
        }

        System.out.println(1);
    }

}


Measured memory_bytes: 27540
N = gets.to_i

MOD = (10 ** 9) + 7
C = ['A','G','C','T']
R = /(AGC|ACG|GAC|A.GC|AG.C)/
W3 = C.product(C,C).map(&:join).reject{|w3| R =~ w3 }

if N == 3
  puts  W3.size
  exit
end

INDEX = W3.each_with_index.to_h
A = W3.map do |w3|
  C.map do |c| 
    w4 = w3 + c
    R =~ w4 ? nil : INDEX[w3[1,2] + c]
  end
end
dp = (4 .. N).inject(Array.new(W3.size,1)) do |prev, n|
  current = Array.new(W3.size, 0) 
  prev.each_with_index do |v, w3|
    C.each_index do |c|
      w3_ = A[w3][c]
      if w3_
        current[w3_] += v
        current[w3_] %= MOD
      end
    end
  end
  current
end
puts dp.inject(&:+) % MOD


Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
	int b,a[3],t,i,j,c=0;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	for(i=0;i<2;i++){
		for(j=i+1;j<3;j++){
			if(a[i]<a[j]){
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
	b=a[0]-a[1];
	a[1]+=b;
	a[2]+=b;
	c+=b;
	if((a[0]-a[2])%2==0){
		c+=(a[0]-a[2])/2;
	}else{
		c+=(a[0]-a[2])/2+2;
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 128
const main = (standardInput) => {
    const lengthList = standardInput.split(' ');
    const r = Number.parseFloat(lengthList[0]);
    const r1 = Math.round(Math.PI*(r*r)*1000000)/1000000;
    const r2 = Math.round(Math.PI*(r+r)*1000000)/1000000

    console.log(r1+ " "+ r2);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



Measured memory_bytes: 15408
#include <bits/stdc++.h>
using namespace std;
pair< pair < string, int > , int > p[110];
int main()
{
    int a;
    cin>>a;
    for(int i=0;i<a;i++)
    {
        int t;
        string in;
        cin>>in>>t;
        p[i]=make_pair(make_pair(in,-t),i);
    }
    sort(p,p+a);
    for(int i=0;i<a;i++)
    cout<<p[i].second+1<<"\n";
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 1000000
int prime[MAX];

int main(void)
{
	int number, i, j, count;
	prime[0] = prime[1] = 0;
	for (i = 2; i < MAX; i++)
	{
		prime[i] = 1;
	}
	for (i = 2; i < 1001; i++)
	{
		if (prime[i])
		{
			for (j = 2 * i; j < MAX; j += i)
			{
				prime[j] = 0;
			}
		}
	}
	while (scanf("%d", &number) != EOF)
	{
		count = 0;
		for (i = 2; i <= number; i++)
		{
			count += prime[i];
		}
		printf("%d\n", count);
	}
  return 0;
}

Measured memory_bytes: 4500
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long long int> VLL;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    io;
    ll a, c, d;
    string b;
    cin >> a;
    cin >> b;
    int i = 0;
    FOR (i, 0, SZ(b)) {
        if (b[i] == '.') {
            c = stoll(b.substr(0, i));
            d = stoll(b.substr(i+1));
            break;
        }
    }

    cout << a*c + a*d/100ll << "\n";

}



Measured memory_bytes: 3664
maxnum = 100000

# エラトステネスのふるい
is_prime = [x for x in range(maxnum)]
for prime in is_prime:
    if prime == 0 or prime == 1:
        is_prime[prime] = 0
        continue
    for non_prime in range(prime * 2, maxnum, prime):
        is_prime[non_prime] = 0

like_sum = [0] * maxnum
for i in range(3, maxnum):
    like_sum[i] = like_sum[i - 1]
    if (is_prime[i] and is_prime[(i + 1) // 2]):
        like_sum[i] += 1

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(like_sum[r] - like_sum[l - 1])


Measured memory_bytes: 8216
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  string s,t;
  cin >> s >> t;
  map<char,int> a,b;
  int sc = 0,tc = 0;
  vi sv,tv;
  REP(i,s.size()){
    if(a.find(s[i])==a.end()) sv.eb(a[s[i]] = sc++);
    else sv.eb(a[s[i]]);
    if(b.find(t[i])==b.end()) tv.eb(b[t[i]] = tc++);
    else tv.eb(b[t[i]]);
  }
  cout << (sv==tv?"Yes":"No") << endl;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int d, n;
    cin >> d >> n;
    int ans;
    if(d == 0) {
        ans = n;
        if(n == 100) ans++;
    } else if(d == 1) {
        ans = n * 100;
        if(n == 100) ans += 100;
    } else {
        ans = n * 10000;
        if(n == 100) ans += 10000;
    }
    cout << ans << endl;

    return 0;
}

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

vector<vector<int> > adj;
vector<int> dp, ans;

void dfs(int u, int p) {
    int s = 0, z = 0;
    for (int v : adj[u]) {
        if (p != v) {
            dfs(v, u);
            if (dp[v] == 0) z++;
            else s += dp[v];
        }
    }
    dp[u] = s + max(0, z - 1);
}

void dfs2(int u, int p, int x) {
    int s = x, z = x == 0 && p >= 0 ? 1 : 0;
    for (int v : adj[u]) {
        if (v != p) {
            if (dp[v] == 0) z++;
            else s += dp[v];
        }
    }
    ans[u] = s + 1 + max(0, z - 1);
    for (int v : adj[u]) {
        if (v != p) {
            int s1 = s, z1 = z;
            if (dp[v] == 0) z1--;
            else s1 -= dp[v];
            dfs2(v, u, s1 + max(0, z1 - 1));
        }
    }
}

int main() {
    int n; cin >> n;
    adj.resize(n);
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dp.resize(n);
    dfs(0, -1);
    ans.resize(n);
    dfs2(0, -1, 0);
    cout << *min_element(ans.begin(), ans.end()) << endl;
}


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

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

	int b[10000];

	for (int i = 0; i < 4; i++) {
		b[S[i] - 'A']++;
	}

	for (int i = 0; i < 4; i++) {

		if ( b[S[i] - 'A'] != 0 && b[S[i] - 'A'] != 2 ) {
			cout << "No" << endl;
			return 0;
		}

	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define BOOST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debugL(i)  cout<<"line no-> "<<i<<" working"<<endl
#define debugVL(i,l)  cout<<"val at line no."<<i<< " ->"<<l<<endl
#define  init(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
//LLONG_MAX
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
struct node{
	int l,r,v;
};
int32_t main() 
{
	BOOST;
	int n;cin>>n;
	string s;cin>>s;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		while(i+1<n && s[i]==s[i+1])
		{
			i++;
		}
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}
 















 
 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Bounding | diff Bounding.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Bounding.cpp && ./a.out

/*
 
 6/16/2019
 
 5:02-
 
 */

const int MAX_N=100+1;
LL X,L[MAX_N];
int N;

void solve() {
  int res=0;
  vector<LL> D(N+2,0);
  D[1]=0;
  FORE(i,2,N+1) {
    D[i]=D[i-1]+L[i-1];
  }
  FORE(i,1,N+1) res+=D[i]<=X;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>X;
  REP(i,N) cin>>L[i+1];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int N;
char s[1000000];

char wariate[1000000];

int create_wariate(void) {
	int i;
	for (i = 2; i <= N + 1; i++) {
		if (s[i - 1] == (wariate[i - 1] == 'S' ? 'o' : 'x')) {
			/* 両隣が同じ */
			wariate[i] = wariate[i - 2];
		} else {
			wariate[i] = (wariate[i - 2] == 'S' ? 'W' : 'S');
		}
	}
	return wariate[0] == wariate[N] && wariate[1] == wariate[N + 1];
}

void check(const char* initial) {
	wariate[0] = initial[0];
	wariate[1] = initial[1];
	if (create_wariate()) {
		wariate[N] = '\0';
		puts(wariate);
		exit(0);
	}
}

int main(void) {
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%s", s) != 1) return 1;
	s[N] = s[0];
	s[N + 1] = s[1];
	check("SS");
	check("SW");
	check("WS");
	check("WW");
	puts("-1");
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int n;
	cin>>n;
	vector<int> v(n);
	REP(i,n)
		cin>>v[i];
	sort(all(v));
	int x = v[n-1];
	int sum = 0;
	REP(i, n-1)
		sum+=v[i];
	if(x<sum)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)
#define inf 123451234512345LL

ll G[100][100] = {0};
void warshallfloyd(int v){
  int i, j, k;
  rep(k, v)rep(i, v)rep(j, v)if(G[i][k] != inf && G[k][j] != inf && G[i][j] > G[i][k] + G[k][j])G[i][j] = G[i][k] + G[k][j];
  return;
}


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){

    for(;;){
      int n, m, s, g1, g2;
      cin >> n >> m >> s >> g1 >> g2;
      if((n | m | s | g1 | g2) == 0)break;
      s--; g1--; g2--;

      rep(i, n)rep(j, n)G[i][j] = inf;
      rep(i, m){
        int3(x, y, z);
        x--; y--;
        G[x][y] = z;
      }
      rep(i, n)G[i][i] = 0;

      warshallfloyd(n);

      ll res = inf;
      rep(i, n)res = min(res, G[s][i] + G[i][g1] + G[i][g2]);
      pri(res);
    }


/*/

//*/ break;
  }
  return 0;
}

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

typedef long long ll;

int main(void) {
	const double EPS = 0.001;
	ll A;
	double B;
	cin >> A >> B;

	int iB = (int)((B + EPS) * 100.0);
	ll ans = A * iB / 100;

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


Measured memory_bytes: 3736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            int S = Integer.parseInt(br.readLine());
            System.out.printf("%d:%d:%d\n", S/3600, (S%3600)/60, S%60);
        } catch (IOException e) {
            e.printStackTrace();
        }
        
    }
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    vector< vector<int> > G(n);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int odp = 0;
    for (int i = 0; i < n; ++i)
    {
        bool ok = true;
        for (int j = 0; j < G[i].size(); ++j)
            if (h[G[i][j]] >= h[i])
                ok = false;
        if (ok)
            ++odp;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 8752
n = int(input())
A = list(map(int, input().split()))

s = sum(A)
i = 0
half = s / 2
neibor = 0
for i in range(n+1):
	if neibor >= half:
		break
	else:
		neibor += A[i]
		
aneibor = neibor - A[i-1]
if abs(s-aneibor*2) < abs(neibor-(s-neibor)):
	print(abs(s-aneibor*2))
else:
	print(abs(neibor-(s-neibor)))


Measured memory_bytes: 26220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{       
    
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);
        int c = int.Parse(inputs[2]);
        int result = Math.Min(b / a, c);
        System.Console.WriteLine(result);
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 13140
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include<stdio.h>

using namespace std;

int main(void) {
	string s; cin >> s;
	for (int i = 0; i < s.length(); i=i+2) {
		if (s[i] == 'L') {
			cout << "No";
			return 0;
		}
	}
	for (int i = 1; i < s.length(); i = i + 2) {
		if (s[i] == 'R') {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define vll vector<long long> 
#define pll pair<ll,ll>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define all(v)  (v).begin(),(v).end()
#define sz 1001
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main(){
	FIO;ll n,k;cin>>n>>k;
	vll v(n),dp(n,1e9);
	f(i,0,n) cin>>v[i];
	dp[0] = 0;
	f(i,1,n){
		for(ll j=i-1;j>=0 and j>=i-k;j--){
			dp[i] = min(dp[i],abs(v[i]-v[j])+dp[j]);
		}
	}
	cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 4788
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
def V(n):
    if n<=0:return 1
    if n==1:return 2
    if n==2:return 3
    cnt = n+1
    for k in range(2,(n+1)//2+1):
        cnt = (cnt+((A[n-k+1]*B[k])%p*B[n-2*k+1])%p)%p
    return cnt
        
p = 10**9+7
H,W,K = map(int,input().split())
A = [1 for _ in range(W+1)]
for i in range(2,W+1):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(W+1)]
B[W] = pow(A[W],p-2)
for i in range(W-1,1,-1):
    B[i] = ((i+1)*B[i+1])%p
dp = [[0 for _ in range(W+2)] for _ in range(H+1)]
dp[1][1] = V(W-2)
if W>=2:
    dp[1][2] = V(W-3)
for h in range(2,H+1):
    for k in range(1,W+1):
        dp[h][k] = ((dp[h-1][k-1]*V(k-3)*V(W-k-1))%p+(dp[h-1][k]*V(k-2)*V(W-k-1))%p+(dp[h-1][k+1]*V(k-2)*V(W-k-2))%p)%p
print(dp[H][K])

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

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

    if (a <= 9 && b <= 9) {
        cout << a*b << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 3000 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
ll arr[N], n, dp[N][N][2];

int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		dp[i][i][0] = -arr[i];
		dp[i][i][1] = arr[i];
	}
	for (int d = 1; d < n; d++) {
		for (int i = 0; i + d < n; i++) {
			dp[i][i + d][0] = min(dp[i + 1][i + d][1] - arr[i], dp[i][i + d - 1][1] - arr[i + d]);
			dp[i][i + d][1] = max(dp[i + 1][i + d][0] + arr[i], dp[i][i + d - 1][0] + arr[i + d]);
		}
	}
	cout << dp[0][n - 1][1];
}

Measured memory_bytes: 85436
import numpy as np
N = int(input())

Number_to_divide = []
for i in range(1,int(np.sqrt(N))+1):
    if (N % i == 0)and((N / i) > (i + 1)):
        Number_to_divide.append((N / i) - 1)
print(int(sum(Number_to_divide)))



Measured memory_bytes: 22420
r,c = map(int,input().split())
masume = [[0 for i in range(c)] for j in range(r)]
for i in range(r):
	masume[i] = list(input())

thispoint = True
for ri in range(r):
	for ci in range(c):
		if masume[ri][ci] == '#':
			draw = False
			for ar in [-1,0,1]:
				for ac in [-1,0,1]:
					if abs(ar) == abs(ac):
						continue
					chkr = ri + ar
					chkc = ci + ac
					if chkr >= 0 and chkr < r and chkc >= 0 and chkc < c and masume[chkr][chkc] == '#':
						draw = True
						break
			if not(draw):
				thispoint = False
				break
	if not(thispoint):
		break
if thispoint:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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() {
  ll H, W;
  cin >> H >> W;

  if (W == 1 || H == 1) {
    cout << 1 << endl;
  }
  else if (W % 2 == 0) {
    ll ans = (H * W)/ 2;
    cout << ans << endl;
  }
  else {
    if (H % 2 == 0) {
      ll ans = ((H * (W - 1))/ 2) + (H/ 2);
      cout << ans << endl;
    }
    else {
      ll ans = ((H * (W - 1)) / 2) + ((H + 1) / 2);
      cout << ans << endl;
    }
  }
  return 0;
}

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

int main()
{
  int N, M, X;
  int a[110];
  int res=0;
  int c1=0;
  int c2=0;
  cin >> N>>M>>X;

  rep(i,N+1) a[i]=0;
  rep(i,M) {
    int aa;
    cin >> aa;
    a[aa]=1;
  }

  for(int i=X; i<=N; i++){
    c1+=a[i];
  }
  for(int i=X; i>=1; i--){
    c2+=a[i];
  }

  cout << min(c1, c2)  << endl;
}

Measured memory_bytes: 256
from collections import deque
s = deque(list(input()))
q = int(input())
cur = 0
for i in range(q):
    ls = list(map(str, input().split()))
    if len(ls) == 1:
        cur += 1
    else:
        if ls[1] == '1':
            if cur%2 == 0:
                s.appendleft(ls[2])
            else:
                s.append(ls[2])
        else:
            if cur%2 == 0:
                s.append(ls[2])
            else:
                s.appendleft(ls[2])
if cur%2 == 0:
    print(*s, sep='')
else:
    print(*list(s)[::-1], sep='')

Measured memory_bytes: 16508
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	long mf(long[][] cap) {
		int n = cap.length;
		int[][] flow = new int[n][n];
		long ret = 0;
		int s = n - 2;
		int t = n - 1;
		while (true) {
			int[] pre = new int[n];
			Arrays.fill(pre, -1);
			ArrayDeque<Integer> q = new ArrayDeque<>();
			q.add(s);
			out: while (!q.isEmpty()) {
				int v = q.pollFirst();
				for (int i = 0; i < n; ++i) {
					if (cap[v][i] - flow[v][i] <= 0 || pre[i] != -1 || i == s) {
						continue;
					}
					pre[i] = v;
					if (i == t)
						break out;
					q.addLast(i);
				}
			}
			if (pre[t] == -1)
				break;
			long inc = Long.MAX_VALUE / 3;
			for (int i = t; i != s; i = pre[i]) {
				inc = Math.min(inc, cap[pre[i]][i] - flow[pre[i]][i]);
			}
			for (int i = t; i != s; i = pre[i]) {
				flow[pre[i]][i] += inc;
				flow[i][pre[i]] -= inc;
			}
			ret += inc;
		}
		return ret;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long base = 0;
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
			if (a[i] > 0)
				base += a[i];
		}
		long[][] cap = new long[n + 2][n + 2];
		// s:削除
		// t:残す
		for (int i = 1; i <= n; ++i) {
			for (int j = 2 * i; j <= n; j += i) {
				cap[i - 1][j - 1] = Long.MAX_VALUE / 3;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (a[i] >= 0) {
				cap[i][n + 1] = a[i];
			} else {
				cap[n][i] = -a[i];
			}
		}
		System.out.println(base - mf(cap));

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 23892
#include <cstdio>

using namespace std;

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a < b && b < c) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2608
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
static const int MAX=100;
static const ll INFTY=(1LL<<32);

int n;
ll d[MAX][MAX];

void floyd(){
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            if(d[i][k]==INFTY)continue;
            for(int j=0;j<n;j++){
                if(d[k][j]==INFTY)continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}
int main(){
    int e,u,v,c;
    cin>>n>>e;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            d[i][j]=((i==j)?0:INFTY);
    }

    for(int i=0;i<e;i++){
        cin>>u>>v>>c;
        d[u][v]=c;
    }
    floyd();

    bool negative=false;
    for(int i=0;i<n;i++){
        if(d[i][i]<0)negative=true;
    }

    if(negative)
        cout<<"NEGATIVE CYCLE"<<"\n";
    else{
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(j)cout<<" ";
                if(d[i][j]==INFTY)cout<<"INF";
                else cout<<d[i][j];
            }
            cout<<"\n";
        }
    }    
    return 0;
        
} 



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
#define N 500007
#define pb push_back;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 998244353

int main()
{
    FAST;
    ll n;
    cin>>n;
    string s="";
    while(n>0)
    {
        ll x=n%26;
        if(x==0)
        {
            s+='z';
            n=n/26-1;
        }
        else
        {
            s+=((x-1)+'a');
            n/=26;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s;
}

Measured memory_bytes: 3652
h, w = map(int, input().split())
s = [input() for  i in range(h)]

ans  =[]
for row in s:
        ans.append(list(row))
        
dxy = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)]
for x in range(h):
        for y in range(w):
                if s[x][y] == "#":
                        continue
                c = 0
                for dx, dy in dxy:
                        if x +dx < 0 or x +dx > h-1 or y + dy < 0 or y + dy > w-1:
                                continue
                        else:
                                if s[x + dx][y + dy] == "#":
                                        c += 1
                ans[x][y] = c
for row in ans:
        print("".join(list(map(str, row))))

Measured memory_bytes: 9228
from collections import deque
from copy import deepcopy

N,M = map(int,input().split())
Matrix = [[False for x in range(N)] for y in range(N)]

Path = []
for i in range(M) :
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    Path.append((a,b))
    Matrix[a][b] = True
    Matrix[b][a] = True

INF = 63
ans = 0
for i in range(M) :
    Matrix_duplicated = deepcopy(Matrix)
    a,b = Path[i]
    Matrix_duplicated[a][b] = False
    Matrix_duplicated[b][a] = False
    Distance = [INF for i in range(N)]
    Distance[0] = 0
    Queue = deque([0])
    while Queue :
        now = Queue.popleft()
        for i in range(N) :
            if Matrix_duplicated[now][i] :
                Matrix_duplicated[now][i] = False
                Matrix_duplicated[i][now] = False
                Distance[i] = min(Distance[now]+1, Distance[i])
                Queue.append(i)
    if INF in Distance :
        ans += 1
print(ans)


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    vector<int> a(3*N);
    for(ll i = 0; i < 3*N; ++i) cin >> a[i];

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

    ll res = 0LL;
    rep(i, 0, N) res += a[2*i + N];

    cout << res << "\n";
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b;
	cin >>a >>b;
	
	vector<string> vs(100, string(100, '.'));
	rep(i, 50) vs[i] = string(100, '#');
	
	int za = a-1, zb = b-1;
	rep(i, 48) rep(j, 100) if(i%2==0 && j%2==0 && za-- >0) vs[i][j]='.';
	repr(i, 99, 52) rep(j, 100) if(i%2 && j%2==0 && zb-- >0) vs[i][j]='#';
	cout <<"100 100\n";
	for(auto x :vs) cout<<x<<"\n";
	return 0;


}


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
typedef long long ll;
using namespace std;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	printf("%d",a<b?0:10);
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int n,p[50],p_swap[50];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&p[i]);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=0;k<n;k++)p_swap[k]=p[k];
            p_swap[i]=p[j];
            p_swap[j]=p[i];
            bool flag=true;
            for(int k=1;k<n;k++){
                flag=flag&&(p_swap[k-1]<p_swap[k]);
            }
            if(flag){
                printf("YES\n");
                return 0;
            }
        }
    }
    bool flag=true;
    for(int k=1;k<n;k++){
        flag=flag&&(p[k-1]<p[k]);
    }
    if(flag){
        printf("YES\n");
        return 0;
    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;

int main(){

    string s;
    cin>>s;

    char temp=s[0];
    int ans=1;
    int f=0;
    for (int i=1; i<s.size();i++){
        if(s[i]==temp)
            ans++;
        else{
            temp=s[i];
            ans=1;
        }
        if(ans==3)
            f=1;
    }

    if (f)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 256
// オリジナル https://atcoder.jp/contests/ABC169/submissions/13872716
// 自分にとってわかるようにコメントを加えつつ微修正
open System

/// origN: 入力値
/// m: origN を割っていった値でどんどん小さくなる
/// a: 2L からインクリメントしていく値
let rec primes origN m a =
    if origN < a * a then
        if m = 1L then [] else [ 1 ] // 最終的に素数と分かったとき
    elif m % a <> 0L then
        primes origN m (a + 1L)
    else
        /// n: primes オリジナルの引数 m を a でどんどん割っていく
        /// acc: 割り切った回数のカウンター
        let rec inner n acc =
            if n % a <> 0L then (n, acc) else inner (n / a) (acc + 1)

        let (m1, c) = inner m 0
        // 1 番最初に 2L で呼んでいるため a >= 3 以上では
        // m がすでに因数として 2 はもっていない。
        // 2 より大きい偶数を考えても仕方ないので奇数だけ考える
        let aPlus = if a = 2L then 3L else a + 2L
        c :: (primes origN m1 aPlus)

/// 問題指定のアルゴリズム A で割った回数を計算する
/// e: p^e の e
/// c: アルゴリズム A の枠組みで割った回数
/// もともと p^{e} だったとして再帰が進むと素べきが p^{e-c} になる
let rec cnt e c =
    if e >= c then 1 + (cnt (e - c) (c + 1)) else 0

let fd n =
    primes n n 2L
    |> List.fold (fun st x -> st + (cnt x 1)) 0
    |> printfn "%d"

let isDev = false

if isDev then
    fd 24L
    fd 1L
    fd 64L
    fd 1000000007L
    fd 997764507000L
else
    let n = stdin.ReadLine() |> int64
    fd n

Measured memory_bytes: 30100
#include<cstdio>
#include<algorithm>

long long ll, ll2, ans, ans2;
long long a, b, c, d;

void solve();

int main(){
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

    solve();

    return 0;
}

void solve(){
    ll = a*c;
    ll2 = a*d;
    //printf("%lld %lld\n", ll, ll2);

    ans = std::max(ll, ll2);
    //printf("%lld\n", ans);

    ll = b*c;
    ll2 = b*d;
    //printf("%lld %lld\n", ll, ll2);

    ans2 = std::max(ll, ll2);
    //printf("%lld\n", ans2);

    ans = std::max(ans, ans2);
    printf("%lld\n", ans);
}

Measured memory_bytes: 1736