akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#define N 5020
#define MOD 1000000007
using namespace std;

namespace Comb
{
    int f[N], g[N];

    int Power(int x, int y)
    {
        int o;

        for(o = 1; y; y >>= 1)
        {
            if(y & 1)
                o = (long long)o * x % MOD;
            x = (long long)x * x % MOD;
        }

        return o;
    }

    void InitComb(void)
    {
        int i;

        for(i = f[0] = 1; i < N; i ++)
            f[i] = (long long)f[i - 1] * i % MOD;
        g[N - 1] = Power(f[N - 1], MOD - 2);
        for(i = N - 2; i > -1; i --)
            g[i] = (long long)g[i + 1] * (i + 1) % MOD;

        return;
    }

    int P(int n, int m)
    {
        return m < 0 || m > n ? 0 : (long long)f[n] * g[n - m] % MOD;
    }
}

vector<int> e[N];
int f[N][N], s[N];

inline int Mod(int x)
{
    return x + ((x >> 31) & MOD);
}

inline int Match(int n)
{
    return n & 1 ? 0 : (long long)Comb::P(n, n / 2) * Comb::Power(Comb::Power(2, n / 2), MOD - 2) % MOD;
}

void DFS(int x, int p)
{
    static int t[N];
    int i, j, k, v;


    for(i = 0; i < (signed)e[x].size(); i ++)
        if(e[x][i] != p)
            DFS(e[x][i], x);

    f[x][1] = 1;
    for(i = 0, s[x] = 1; i < (signed)e[x].size(); i ++)
        if((v = e[x][i]) != p)
        {
            memset(t, 0, sizeof(int) * (s[x] + s[v] + 1));
            for(j = 1; j <= s[x]; j ++)
                for(k = 1; k <= s[v]; k ++)
                {
                    t[j + k] = Mod(t[j + k] + (long long)f[x][j] * f[v][k] % MOD - MOD);
                    t[j] = Mod(t[j] - (long long)f[x][j] * f[v][k] % MOD * Match(k) % MOD);
                }
            memcpy(f[x], t, sizeof(int) * (s[x] + s[v] + 1));
            s[x] += s[v];
        }

    return;
}

int main(void)
{
    int n, u, v;
    int i;

    Comb::InitComb();
    scanf("%d", &n);
    for(i = 1; i < n; i ++)
    {
        scanf("%d %d", &u, &v);
        e[-- u].push_back(-- v);
        e[   v].push_back(   u);
    }

    // for(i=0;i<=n;i++)cout<<Match(i)<<' ';cout<<endl;
    DFS(0, 0);
    // for(i=1;i<=n;i++)cout<<f[0][i]<<' ';cout<<endl;
    for(i = 1, v = 0; i <= n; i ++)
        v = Mod(v + (long long)f[0][i] * Match(i) % MOD - MOD);
    printf("%d\n", v);

    return 0;
}


Measured memory_bytes: 98688
#include <stdio.h>
int main(void){
  int i,a[26]={};
  char s[100001];
  scanf("%s",s);
  for (i=0;s[i];i++) a[(int)s[i]-97]++;
  for (i=0;i<26;i++){
    if (a[i]==0) break;
  }
  if (i==26) printf("None\n");
  else printf("%c\n",(char)(i+97));
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  float h, a;
  cin >> h >> a;
  cout << ceil( h / a ) << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}

import Data.Array
import Data.Array.IO
import Data.IORef
import Data.List
import Control.Monad

solve :: Array (Int, Int) Char -> Int -> Int -> String
solve arr h w
    | null res = "Yes"
    | otherwise = "No"
    where
        res = [() | i <- [1..h], j <- [1..w], step arr i j]
        step :: Array (Int, Int) Char -> Int -> Int -> Bool 
        step arr i j = curr && ns
            where
                curr = arr ! (i,j) == '#'
                ns = null $ (filter (\p -> arr ! p == '#') $ filter (\(a,b) -> a > 0 && a <= h && b > 0 && b <= w) [(i+1,j),(i-1,j),(i,j+1),(i,j-1)])


