akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m,k;
    while(cin>>n>>m>>k){
        vl a(n+1), b(m+1);
        fore(i,1,n+1) cin>>a[i];
        fore(i,1,m+1) cin>>b[i];
        // b.push_back(INT_MAX);

        partial_sum(all(a), a.begin());
        partial_sum(all(b), b.begin());

        // print(a);
        // print(b);


        ll mx = 0;
        for(int i=0; i<=n; ++i){
            if(a[i]>k) break;
            ll req = k - a[i];
            auto pos = upper_bound(all(b), req);
            if(pos!=b.begin()){
                --pos;
                ll cur = distance(b.begin(), pos);
                // deb(i,req, cur);
                mx = max(mx, cur+i);
            }
        }
        cout<<mx<<"\n";
    }
    return 0;
}

Measured memory_bytes: 6368
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int T = sc.nextInt();
		int []t = new int [n+1];
		int []s = new int [n+1];
		
		t[0] = sc.nextInt();
		for(int i = 1; i < n ; i++) {
			t[i] = sc.nextInt();
			s[i - 1] = t[i] - t[i - 1];
		}
		int sum = 0;
		for(int i = 0; i < n ;i++) {
			if(T >= s[i]) {
				sum += s[i];
				
			}
			if(T < s[i]) {
				sum += T;
			}
		}
		System.out.println(sum + T);

	}

}


Measured memory_bytes: 87608
while que  =  gets
  que.chomp
    stack = []
    que = que.split(" ")

    while que.size>0
      a = que.shift
      if  a == "+"
        x = stack.shift.to_i + stack.shift.to_i
      elsif a == "-"
        x = -stack.shift.to_i + stack.shift.to_i
      elsif a == "*"
        x = stack.shift.to_i * stack.shift.to_i 
      else
        x = a
      end
      stack.unshift(x)
    
    end
    puts stack[0]
  end

Measured memory_bytes: 8664
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll ave=0;
  rep(i,n)ave+=a[i];
  ave/=n;
  ll ans1=0;
  ll ans2=0;
  rep(i,n){
    ans1+=(a[i]-ave)*(a[i]-ave);
    ans2+=(a[i]-(ave+1))*(a[i]-(ave+1));
  }
  cout<<min(ans1,ans2)<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

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;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  int n;
  cin>>n;
  if(n%2==0){
    cout<<n/2-1<<endl;
  }
  else{
    cout<<n/2<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b)    for (int i = a; i <= (int) b; ++i)
#define ii              pair <int, int>
using namespace std;
const int N = 1503;
int n, m;
vector <ii> adj[N];

void init() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);
}

priority_queue <ii, vector <ii>, greater <ii> > Q;
int d[N][N], Max;
void dijk(int st) {
    d[st][st] = 0; Q.push({ 0, st });
    while (Q.size()) {
        int u = Q.top().second, du = Q.top().first;
        Q.pop();
        if (du != d[st][u]) continue;
        Max = max(Max, du);
        for (ii it : adj[u]) {
            int v = it.second, w = it.first;
            if (d[st][v] > du + w) d[st][v] = du + w, Q.push({ d[st][v], v });
        }
    }
}

queue <int> dm;
int vis[N];
void trace(int st) {
    FOR(i, 1, n) if (d[st][i] == Max) dm.push(i), vis[i] = st;
    while (dm.size()) {
        int u = dm.front(); dm.pop();
        for (ii it : adj[u]) {
            int v = it.second, w = it.first;
            if (d[st][u] == d[st][v] + w && vis[v] < st) vis[v] = st, dm.push(v);
        }
    }
}

void solve() {
    cin >> n >> m;
    FOR(i, 1, m) {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back({ w, v }), adj[v].push_back({ w, u });
    }

    memset(d, 0x3f, sizeof d);
    FOR(i, 1, n) dijk(i);

    FOR(i, 1, n) trace(i);
    int dem = 0;
    FOR(i, 1, n) if (vis[i] == 0) ++dem;
    cout << dem << '\n';
    FOR(i, 1, n) if (vis[i] == 0) cout << i << '\n';
}

main() {
    init(); solve();
}



Measured memory_bytes: 12208
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int a, b, sum;

	scanf("%d%d", &a, &b);
	sum = a + b;

	switch (sum) {
	case 3:
		printf("%d", 3);
		break;

	case 4:
		printf("%d", 2);
		break;

    case 5:
	    printf("%d", 1);
	    break;

	}
	return 0;
}

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

int main(){
  unsigned long long int ans = 1;
  int n;
  int flag = 0;
  cin >> n;
  vector<long> a(n);
  for(int i=0;i < n;i++){
    cin >> a.at(i);
    if(a.at(i)==0){
      flag = 1;
    }
  }
  
  for(int i=0;i < n;i++){
    ans *= a.at(i);      
  }
  if(ans > 1000000000000000000 || ans <= 0){
    if(flag == 1){
      cout << ans << endl;
    }
    else{
      cout << "-1" << endl;
    }
  }
  else{
    cout << ans << endl;
  }
}



Measured memory_bytes: 4036
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#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 <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    LL a[SIZE];
    a[0] = 0;
    for( int i = 1; i <= n; ++i ) cin >> a[i];
    sort( a, a + n + 1 );

    LL sum[SIZE] = {};
    for( int i = 1; i <= n; ++i ) {
        sum[i] = sum[i - 1] + a[i];

    }
    
    int res = 1;
    bool flg = true;
    for( int i = n - 1; i >= 0 && flg; --i ) {
        if( sum[i] * 2 < a[i + 1] ) {
            flg = false;

        } else {
            ++res;

        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	//????????????????????¨NG??£??????
	int i,j,h,w;
	scanf("%d %d",&h,&w);
	while((h != 0) || (w != 0)){
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d",&h,&w);
	}
		
	return 0;
}

Measured memory_bytes: 572
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b) * (static_cast<int>(a > b)*2 - 1); }
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