main = do
    [h, w] <- map read . words <$> getLine :: IO [Int]
    str <- concat <$> replicateM h getLine :: IO String
    let (grid :: Array (Int,Int) Char) = listArray ((1,1),(h,w)) str
    putStrLn $ solve grid h w

Measured memory_bytes: 1020
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;
ll dp[3005][3005];
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}

int main() {
    input;
    int n, s;
    cin >> n >> s;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    // dp[i][j] = sum of left endpoints of subsequences with sum j that end at i 
    for(int i = 0; i < n; i++) {
        dp[i + 1][a[i]] = i + 1;

        for(int j = 0; j <= s; j++) {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
            if(j + a[i] <= s) {            
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= mod;
            }
        }
        
    }
    for(int i = 1; i <= n; i++) {
        debug(dp[i][s]);
        dp[i][s] += dp[i - 1][s];
        dp[i][s] %= mod;
    }


    cout << dp[n][s];
}


Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  int N;
  ll sum_A = 0, sum_B = 0;
  map<ll, int> mp;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  rep(i, N) {cin >> A[i]; sum_A += A[i];}
  rep(i, N){ cin >> B[i]; sum_B += B[i];}

  if(sum_A < sum_B){
    cout << -1 << endl;
    return 0;
  }

  ll sum = 0, ans = 0;
  vector<ll> diff;
  for(int i = 0; i < N; i++){
    sum += max(0LL, B[i] - A[i]);
    diff.pb(A[i] - B[i]);
    if(B[i] > A[i]) ans++;
  }
  sort(all(diff), greater<ll>());

  rep(i, diff.size()){
    if(sum <= 0)break;
    ans++;
    sum -= diff[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3704
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        int L = S.length(); 
        String[] str = S.split("");
        String str1 = "";
        String str2 = "";
        
        for(int i=0; i<(L-1)/2; i++){
            str1 += str[i];
        }
        
        for(int i=((L+3)/2)-1; i<L; i++){
            str2 += str[i];
        }  
        
        if(str1.equals(str2)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
string S;
ll K;
ll slv(string s){
	ll ans=0,i=0;
	while(i<s.size()){
		ll j=i+1;
		for(;j<s.size()&&s[j]==s[i];j++);
		ans+=(j-i)/2;
		i=j;
	}
	return ans;
}
bool isp(string s){
	REP(i,s.size()-1){
		if(s[0]!=s[i+1])return false;
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>S>>K;
	if(isp(S)){
		cout<<S.size()*K/2<<endl;
	}else{
		ll a=slv(S),b=slv(S+S);
		cout<<(b-a)*(K-1)+a<<endl;
	}
}

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

int main()
{
    int n, sum = 0;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(all(p), greater<int>());
    rep(i, n)
    {
        if (i == 0)
            sum += p[i] / 2;
        else
        {
            sum += p[i];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

R = 0
G = 0
B = 0

# R,G,Bの数を数える
for i in range(N):
    if S[i] == 'R':
        R += 1
    elif S[i] == 'G':
        G += 1
    else:
        B += 1
    
# 等間隔で(R,G,B)の組み合わせとなっている数を数える
# 間隔(step)は1～1999のいずれか
count = 0
for step in range(1,2000):
    start = 0
    while (start + step * 2) < N:
        i,j,k = start, start+step, start+step*2
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            count += 1
        start += 1

# print(count)

print(R*G*B - count)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const ll INF = INT64_MAX;

int n, k;

int main() {
    cin >> n >> k;
    vector<ll> xvec(n, 0);
    vector<ll> yvec(n, 0);
    for(int i = 0; i < n; ++i) cin >> xvec[i] >> yvec[i];
    vector<P> xpvec;
    vector<P> ypvec;
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            xpvec.emplace_back(P(xvec[i], xvec[j]));
            ypvec.emplace_back(P(yvec[i], yvec[j]));
        }
    }
    int plen = xpvec.size();

    ll ans = INF;
    for(int i = 0; i < plen; ++i) {
        for(int j = 0; j < plen; ++j) {
            if(xpvec[i].first > xpvec[i].second) swap(xpvec[i].first, xpvec[i].second);
            if(ypvec[j].first > ypvec[i].second) swap(ypvec[j].first, ypvec[j].second);
            ll llimit = xpvec[i].first, rlimit = xpvec[i].second;
            ll blimit = ypvec[j].first, ulimit = ypvec[j].second;
            int cnt = 0;
            for(int l = 0; l < n; ++l) {
                int chx = xvec[l], chy = yvec[l];
                if(chx >= llimit && chx <= rlimit && chy >= blimit && chy <= ulimit) cnt++;
            }

            if(cnt >= k) {
                ll square = (rlimit-llimit)*(ulimit-blimit);
                chmin(ans, square);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;

int main() {
	ll n,maxv,maxv2;
	int i;
	int digit1 = 0, digit2 = 0;
	cin >> n;
	for (i = 1; i <= sqrt(n)+1; ++i) {
		if (n % i == 0) {
			maxv = i;
		}
	}
	maxv2 = n/maxv;
	while (maxv != 0) {
		maxv /= 10;
		++digit1;
	}
	while (maxv2 != 0) {
		maxv2 /= 10;
		++digit2;
	}
	digit1 = max(digit1, digit2);
	cout << digit1 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3

import array
import math
import os
import sys


def main():
    N = read_int()
    for x in range(1, 10):
        for y in range(x, 10):
            if x * y == N:
                print('Yes')
                return
    print('No')


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n; cin >> n;

    vi v1, v2;
    v1.reserve(n);
    v2.reserve(n);

    vi a(n);
    REP(i, n) cin >> a[i];

    REP(i, n) {
        if (i & 1) {
            v1.pb(a[i]);
        } else {
            v2.pb(a[i]);
        }
    }

    if (n & 1) {
        swap(v1, v2);
    }
    reverse(ALL(v1));
    REP(i, v1.size()) {
        if (i > 0) cout << " ";
        cout << v1[i];
    }

    REP(i, v2.size()) {
        cout << " " << v2[i];
    }

    print("");
}


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


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

    vector<string> s(N);
    vector<int> t(N);

    for (int i=0; i<N; i++) {
        cin >> s[i] >> t[i];
    }

    string X;
    cin >> X;

    int total_sec = 0;
    for (int i=0; i<N; i++) {
        total_sec += t[i];
    }

    int sec = 0;
    for (int i=0; i<N; i++) {
        sec += t[i];
        if (s[i] == X) break;
    }


    int ans = total_sec - sec;
    cout << ans << endl;

    return 0;
}

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

int main(){

int a,b,c,x;
int i,j,k;

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

int count,sum;

count = 0;
sum = 0;

	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(k=0;k<=c;k++){

				sum = 500*i + 100*j + 50*k;

				if(sum == x){
					count = count + 1;
				}

			}
		}
	}

	printf("%d",count);

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

ll intpow(const int &a, const int &n) {
    if (n == 0)
        return 1;
    else if (n & 1)
        return intpow(a * a, n / 2) * a;
    else
        return intpow(a * a, n / 2);
}

signed main() {
    vi a(3);
    cin >> a >> K;
    REP(k, K + 1) {
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k - x; y++) {
                int z = k - y - x;
                dump(x, y, z);
                A = intpow(2, x) * a[0];
                B = intpow(2, y) * a[1];
                C = intpow(2, z) * a[2];
                if (A < B && B < C) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
	float h;
	int i , n , cnt[6] = {0};
	scanf("%d" , &n);
	while(n){
		scanf("%f" , &h);
		if(h<165) cnt[0]++;
		else if(h<170) cnt[1]++;
		else if(h<175) cnt[2]++;
		else if(h<180) cnt[3]++;
		else if(h<185) cnt[4]++;
		else cnt[5]++;
		n--;
	}
	for(n=0;n<6;n++){
		printf("%d:" , n+1);
		for(i=0;i<cnt[n];i++){
			printf("*");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

void no() {
  cout << 0 << endl;
  exit(0);
}

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 2010000;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main() {
  ll x, y;
  cin >> x >> y;

  ll u = 2 * x - y, v = 2 * y - x;
  if (u < 0 || v < 0 || u % 3 != 0 || v % 3 != 0) {
    no();
  }

  ll a = u / 3, b = v / 3;

  COMinit();

  ll ans = COM(a + b, a);
  cout << ans << endl;
}

Measured memory_bytes: 47360
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
void arrange(int (*ar)[2],int left,int right)
{
    if(left<right)
    {
        int key=ar[left][1],keep=ar[left][0];
        int low=left,high=right;
        while(low<high)
        {
            while(ar[high][1]>=key&&low<high)
                high--;
            ar[low][1]=ar[high][1];
            ar[low][0]=ar[high][0];
            while(ar[low][1]<=key&&low<high)
                low++;
            ar[high][1]=ar[low][1];
            ar[high][0]=ar[low][0];
        }
        ar[low][1]=key;ar[low][0]=keep;
        arrange(ar,left,low-1);
        arrange(ar,low+1,right);
    }
}
int main()
{
    int n,x,l,i,j,count=0,min=-2e10;
    int ar[100000][2]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&x,&l);
        ar[i][0]=x-l;
        ar[i][1]=x+l;
    }
    arrange(ar,0,n-1);
    for(i=0;i<n;i++)
    {
        if(ar[i][0]>=min)
        {
            min=ar[i][1];
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 896
n,k=list(map(int,input().split()))
m=list(map(int,input().split()))
for i in range(n):
    m[i]*=(-1)

import heapq
heapq.heapify(m)
for i in range(k):
    p=heapq.heappop(m)
    heapq.heappush(m,p/2)
s=0
for i in range(n):
    s+=int(abs(m[i]))
print(s)

Measured memory_bytes: 85928
import bisect

A, B, Q = map(int, input().split())
INF = 10 ** 11
s_list = [-INF] + [int(input()) for i in range(A)] + [INF]
t_list = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    near_right_s = bisect.bisect_right(s_list, x)
    near_right_t = bisect.bisect_right(t_list, x)
    min_distance = INF
    for s in [s_list[near_right_s - 1], s_list[near_right_s]]:
        for t in [t_list[near_right_t - 1], t_list[near_right_t]]:
            distance_1 = abs(s - x) + abs(t - s)
            distance_2 = abs(t - x) + abs(s - t)
            min_distance = min(min_distance, distance_1, distance_2)
    print(min_distance)

Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    put(min(n*a,b));
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let (d,g) = {
        let xs = read_vec_i64();
        (xs[0] as usize, xs[1] as usize)
    };
    let (ps, cs) = {
        let mut ps = vec![];
        let mut cs = vec![];
        for _ in 0..d {
            let mut xs = read_vec_i64();
            ps.push(xs[0] as usize);
            cs.push(xs[1] as usize / 100);
        }
        (ps,cs)
    };
    let inf = 1usize << 40;
    let mut xs = vec![inf; 212345];
    let mut ys = vec![inf; 212345];
    let m = 200001;
    xs[0] = 0;
    for i in 0..d {
        for k in 0..m {
            ys[k] = xs[k];
        }
        for k in 0..m {
            for j in 1..ps[i] {
                ys[k+(i+1)*(j)] = min(ys[k+(i+1)*(j)], xs[k] + j);
            }
            ys[k+(i+1)*ps[i]+cs[i]] = min(ys[k+(i+1)*ps[i]+cs[i]], xs[k] + ps[i]);
        }
        for k in 0..m {
            xs[k] = ys[k];
        }
    }
    let mut res = inf;
    for i in g/100..212345 {
        res = min(res, xs[i]);
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}

#[allow(dead_code)]
fn tf<T>(cond: bool, t: T, f: T) -> T {
    if cond { t } else { f }
}


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

using ll=long long; 

bool hantei(string s){
	for(int i=0; i<int(s.size()); i++){
		if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T')return false;
	}
	return true;
}

void solve(){
	string s;
	cin>>s;
	int maxv=0;
	for(int i=0; i<int(s.size()); i++){
		for(int j=i+1; j<int(s.size())+1; j++){
			if(hantei(s.substr(i, j-i))){
				int n=int(s.substr(i, j-i).size());
				maxv=max(maxv, n);
			}
		}
	}
	cout<<maxv<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(int, "a", int, "b");

void main() {
    int n; long k;
    scan(n, k);

    auto a = readln.split.to!(long[]).sort();
    auto f = readln.split.to!(long[]).sort!"a > b"();

    auto as = a.sum();

    long ok = inf6, ng = -1;

    bool check(long t) {
        auto tf = iota(n).map!(i => t / f[i]).array;
        auto km = iota(n).map!(i => max(0, a[i] - tf[i])).sum(0L);
        return km <= k;
    }

    while (abs(ok - ng) > 1) {
        long mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }

    auto ans = ok;
    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
string to_string(const char &ch) {
  return string(1, ch);
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define pr(...) 42
#endif

double tick() {
  static clock_t oldtick;
  clock_t newtick = clock();
  double diff = 1.0 * (newtick - oldtick) / CLOCKS_PER_SEC;
  oldtick = newtick;
  return diff;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(10);
  cout << fixed;
  #ifdef LOCAL
    freopen("b_roller_coaster.in", "rt", stdin);
  #endif

  int n, k;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    if (val >= k) ans++;
  } 
  cout << ans << endl;

  #ifdef LOCAL
    fprintf(stderr, "Time elapsed: %.12lf secs...\n", tick());
  #endif
  return 0;
}


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

int main() {
    string S;
    while (cin >> S && S != "0") {
        int N = S.length();
        vector<vector<int>> dp = vector<vector<int>>(N + 1, vector<int>(11, 0));
        for (int i = 0; i < N; i++) {
            int d = S[i] - '0';
            for (int j = 0; j < 11; j++) {
                dp[i + 1][(10 * j + d) % 11] += dp[i][j];
            }
            if (d) dp[i + 1][d] += 1;
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans += dp[i + 1][0];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 9964
n,k = map(int,input().split(" "))
sunuke = [0]*n
for i in range(k):
  d = int(input())
  a = list(map(int,input().split(" ")))
  for a_i in a:
    sunuke[a_i-1] += 1
sum_sunuke = 0
for sunuke_i in sunuke:
  if sunuke_i == 0:
    sum_sunuke += 1
print(sum_sunuke)

Measured memory_bytes: 9204
A, B = map(int, input().split())

# summary = A
# for XORed in range(A+1, B+1):
#     summary = summary ^ XORed

def XORfromZERO(x):
    rest = x % 2
    quotient = (x + rest) / 2
    if rest == 0:
        if quotient % 2 == 0:
            return 0 ^ x
        else:
            return 1 ^ x
    else:
        if quotient % 2 == 0:
            return 0
        else:
            return 1

print(XORfromZERO(A-1) ^ XORfromZERO(B))


Measured memory_bytes: 2940
import java.util.Scanner;

class Main{
  public static void main(String[] args) throws Exception{
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    System.out.println(check(S));
    sc.close();
  }
  static String check(String s) {
    char[] cList = s.toCharArray();
    //aaパターン
    for (int i = 0; i < cList.length - 1 ; i++) {
      if (cList[i] == (cList[i+1])) {
        return (i+1) + " " + (i+2);
      }
    }
    //abaパターン
    for (int i = 0; i < cList.length - 2 ; i++) {
      if (cList[i] == (cList[i+2])) {
        return (i+1) + " " + (i+3);
      }
    }
    // no match
    return (-1) + " " + (-1);
  }
}

Measured memory_bytes: 26660
/*
      author : nishi5451
      created: 11.08.2020 20:08:43
*/

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


int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s=="abc") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    int n;
    cin >> n;
    ll d[101] = {};
    for(int i = 2; i <= n; i++){
        int m = i;
        for(int j = 2; m != 1; j++){
            while(m % j == 0){
                d[j]++;
                m /= j;
            }
        }
    }
    int c74 = 0, c24 = 0, c14 = 0, c4 = 0, c2 = 0;
    for(int i=2; i <= n; i++){
        if (d[i] >= 74) c74++;
        if (d[i] >= 24) c24++;
        if (d[i] >= 14) c14++;
        if (d[i] >= 4)  c4++;
        if (d[i] >= 2)  c2++;
    }
    int ans = c74 + c24 * (c2-1) + c14 * (c4-1) + c4 * (c4-1) / 2 * (c2-2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <numeric>
#include <math.h>
using namespace std;
int main(){
  	int A, B, K, i=0;
    cin>>A>>B;
    if(B==1){
      cout<<0<<endl;
    }else{
      for(i=0; (A*(i+1))-i<B; i++)
      {
        
      }
      cout<<i+1<<endl;
    }
    
    
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll N;
    cin >> N;
    ll ans = N - 1;
    For(i, 1, int(sqrt(N)) + 10) {
        if (N % i == 0) {
            ans = min(ans, i + (N / i) - 2);
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    dic = {}
    for i in range(2,n+1):
        a = i
        p = 2
        while p * p <= a:
            if a % p == 0:
                if p in dic:
                    dic[p] += 1
                else:
                    dic[p] = 1
                a //=p
            else:
                p += 1
        if a in dic:
            dic[a] += 1
        else:
            dic[a] = 1
    ans = 1
    #print(dic)
    for k,v in dic.items():
        ans *= (v+1)
    print(ans%mod)
if __name__ == '__main__':
  main()


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

const Long MOD = 1e9 + 7;
const int N = 2e5 + 1;
vector<int> adj[N];
bool vis[N];
int deep = 0;

void dfs( int u ){
    vis[u] = true;
    ++deep;
    for( int v : adj[u] ){
        if( !vis[v] ) {
            dfs(v);
        }
    }
    return;
}

int main(){
  int n , m;
  cin >> n >> m;
  for( int i = 0 ; i < m ; ++i ){
      int u , v;
      cin >> u >> v;
      --u ; --v;
      adj[u].push_back(v);
      adj[v].push_back(u);
  }

    int ans = 0;
  for( int i = 0 ; i < n ; ++i ){
      if( !vis[i] ){
          deep = 0;
          dfs(i);
          ans = max( ans , deep );
      }
  }
  cout << ans ;
  return 0;
}


Measured memory_bytes: 21012
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

signed main() {
	int N;
	//vector<int>list;
	int list[2005];
	int cnt = 0;

	//memset(list, 99999999, sizeof(list));
	for (int i = 0; i < 2005; i++) {
		list[i] = 99999999;
	}

	cin >> N;

	for (int i = 0; i < N; i++) {
		int num;
		cin >> num;
		//list.push_back(num);
		list[i] = num;
	}

	//sort(list.begin(), list.end());
	sort(list , list + SIZE_OF_ARRAY(list));
	int indexk = 0;

	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {
			//for (int k = indexk; k > j;) {
			//for (int k = indexk; k < N; k++) {
				//if (k <= j)continue;
				//if (list[i] + list[j] <= list[k]) {
				//	//cnt += (k - j);
				//	cnt += (k + 1);
				//	//cnt += (indexk + 2);
				//	cout << "cnt->" << cnt << " k->" << k << endl;
				//	indexk = k - 1;
				//	break;
				//}
				//else {
				//	//indexk = k;
				//}

				//int num = list[i] + list[j] + list[k];
				//int num = min( { list[i] + list[j], list[j] + list[k], list[i] + list[k]});

				//if (list[i] + list[j] < num && list[i] + list[k] < num &&list[j] + list[k] < num) {
				if (list[i] + list[j] > list[k] && list[i] + list[k] > list[j] &&list[j] + list[k] > list[i]) {
					cnt++;
				}
				else {
					break;
				}
			}
			//indexk = j + 2;
			//indexk = 0;
		}
		//indexk = 0;
	}



	cout << cnt << endl;


	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define INFTY 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];



void merge(struct Card A[],int n,int left,int mid,int right){
 
  int n1,n2,j,k,i;
 
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }

  L[n1].value=INFTY;
  R[n2].value=INFTY;
  i=0;
  j=0;

  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
    }
  }
}

void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
    }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card num, x;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      num=A[i];
      A[i]=A[j];
      A[j]=num;	
    }
  }
  num=A[i+1];
  A[i+1]=A[r];
  A[r]=num;
  return i+1;
}


void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if (p < r){
    q = partition(A,n,p,r);
    quickSort(A,n,p,q - 1);
    quickSort(A,n,q + 1,r);
  }
}

int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
  scanf("%d", &n);

  for (i = 0;i < n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for (i = 0;i < n;i++){
    if (A[i].suit != B[i].suit)stable = 0;
  }

  if (stable == 1)printf("Stable\n");
  else printf("Not stable\n");
  for (i = 0;i < n;i++){
    printf("%c %d\n", B[i].suit, B[i].value);
  }
}



Measured memory_bytes: 4200
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(" ").map(Number);
console.log(function(a, b, c) {
  var count = c % a == 0 ? 1 : 0;
  return a == b ? count : count + arguments.callee(a + 1, b, c);
}(input[0], input[1], input[2]));

Measured memory_bytes: 19884
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := []int{}
	fmt.Scan(&A)
	for n := 0; n < N; n++ {
		var tmp int
		fmt.Scanf("%d", &tmp)
		A = append(A, tmp)
	}
	minimum := A[0]
	ans := 1
	for n := 1; n < N; n++ {
		if minimum > A[n] {
			ans++
			minimum = A[n]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int N=500005,M=1000000007;
int n,i,j,t;
long long a[N],f[66];
char c[N];
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(i=1;i<=n;++i)
			scanf("%lld",&a[i]);
		scanf("%s",c+1);
		memset(f,0,sizeof(f));
		for(i=n;i>=1;--i)
			if(c[i]=='0')
			{
				long long x=a[i];
				for(j=62;j>=0;--j)
					if((x>>j)&1)
						if(!f[j])
						{
							f[j]=x;
							break;
						}
						else
							x^=f[j];
			}
			else
			{
				long long x=a[i];
				for(j=62;j>=0;--j)
					if((x>>j)&1)
						x^=f[j];
				if(x)
					break;
			}
		if(i<=0)
			puts("0");
		else
			puts("1");
	}
}


Measured memory_bytes: 3680
fn main() {
	let mut line = String::new();
	let _ = std::io::stdin().read_line(&mut line);
	let vec: Vec<&str> = line.split_whitespace().collect();
	let n:i32 = vec[0].parse().unwrap();
	let a:i32 = vec[1].parse().unwrap();
	let b:i32 = vec[2].parse().unwrap();

	println!("{}", std::cmp::min(n * a, b));
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;
    using ll = long long;

    int A, B;
    cin >> A >> B;
    int ans = A - 2 * B;
    if(ans < 0)
        cout << 0 << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll k, s;
    cin >> k >> s;

    ll ans = 0;
    rep(i, k+1){
        rep(j, k+1){
            if(s - i - j <= k && s -i - j>=0) ans++;
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b;
	scanf("%d%d", &a, &b);
	if(a != 1 && b != 1)printf("1\n");
	else if(b != 2 && a != 2)printf("2\n");
	else printf("3\n");
	
	
	Please AC;
}


Measured memory_bytes: 760
#include<iostream>
#include<cstdio>
#include<map>
#include<string>
#include<vector>
using namespace std;

const int ROW = 10000 + 10;
const int COL = 10 + 5;

int n;

int  main()
{
    cin>>n;
    int a=n/100;
    n=n-a*100;
    int b=n/10;
    int c=n%10;
    //cout<<a<<endl<<b<<endl<<c<<endl;
    if(a==c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,a,b,c,d;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


/* dijkstra(G,s,dis)
    入力：グラフ G, 開始点 s, 距離を格納する dis
    計算量：O(|E|log|V|)
    副作用：dis が書き換えられる
*/
void dijkstra(const graph &g, int s, vector<long long> &dis) {
    int N = g.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P>> pq;  // 「仮の最短距離, 頂点」が小さい順に並ぶ
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {  // 最短距離で無ければ無視
            continue;
        }
        for (auto &e : g[v]) {
            if (dis[e.to] > dis[v] + e.cost) {  // 最短距離候補なら priority_queue に追加
                dis[e.to] = dis[v] + e.cost;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}
 int main(){
   

   ll n, m ; cin>>n>>m ;
  graph g(3*n) ;

  rep(i,m){
    ll a,b ; cin>>a>>b ;
    a-- ;b-- ;
   edge e ;
   e.to= 3*b+1 ;e.cost= 1 ;
    g[3*a].pb(e) ;
    e.to=3*b+2 ;
    g[3*a+1].pb(e) ;
    e.to=3*b ;
    g[3*a+2].pb(e) ;
  }
  
  ll s,t ; cin>>s>>t ;
  s-- ;t-- ;
  vector<ll> dis ;

  dijkstra(g,s*3,dis) ;
  if(dis[3*t]==INF) cout<<-1<<endl ;
  else cout<< dis[3*t]/3 <<endl ;
 
   return 0;
  }

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

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

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

char s[202000];
int n;
int nremoved = 0;
int nS;

int main()
{
	int prev;
	scanf("%s", s);
	n = strlen(s);
	nremoved = 0;
	for (int i = 0; i< n; ++i) {
		if (s[i] == 'S') {
			nS++;
		} else if (s[i] == 'T') {
			if (nS) {
				nremoved += 2;
				nS--;
			}
		}
	}
	printf("%d\n", n - nremoved);
	return 0;
}


Measured memory_bytes: 384
a,b,c,d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
def MAX(n,m):
  if n >= m:
    return n
  else:
    return m
x1 = MAX(a*c,a*d)
x2 = MAX(b*c,b*d)
print(MAX(x1,x2))


Measured memory_bytes: 9172
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
    int n;
    while(cin>>n) {
        int a[2*n];
        int i;
        for(i=0;i<2*n;i++) cin>>a[i];
        sort(a,a+2*n);
        int sum=0;
        for(i=0;i<2*n;i+=2) {
        sum+=a[i];
    }
    cout<<sum<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int x,h,m,s;

    cin >> x ;

    h = x/3600;
    m = (x-h*3600)/60;
    s = (x-h*3600)%60;

    cout << h << ":" << m << ":" << s << endl;

    return 0;
}

Measured memory_bytes: 1164
N = int(input())

# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
m = 10**100
for v in make_divisors(N):
    A = v
    B = N // v
    m = min(m, max(len(str(A)), len(str(B))))

print(m)

Measured memory_bytes: 39536