signed main()
{	
	LL X;
	cin >> X;

	LL year = 0, yen = 100;
	while (yen < X) {
		yen = static_cast<LL>(yen * 1.01);
		year++;
	}

	COL(year);
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;

int main(int, char**) {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ret = 0;
	if (k <= a) {
		ret = k;
	} else if (k <= a + b) {
		ret = a;
	} else {
		ret = a - (k - a - b);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3604
import sys
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
K = ir()
length = len(str(N))

def F(length, K, N):
    if length < K:
        return 0
    if K == 0:
        return 1
    if length == 1: #この時、Kも1
        return N
    ret = 0
    top = int(str(N)[0])
    if length-K >= 1:
        ret += factorial(length-1) // factorial(K) // factorial(length-K-1) * 9 ** K # 一個前まで    
    ret += factorial(length-1) // factorial(K-1) // factorial(length-K) * (top-1) * 9 ** (K-1) # 一桁目がtopより小さい数  
    # 一桁目がtopと同じ数
    if K > 1: 
        N = int(str(N)[1:])
        length = len(str(N))
        ret += F(length, K-1, N)
    else:
        ret += 1 # 2000のような数
    return ret

answer = F(length, K, N)
print(answer)


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

int main(){
    
    char S[26],i,j,len,ct;
    
    scanf("%s",S);
    
    len=strlen(S);
    for(i=0;i<len-1;i++){
        for(j=i+1;j<len;j++){
            if(S[i]==S[j])ct++;
        }
    }
    if(ct==0)printf("yes\n");
    else printf("no\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{

    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

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

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> rensou1, rensou2;
    ll a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (i % 2)
        {
            rensou1[a]++;
        }
        else
        {
            rensou2[a]++;
        }
    }
    ll sum = 0;
    ll tmp;
    ll max = 0;
    for (auto f : rensou1)
    {
        if (chmax(max, f.second))
        {
            tmp = f.first;
        }
        sum += f.second;
    }
    ll ans1 = sum - max;
    sum = 0;
    max = 0;
    for (auto f : rensou2)
    {
        if (f.first != tmp)
        {
            chmax(max, f.second);
        }
        sum += f.second;
    }
    ll ans2 = sum - max;
    ll finans1 = ans1 + ans2;

    sum = 0;
    max = 0;
    for (auto f : rensou2)
    {
        if (chmax(max, f.second))
        {
            tmp = f.first;
        }
        sum += f.second;
    }
    ans1 = sum - max;
    sum = 0;
    max = 0;
    for (auto f : rensou1)
    {
        if (f.first != tmp)
        {
            chmax(max, f.second);
        }
        sum += f.second;
    }
    ans2 = sum - max;
    ll finans2 = ans1 + ans2;
    cout << min(finans1, finans2) << endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

int const MAXN = 2e5;

std::vector<int> G[MAXN];
std::map<std::pair<int,int>, int> m;
int N, color[MAXN];

void dfs(int v, int p) {
  int pc = 0;
  if(p >= 0) pc = color[m[std::make_pair(v, p)]];
  int col = 1;
  for(auto c: G[v]) if(c != p) {
    if(col == pc) ++col;
    color[m[std::make_pair(c, v)]] = col;
    ++col;
    dfs(c, v);
  }
}

int main() {
  std::cin >> N;
  for(int i = 0; i < N-1; ++i) {
    int a, b; std::cin >> a >> b; --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
    m[std::make_pair(a, b)] = i;
    m[std::make_pair(b, a)] = i;
  }
  dfs(0, -1);
  int K = 0;
  for(int i = 0; i < N-1; ++i) K = std::max(K, color[i]);
  std::cout << K << std::endl;
  for(int i = 0; i < N-1; ++i) std::cout << color[i] << std::endl;
  return 0;
}


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

/** defines and macros */
#define ll long long
#define ull unsigned long long
#define loop(n) for(int i = 0; i < n; i++)
#define loop1(n) for(int i = 1; i <= n; i++)
#define all(v) ((v).begin()), ((v).end())
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vvi vector<vi>
#define vvpii vector<vii>
#define PB push_back

#define fw(fileName) freopen(fileName, "w", stdout)
#define fr(fileName) freopen(fileName, "r", stdin)
#define fc(stream) fclose(stream);

#define faster_IO_stream ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define endl "\n"

/*To compile and run

	g++ -o main main.cpp && ./main

*/

/*
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣤⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣤⣀⡀⠄⠄⠄⠄⠄⣰⣷⡀⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⣀⣀⣀⠄⠄⠄⠄⠄⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠄⠄⢠⣿⣿⣷⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠤⠒⠛⠛⠛⠛⠻⠷⣦⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣿⣿⣿⠟⠁⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢀⣤⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⡤⠐⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⢀⣶⣿⣿⠿⢛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⢠⣿⠟⠉⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠘⠁⠄⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠻⣿⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⣾⣿⡿⣽⡿⢹⣿⣿⣟⣿⢻⠇⢀⢹⣿⢿⣿⣿⣿⣿⣿⣦⣙⢿⣿⢷⣈⠻⢿⣟⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢿⡿⠁⡿⠁⢸⣿⣿⢹⡇⢸⠄⠈⠄⠻⣏⠻⣿⡿⣿⣿⣿⣌⠛⢿⡌⠙⢧⣀⠙⢳⡹⢻⣿⣿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠘⡇⠄⡇⢠⣼⣿⣿⠈⡇⠘⠤⠤⠤⠤⢜⣢⣘⡻⢮⡛⢿⣿⣷⣬⡤⠤⠤⠤⠥⠤⠥⢬⣿⣧⡄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠁⠄⠄⠘⢿⡏⠛⠄⠄⠄⠄⠄⠄⠄⠄⠄⠙⣿⣿⣿⡿⠋⠉⠛⠉⠄⠄⠄⠄⠄⠄⠄⢹⡿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡟⠁⠈⢳⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠱⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⡜⠁⠄⠄⠈⢇⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠑⠦⢄⣀⣀⣀⣀⣀⠴⠊⠄⠄⠄⠄⠄⠄⠑⠤⢀⣀⣀⣀⡀⠠⠔⠋⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣶⣦⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣤⣶⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣶⣄⣀⣀⣀⣀⣤⣾⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⣿⣿⣿⣿⠟⠁⠄⠄⠄⠄⠙⢿⣿⣿⣿⡟⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⠟⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠉⠛⠿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
*/

const double pi = 3.14159265358979323846;
const int module = 1e9 + 7;

//bool compare(pii x, pii y)
//{
//	return abs(x.first - y.first) + (ull) abs(x.second - y.second) < abs(x.first - y.second) + (ull) abs(x.second - y.first);
//}

int main() {
	faster_IO_stream

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a * c, a * d), max(b * c, b * d)) << "\n";

	return 0;
}


Measured memory_bytes: 3648
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// functions and classes

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

	ll A;
	cin >> A;

	bool factorization = false;
	for (ll i = 1; i <= 9; ++i)
	{
		if (A % i != 0)
			continue;
		if (A / i >= 10)
			continue;
		factorization = true;
		break;
	}

	cout << (factorization ? "Yes" : "No") << endl;

	return 0;
}


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

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

	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int d = 0;
		for (int j = i; j; j /= 10)
		{
			d += j % 10;
		}

		if (a <= d && d <= b)
		{
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	solve()
}

func solve() {
	_, K := ReadInt2()
	R, S, P := ReadInt3()
	T := ReadLine()
	l := make([][]string, K)

	for i, c := range T {
		l[i%K] = append(l[i%K], string(c))
	}

	ans := 0
	for _, values := range l {
		tmp := 0
		prev := ""
		for _, c := range values {
			if prev != c {
				if c == "p" {
					prev = "p"
					tmp += S
				} else if c == "s" {
					prev = "s"
					tmp += R
				} else {
					prev = "r"
					tmp += P
				}
			} else {
				prev = ""
			}
		}
		ans += tmp
	}
	fmt.Println(ans)
}

func ReadLine() string {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func ReadWords() []string {
	str := strings.Split(ReadLine(), " ")
	return str
}

func ReadLineInt64() []int64 {
	str := ReadWords()
	l := len(str)

	ret := make([]int64, l)

	for i, s := range str {
		ret[i] = s2i64(s)
	}
	return ret
}

func ReadLineInt() []int {
	values := ReadLineInt64()
	ret := make([]int, len(values))
	for i, v := range values {
		ret[i] = int(v)
	}
	return ret
}

func ReadInt() int {
	v := ReadLineInt()
	return v[0]
}
func ReadInt2() (int, int) {
	v := ReadLineInt()
	return v[0], v[1]
}
func ReadInt3() (int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2]
}
func ReadInt4() (int, int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2], v[3]
}

func ReadInt64() int64 {
	v := ReadLineInt64()
	return v[0]
}
func ReadInt64_2() (int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1]
}
func ReadInt64_3() (int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2]
}
func ReadInt64_4() (int64, int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2], v[3]
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int64
func Bool2Int64(b bool) int64 {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func Min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func Max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func Distance64(a, b int64) int64 {
	return Abs64(a - b)
}

// For int
func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func Min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func Max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func Distance(a, b int) int {
	return Abs(a - b)
}


Measured memory_bytes: 23936
#include <iostream>
#include <cstdio>
using namespace std;
int w[100000];
int n,k;
int work(int p)
{
    int sum,i=0,j=k;
    while(j--)
    {
        sum=0;
        while(sum+w[i]<=p)
        {
            sum += w[i];
            i++;
            if(i==n)
                return n;
        }
    }
    return i;
}
int main()
{
    int i,left=0,right=1000000000,mid;
    cin>>n>>k;
    for(i=0;i<n;i++)
        //cin>>w[i];
        scanf("%d",&w[i]);
    while(right-left>1)
    {
        mid = (right+left)/2;
        if(work(mid)<n)
            left = mid;
        else
            right = mid;
    }
    cout<<right<<endl;
    return 0;
}
 

 

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, L, Total, Min, min;
  cin >> N >> L;
  vector<int> apple(N);
  for (int i=0; i<N; i++){
    apple.at(i) = L+i;
    Total += apple.at(i);
  }
  Min = 1000;
  for (int i=0; i<N; i++){
    if (abs(L+i) < Min){
      Min = abs(L+i);
      min = L+i;
    }
  }
  Total -= min;
  cout << Total << endl;
}

Measured memory_bytes: 256
N,K,Q = map(int, input().split())
A = []
for a in range(Q):
	A.append(int(input()))


P = [K-Q] * N
for i in range(Q):
    P[A[i]-1] += 1
for i in range(N):
    if P[i] <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 10472
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

function main() {
	var numbers = readLine().split(" ");
	var N = parseInt(numbers[0]), M = parseInt(numbers[1]);
	
	var A=[], B=[], C=[];
    for (var i=0; i < M; i++){
        var s = readLine().split(" ");
        var a = parseInt(s[0])-1;
        var b = parseInt(s[1])-1;
        var c = parseInt(s[2]);
        A.push(a);
        B.push(b);
        C.push(c);
    }
    
    var dp = [];
    /*Declarando arreglo*/
	for (var i=0; i < N; i++){
		dp[i] = [];
		for (var j=0; j < N; j++){
			if (i!=j)
                dp[i].push(1000000000);
            else
                dp[i].push(0);
		}
	}
    
    for (var i=0; i < M; i++){
        if (dp[A[i]][B[i]] > C[i])
            dp[A[i]][B[i]] = C[i];
        if (dp[B[i]][A[i]] > C[i])
            dp[B[i]][A[i]] = C[i];
    }
    
    for (var k=0; k < N; k++){
        for (var i=0; i < N; i++){
            for (var j=0; j < N; j++){
                if (dp[i][j] > dp[i][k] + dp[k][j]){
                    dp[i][j] = dp[i][k] + dp[k][j];
                }
            }
        }
    }
    
    var ans=M;
    for (var i=0; i < M; i++){
        var shortest = false;
        for (var j=0; j < N; j++){
            if (dp[j][A[i]] + C[i] == dp[j][B[i]]){
                shortest = true;
            }
        }
        if (shortest == true) ans--;
    }
    console.log(ans);
	
	process.exit();
}

Measured memory_bytes: 21064
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;






int main() {

    
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];

    int cnt[n+1];
    rep(i,n+1) cnt[i] = 0;
    rep(i,n) ++cnt[a[i]];

    int s = 0;
    rep(i,n+1) {
        if (cnt[i] != 0) ++s;
    }

    sort(cnt, cnt+(n+1));

    int ans = 0;
    rep(i,n+1) {
        if (s <= k) break;
        if (cnt[i] != 0) {
            --s;
            ans += cnt[i];
        }
    }

    out(ans);



    return 0;
}




//              g++ -std=c++1z






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


d = {}
for a in A:
    if a in d.keys():
        d[a] += 1
    else:
        d[a] = 1



ls = sorted(d.values())
ans = 0
for v in ls[:len(ls)-k]:
    ans += v
print(ans)


Measured memory_bytes: 33152
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 1e6+2;

int main()
{
    fastio; //remove for interactive
    ll i, j, k, n, m, t;

    cin>>t;
    cout<<(t+1)%2<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	fastio();
	set<int> have;
	int n; cin >> n;
	for(int i = 0; i<n; i++){
		int x;
		cin >> x;
		if (have.count(x)) {cout << "NO\n"; return 0;}
		have.insert(x);
	}
	cout << "YES\n";
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;

	if (a > b) {
		cout << "Alice" << endl;
	}else if(b > a) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long 
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll x; cin >> x;
	ll ans = (x / 11) * 2;
	ll r = x % 11;
	if (r > 6) ans += 2;
	else if (r != 0) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
	proconio::input!{
		n: usize,
		m: usize,
		a: [proconio::marker::Usize1; m*2],
	}

	let mut city: [usize; 50] = [0; 50];
	for i in 0..m*2 {
		city[a[i]] += 1;
	}
	for i in 0..n {
		println!("{}", city[i]);
	}
}



Measured memory_bytes: 2124
import sys

def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def main():
	N, M, X = IL()
	c = [0] * N
	a = [[0] * M for _ in range(N)]
	for i in range(N):
		tmp = IL()
		c[i] = tmp[0]
		a[i][:] = tmp[1:]

	min_price = sys.maxsize
	for i in range(2**N):
		sum_price = 0
		rikaido = [0] * M
		for j in range(N):
			if (i>>j) & 1:
				sum_price += c[j]
				for k in range(M):
					rikaido[k] += a[j][k]
		if min(rikaido) >= X:
			min_price = min(min_price, sum_price)
	
	if min_price == sys.maxsize:
		print(-1)
	else:
		print(min_price)



if __name__ == "__main__":
	main()

Measured memory_bytes: 68708
fun main(args: Array<String>) {

    C.init()
    C.execute()

}

class C {

    companion object {
        var N = 0
        private var numberMap1 = mutableMapOf<Int, Int>()
        private var numberMap2 = mutableMapOf<Int, Int>()

        fun init() {

            N = readLine()!!.toInt()

            readLine()!!.split(" ").forEachIndexed { index, s ->

                val num = s.toInt()
                if (index % 2 == 0) {
                    if (numberMap1.containsKey(num)) {
                        numberMap1[num] = numberMap1[num]!! + 1
                    } else {
                        numberMap1[num] = 1
                    }
                } else {
                    if (numberMap2.containsKey(num)) {
                        numberMap2[num] = numberMap2[num]!! + 1
                    } else {
                        numberMap2[num] = 1
                    }
                }
            }
        }

        fun execute() {

            var num1Entry = numberMap1.maxBy {
                it.value
            }!!
            var num2Entry = numberMap2.maxBy {
                it.value
            }!!

            numberMap1.remove(num1Entry.key)
            numberMap2.remove(num2Entry.key)


            val num1MostSeeEntry = num1Entry
            val num2MostSeeEntry = num2Entry

            // 異なる数字かチェック
            if (num1Entry.key != num2Entry.key) {
                print(N - num1Entry.value - num2Entry.value)
                return
            }

            // 同じ数字の場合
            // 回数が異なる場合
            if (num1Entry.value > num2Entry.value) {
                // num1の方が多いってことは、num2には２個以上あるはず
                print(N - num1Entry.value - numberMap2.maxBy {
                    it.value
                }!!.value)
                return
            } else if (num1Entry.value < num2Entry.value) {
                // num2の方が多いってことは、num1には２個以上あるはず
                print(N - numberMap1.maxBy {
                    it.value
                }!!.value - num2Entry.value)
                return
            }

            // 同じ数字の場合
            // 回数も同じ場合
            if (numberMap1.size == 0) {
                print(num1Entry.value)
                return
            }

            // 同じ数字かつ出現回数が等しい場合
            // 次の値を見る
            num1Entry = numberMap1.maxBy { it.value }!!
            num2Entry = numberMap2.maxBy { it.value }!!

            if (num1Entry.value > num2Entry.value) {
                print(N - num1Entry.value - num2MostSeeEntry.value)
            } else {
                print(N - num2Entry.value - num1MostSeeEntry.value)
            }
            return
        }
    }
}






Measured memory_bytes: 64512
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;

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

    ans = a;
    if (b < a) ans--;
    
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
    int n; cin >> n;
    vector<ll> L(n);
    for(int i=0; i<n; i++) cin >> L[i];

    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            for(int k=j; k<n; k++){
                if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;

                if(L[i] > L[j] && L[i] > L[k] && L[i] < L[j] + L[k]){ ans++; continue;}
                if(L[j] > L[i] && L[j] > L[k] && L[j] < L[i] + L[k]){ ans++; continue;}
                if(L[k] > L[i] && L[k] > L[j] && L[k] < L[i] + L[j]){ ans++; continue;}
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
def warshall_floyd(n, edges):
    d = [[float('inf')] * n for _ in range(n)]
    for i in range(n):
        d[i][i] = 0
    for vf, vt, w in edges:
        d[vf][vt] = w
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


n, m, l = map(int, input().split())
edges = []
for _ in range(m):
    a, b, w = map(int, input().split())
    if w <= l:
        edges.append((a-1, b-1, w))
        edges.append((b-1, a-1, w))
wf = warshall_floyd(n, edges)

edges.clear()
for i in range(n):
    for j in range(i + 1, n):
        if wf[i][j] <= l:
            edges.append((i, j, 1))
            edges.append((j, i, 1))
wf = warshall_floyd(n, edges)

q = int(input())
ans = [0] * q
for i in range(q):
    s, t = map(lambda x:int(x) - 1, input().split())
    ans[i] = -1 if wf[s][t] == float('inf') else wf[s][t] - 1
for x in ans:
    print(x)


Measured memory_bytes: 101016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

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

    int s1=0, s2=0, s3=0;
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        if(p<=a){
            s1++;
        }else if(p<=b){
            s2++;
        }else{
            s3++;
        }
    }


    cout << min(min(s1,s2),s3) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i, n) for( int i=0 ; i<n ; i++ )
#define f(i, a, b) for( int i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll fact(ll n)
{
    ll ans = 1e14;
    for(ll i = 1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll sol = (i - 1) + (n/i - 1);
            ans = min(ans,sol);
        }
    }
    return ans;
}
int main()
{
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    int ans = INT_MAX;
    int i = 0;

    fi(i,n - m + 1)
    {
        int count = 0;
        fi(j,m)
        {
            if(t[j]!=s[i + j])
            {
                count++;
            }
        }
        ans = min(ans,count);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3716
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	vector< int > A(M), B(M);
	rep(i, M) cin >> A[i] >> B[i];
	vector< vector< int > > G(N);
	rep(i, M) {
		int a = A[i] - 1, b = B[i] - 1;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans = 0;
	vector< int > done(N, 0);
	auto f = [&](auto &&f, int x) -> int {
		int ret = 1;
		done[x] = 1;
		for (auto j : G[x]) {
			if (done[j])
				continue;
			ret += f(f, j);
		}
		return ret;
	};
	rep(i, N) if (!done[i]) {
		chmax(ans, f(f, i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 28284
import sys
S = input().strip()

for i in range(2,4):
    for j in range(0,len(S)+1-i):
        s = S[j:j+i]
        for k in set(s):
            if s.count(k)*2 > len(s):
                print(j+1,j+i)
                sys.exit(0)

print(-1,-1)


Measured memory_bytes: 3192
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  Int A[64], S = 0;
  for (int i = 0; i < N; ++i) {
    A[i] = lin();
    S += A[i];
  }
  sort(A, A + N);
  reverse(A, A + N);

  if (A[0] < N) {
    puts("0");
    return 0;
  }

  Int T[64], s = 0;
  memcpy(T, A, sizeof(T));

  Int K = S - N * (N - 1) - 1;
  Int lo = 0, hi = K + 1;
  while (hi - lo > 1) {
    Int mid = (hi + lo) / 2;
    Int tot = mid, C[64];
    C[0] = mid;
    for (int i = 1; i < N; ++i) {
      C[i] = max(0LL, mid - (A[0] - A[i] + N) / (N + 1) - 1);
      tot += C[i];
      if (tot > K) {
        break;
      }
    }
    if (tot <= K) {
      lo = mid;
      s = tot;
      for (int i = 0; i < N; ++i) {
        T[i] = A[i] - C[i] * N + (tot - C[i]);
      }
    } else {
      hi = mid;
    }
  }

  while (*max_element(T, T + N) >= N) {
    (*max_element(T, T + N)) -= N + 1;
    for (int i = 0; i < N; ++i) {
      ++T[i];
    }
    ++s;
  }

  printf("%lld\n", s);

  return 0;
}


Measured memory_bytes: 256
N = input()
a = ''
kazu = int(N[0])
for i in range(len(N) - 1):
  a = a + '9'
if N[1:] == a:
  print(9 * (len(N) - 1) + kazu)
else:
  print(9 * (len(N) - 1) + kazu - 1)
  

Measured memory_bytes: 9172
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

string s;
const string w[4] = {"dream", "dreamer", "erase", "eraser"};

bool dfs(int p) {
  if (p == s.size()) return true;

  for (int i = 0; i < 4; i++) {
    int ws = w[i].size();
    if (s.size() - p >= ws && s.substr(p, ws) == w[i]) {
      if (dfs(p + ws)) return true;
    }
  }

  return false;
}

int main(int argc, char *argv[])
{
  cin >> s;

  if (dfs(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
  if ((x += a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator-=(const mint a) {
  if ((x += mod-a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t>>1);
  a *= a;
  if (t&1) a *= *this;
  return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数
    // 割れる限り割り続ける
    while (N % a == 0) {
     ++ex;
      N /= a;
    }
    // その結果を push
    res.push_back({a, ex});
  }
  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

vector<mint> fac(2000003, 1);
void calc(int n){
  rep(i, n){
    fac.at(i+1) = fac.at(i) * (i+1);
  }
  return;
}

mint mcom(int r, int c){ // (r+c)!/(r!c!)
  mint a = fac.at(r+c);
  mint b = fac.at(r);
  mint d = fac.at(c);
  mint ans = a / (b * d);
  return ans;
  }

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> p = prime_factorize(M);
    calc(2000000);
    mint ans = 1;
    for(auto q : p){
        ll e = q.second;
        ans *= mcom(e, N-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
import typing
from typing import List, Counter
from itertools import product
class Grid:
    def __init__(self, field: List[str]):
        self.setField(field)
    
    def setField(self, field) -> None:
        self.column: int = len(field)
        self.row: int = len(field[0])
        self.field: List[List[str]] = [list(line) for line in field]

    def searchBomb(self) -> None:
        for i,j in product(range(self.column), range(self.row)):
            conn = tuple((i-1+k//3, j-1+k%3) for k in range(9))
            conn = tuple((x,y) for x,y in conn if 0<=x<self.column and 0<=y<self.row)
            if self.field[i][j] == '.':
                self.field[i][j] = str(Counter(self.field[x][y] for x,y in conn)['#'])
    
    def print(self) -> None:
        for line in self.field:
            print(''.join(line))

def main():
    with open(0) as f:
        H, W = map(int, f.readline().split())
        S = [line.strip() for line in f.readlines()]
    grid = Grid(S)
    grid.searchBomb()
    grid.print()

if __name__ == '__main__':
    main()

Measured memory_bytes: 10232