akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let (ans, _) = S.iter().fold((0, '_'), |(res, prev), &c| if c == prev { (res, c) } else { (res + 1, c) });

    println!("{}", ans);
}

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

int main(){
    int n;
    cin >> n;
    vector<double> array(n);
    for(int i=0;i<n;i++) cin >> array.at(i);
    sort(array.begin(),array.end());
    double sum = array.at(0);
    for(int i=1;i<n;i++){
        sum = (sum + array.at(i))/2;
    }
    printf("%.7lf\n",sum);
}

Measured memory_bytes: 3796
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

ll mpow(ll x, int n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
struct Combination {
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2);
        for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator()(int n, int k) { return fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
};

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    Combination C(H + W);

    int midPoint = min(H - A, W - B);
    ll ans = 0;
    rep(i, midPoint) {
        int h1 = H - A - i - 1;
        int w1 = B + i;
        int h2 = A + i;
        int w2 = W - B - i - 1;
        ans += C(h1 + w1, h1) * C(h2 + w2, h2) % MOD;
        ans %= MOD;
    }
    write(ans);
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
long long gcd(long long a, long long b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b)
{
    return a * b / gcd(a, b);
}
int main(){
    long long a,b;
    cin >> a >> b;
    if(a<b){
        cout << lcm(a,b);
    }else{
        cout << lcm(b,a);
    }
    return 0;
}

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

int main() {
  int n,k;  cin>>n>>k;
  vector<int> v(n);
  rep(i,n){cin>>v[i];}
  sort(v.begin(),v.end());
  int ans=0;
  rep(i,k){ans+=v[i];}
  cout<<ans;
}
      




Measured memory_bytes: 3628
S=input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
using System;
class Program
 {
        static void Main(string[] args)
        {
            string[] inputAStr = Console.ReadLine().Split(' ');
            string[] inputBStr = Console.ReadLine().Split(' ');
            string[] inputCStr = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int[] inputA = new int[3];
            int[] inputB = new int[3];
            int[] inputC = new int[3];
            for(int i = 0; i < 3; i++){
                inputA[i] = int.Parse(inputAStr[i]);
                inputB[i] = int.Parse(inputBStr[i]);
                inputC[i] = int.Parse(inputCStr[i]);
            }
            bool flag = true;
            int ABdiff = inputB[0] - inputA[0];
            int BCdiff = inputC[0] - inputB[0];
            for(int i = 0; i < 2; i++){
                if(inputB[i + 1] - inputA[i + 1] != ABdiff || inputC[i + 1] - inputB[i + 1] != BCdiff){
                    flag = false;
                }
            }
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            if(flag){
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
 }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;
	
	bool A = false, B = false;
	int X = std::stoi(s.substr(0, 2)), Y = std::stoi(s.substr(2, 2));
	if(0 < X and X <= 12) B = true;
	if(0 < Y and Y <= 12) A = true;
	
	if(A and B) printf("AMBIGUOUS\n");
	else if(A) printf("YYMM\n");
	else if(B) printf("MMYY\n");
	else printf("NA\n");
	return 0;
}


Measured memory_bytes: 256
function Main(raw: string) {
    const S = raw;
    const subst=S.split(/[^ATGC]/);
    console.log(subst.map((s:string)=>s.length).reduce((x,y)=>((x>y)?x:y)));
}

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


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<n;i++){
    cin>>b.at(i);
  }
  for(int i=0;i<n-1;i++){
    cin>>c.at(i);
  }
  int A=0;
  for(int i=0;i<n-1;i++){
    A+=b.at(a.at(i)-1);
    if(a.at(i)+1==a.at(i+1)){
      A+=c.at(a.at(i)-1);
    }
  }
  A+=b.at(a.at(n-1)-1);
  cout<<A<<endl;
}
  

Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    cout << H*W - (h*W + (H-h)*w)<< endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	scanf("%d",&N);
	if(N/10==9||N%10==9)puts("Yes");
	else puts("No");
}




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

int digit_sum(int x) {
  int s = 0;
  while (0 < x) {
    s += x % 10;
    x /= 10;
  }
  return s;
}

int main() {
  int N;
  cin >> N;
  cout << (N % digit_sum(N) ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c,M,ans;
  cin>>a>>b>>c;
  M=max(a,max(b,c));
  if(M==a)ans=b*c/2;
  if(M==b)ans=c*a/2;
  if(M==c)ans=a*b/2;
  cout<< ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool graph[101][101];
bool visit[101010];
vector<ll> to[101010];
vector<ll>ball(101010, 1);
vector<bool>flag(101010);

//long longしか使わない
//素数は1より大きい
int main() {
	ll x, y;
	cin >> x >> y;
	ll ans = 0;
	if (y >= x) {
		if (x >= 0) {
			ans = y - x;
		}
		else if (y <= 0) {
			ans = y - x;
		}
		else {
			ll min2 = min(abs(x), abs(y));
			ll max2 = max(abs(x), abs(y));
			ans = max2 - min2 + 1;
		}
	}
	else {
		if (y >= 0) {
			ans = x - y + 2;
			if (y == 0) {
				ans = abs(x) + 1;
			}
		}
		else if (x <= 0) {
			ans = x - y + 2;
			if (x == 0) {
				ans = abs(y) + 1;
			}
		}
		else {
			ll min2 = min(abs(x), abs(y));
			ll max2 = max(abs(x), abs(y));
			ans = max2 - min2 + 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5120
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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 = 1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> v(n+1, INF), a(n);
    rep(i,n) cin >> a[i];
    for(int i = n-1; i >= 0; --i){
        auto idx = lower_bound(v.begin(), v.end(), a[i]+1);
        *idx = a[i];
    }
    ll ans = 0;
    rep(i,n){
        if(v[i] < INF) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4756
#include<iostream>
main()
{
    int n,i,rem,initial,sum=0,final,temp,temp2;
    std::cin >> n;
    float rem2;
    if(n>=1 && n<=50000){
    rem=n/1.08;
    rem2=n/1.08;
    if(rem==rem2){
        temp=1;
    }
    else{temp=0;}
    if(temp==1){
        std::cout << rem;
    }
    else{
        initial=rem-1;
        final=rem+1;
        sum=0;
        for(i=initial;i<=final;i++){
            temp2=i*1.08;
            if(temp2==n){
                sum+=1;
                rem=i;
            }
        }
        if(sum==1)
        {std::cout << rem ;}
        else{std::cout <<":(";}
    }}
}

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

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int tmp;
    int ans = 0;

    tmp = min(A, K);
    ans += tmp;
    K -= tmp;

    tmp = min(B, K);
    K -= tmp;

    tmp = min(C, K);
    ans -= tmp;
    cout << ans << endl;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static int[] goals = {5, 7, 5, 7, 7};
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int L = 31;
        
        while (true) {
            int W = sc.nextInt();
            if (W == 0) break;
            
            int[] arr = new int[W];
            
            for (int i = 0; i < W; i++) {
                arr[i] = sc.next().length();
            }
            
            for (int i = 0; i < W; i++) {
                if (isPossible(arr, i, 0, 0)) {
                    System.out.println(i + 1);
                    break;
                }
            }
        }
    }
    
    public static boolean isPossible(int[] lens, int pos, int currLen, int goalPos) {
        if (goalPos >= 5) return true;
        if (currLen > goals[goalPos]) return false;
        if (currLen == goals[goalPos]) return isPossible(lens, pos, 0, goalPos + 1);
        return isPossible(lens, pos + 1, currLen + lens[pos], goalPos);
    }
}




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

using namespace std;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) (x.size())
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7


typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("test cases\\in.txt", "r", stdin);
    //freopen("test cases\\in.txt", "w", stdout);
    string s; cin>>s;
    int n = sz(s), m = 2019;
    int po10 = 1, suff =0;
    vector<int> mp(m);
    mp[suff]++;
    ll cnt = 0;
    for(int i = n-1; ~i; i--){
        int dig = s[i] - '0';
        suff = (suff + dig * po10%m)%m;
        po10 = (po10 * 10)% m;
        cnt += mp[suff];
        mp[suff]++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3784
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for big in range(0,A+1):
    for middle in range(0,B+1):
        for mini in range(0,C+1):
            kakaku=big*500+middle*100+mini*50
            if kakaku==X:
                count+=1


print(count)

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);

	string s; cin >> s;
	map<char, int> mp;
	++mp[s[0]];	
	++mp[s[1]];	
	++mp[s[2]];	
	++mp[s[3]];
	if (mp.size() == 2 && mp.begin()->second == 2) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    int h,w; cin >> h >> w;

    vector<vector<ll>> c(10,vector<ll> (10));
    rep(i,10) rep(j,10){
        cin >> c[i][j];
    }
    vector<vector<ll>> a(h,vector<ll> (w));
    rep(i,h) rep(j,w){
        cin >> a[i][j];
    }

    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    ll ans = 0;
    rep(i,h) rep(j,w){
        if(a[i][j] >= 0) ans += c[a[i][j]][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+EPS)

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

  int n, k;
  scan(n);
  scan(k);
  vint p(n);
  REP(i, n) scan(p[i]);
  int sumx = 0;
  int sum;
  REP(i, k){
    sumx += p[i];
  }
  sum = sumx;
  REP(i, n-k){
    sum = sum - p[i] + p[i+k];
    if(p[i] < p[i+k] && sumx < sum ){
      sumx = sum;
    }
  }


  cout << fixed << setprecision(10) << (sumx + k)/2.0 << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define ms memset
#define FOR(i, a, b) for(int i = a; i <= b; i++)

int main()
{
    int n, m, k; cin >> n >> m >> k; k++;
    vector<ll> A; A.pb(0); FOR(i,1,n){
        int a; cin >> a;
        A.pb(A[i-1] + a);
    }
    vector<ll> B; B.pb(0); FOR(i,1,m){
        int b; cin >> b;
        B.pb(B[i-1] + b);
    }
    B.pb(1000000001);
    int ans = 0;
    FOR(i,0,n){
        if (A[i] > k) break;
        int hehe = lower_bound(B.begin(), B.end(), k - A[i]) - B.begin() - 1;
        ans = max(ans, i + hehe);
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
        cout<<1<<endl;
    if(b==0)
        cout<<2<<endl;
    if(c==0)
        cout<<3<<endl;
    if(d==0)
        cout<<4<<endl;
    if(e==0)
        cout<<5<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <tuple>
#include <climits>
#define FOR(i,m,n) for(int i = (m); i < (n); i++)
#define REP(i,n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vint;

int main() {
	ll n, a[5], min{LLONG_MAX};
	cin >> n;
	for(int i = 0; i < 5; i++) {
		cin >> a[i];
		if(min > a[i]) {
			min = a[i];
		}
	}
	ll rslt{};
	rslt += 4;
	rslt += (n + min - 1)/ min;
	cout << rslt << endl;
	return 0;
}


Measured memory_bytes: 256
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 

 
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x,a,b,c,n,sum=0;
   string s,t;
cin>>a>>b>>c>>n;
x=min(a,n);
sum+=x;
n-=x;
x=min(b,n);
n-=x;
x=min(c,n);
sum-=x;
cout<<sum<<endl;

   
   
   
   
    return 0;
}

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

int main(){
int N,T;
  cin>>N>>T;
 vector<int>c(N),t(N);
   for(int i=0; i<N; i++){
  cin>>c[i]>>t[i];
   }
  vector<int>filtered_c;
  for(int i=0; i<N; i++){
  if(T>=t[i]){
    filtered_c.push_back(c[i]);
  }
  }
  if(filtered_c.size()==0){
  cout<<"TLE"<<endl;
  }
  else{
  cout<<*min_element(filtered_c.begin(), filtered_c.end())<<endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, H = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(N)]
a.sort(key = lambda x: -x[1])
cs = [0] * (N + 1)
mx = 0
for i in range(N):
  cs[i + 1] = cs[i] + a[i][1]
  mx = max(mx, a[i][0])
res = H + 1
for i in range(N + 1): res = min(res, -(-max(0, H - cs[i]) // mx) + i)
print(res)

Measured memory_bytes: 86040
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void getDivisor(ll n, vector<ll>& result)
{
	for (auto i = 1ll; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			result.push_back(i);
			if (i != n / i)
			{
				result.push_back(n / i);
			}
		}
	}
}

ll calc(ll A, ll B)
{
	return A * A * A * A * A - B * B * B * B * B;
}

int main()
{
	ll X;
	cin >> X;

	vector<ll> list;
	getDivisor(X, list);

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

	auto A = 0ll;
	auto B = 0ll;
	auto find = false;
	for (auto i = 0; i < (int)list.size(); ++i)
	{
		auto div = list[i];

		for (auto b = 0ll; true; ++b)
		{
			auto a = b + div;
			auto x = calc(a, b);
			if (x == X)
			{
				A = a;
				B = b;
				find = true;
				break;
			}
			else if (x > X)
			{
				break;
			}
		}

		if (find)
		{
			break;
		}

		for (auto b = 0ll; true; --b)
		{
			auto a = b + div;
			auto x = calc(a, b);
			if (x == X)
			{
				A = a;
				B = b;
				find = true;
				break;
			}
			else if (x > X && a < 0)
			{
				break;
			}
		}
	}
	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 3632
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s: Vec<char> = s.trim().chars().collect();
    let mut t = s.clone();
    t.reverse();
    if s != t {
        println!("No");
        return;
    }
    let n = s.len();
    t[..(n / 2)].reverse();
    t[(n / 2 + 1)..].reverse();
    if s == t {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define _K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ld long double
#define ll long long
#define pb push_back
#define pi acos(-1)
#define eps 1e-7
#define F first
#define S second
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).X
#define dot(a,b) (conj(a)*(b)).Y
#define all(f) (f).begin(),(f).end()
#define allr(f) (f).rbegin(),(f).rend()
const int mod = 1e9+7 , A = 1e5 ;
typedef complex <ld> point ;
typedef vector <point> polygon ;
typedef tuple <int , int , int> line ;
//====================================
ll n , ans[100005] , h[100005] ;
ll solve(ll ind)
{
	if (ind >= n)
		return 1e10 ;
	if (ind == n-1)
		return 0 ;
	if (ans[ind] != -1)
		return ans[ind] ;
	ll val = 1e10 ;
	val = min(val , abs(h[ind] - h[ind+1]) + solve(ind+1)) ;
	val = min(val , abs(h[ind] - h[ind+2]) + solve(ind+2)) ;
	ans[ind] = val ;
	return val ;
}
int main()
{
	_K
	cin >> n ;
	memset(ans , -1 , sizeof ans) ;
	for (int i =0 ; i < n ; cin >> h[i++]) ;
	cout << solve(0) ;
	return 0 ;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    unordered_map<int, int> mp;
    mp[0] = 1;

    ll ans = 0;
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        (sum += A) %= M;
        ans += (mp[sum]++);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int

using namespace std;

int main(){
  ll N,M; cin>>N>>M;
  vector <ll> dp(N+1,0);
  dp[0] = 1;

  for(int i=0;i<M;i++){
    int a; cin>>a;
    dp[a] = -INF;
  }

  dp[1]++;

  for(int i=2;i<=N;i++){
    dp[i] += (0 > dp[i-1]) ? 0 : dp[i-1];
    dp[i] += (0 > dp[i-2]) ? 0 : dp[i-2];

    if(dp[i] >0) dp[i] = dp[i] % MOD;

    
  }

  cout<<dp[N]<<endl;
  return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> ss(n);
    rep(i,n) {
        if(s[i] == 'R') ss[i] = 0;
        else if(s[i] == 'G') ss[i] = 1;
        else ss[i] = 2;
    }
    vector<vector<ll>> cnt(n,vector<ll> (3));
    rep(i,n){
        rep(j,3){
            if(i > 0) cnt[i][j] = cnt[i-1][j];
        }
        cnt[i][ss[i]]++;
    }

    ll ans = 0;

    FOR(i,1,n-1){
        int t = ss[i];
        int u = (t+1)%3;
        int v = (t+2)%3;
        ll lu = cnt[i-1][u], lv = cnt[i-1][v];
        ll ru = cnt[n-1][u] - cnt[i][u];
        ll rv = cnt[n-1][v] - cnt[i][v];
        ll tmp = lu*rv + lv*ru;
        int l = min(i, n-i-1);
        FOR(j,1,l+1){
            if(ss[i+j] == u && ss[i-j] == v) tmp--;
            else if(ss[i+j] == v && ss[i-j] == u) tmp--;
        }
        ans += tmp;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3872
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

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

const int N = 1e6 + 20 , mod = 1e9 + 7 ;
int n , d , h , dp[N] , m ;

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

	cin >> n >> h >> d ;

	for (int i = 1 , j = 1 ; i <= n ; i ++) {
		j = 1ll * j * i % mod ;
		m = (m + j) % mod ;

		if (i == n) dp[0] = j , dp[1] = -j ;
	}

	for (int i = 0 ; i <= h ; i ++) {
		if (!i) {
			int val = dp[i] ;

			dp[i + 1] = (dp[i + 1] + val) % mod ;

			if (i + d < h) dp[i + d + 1] = (dp[i + d + 1] - mod - val) % mod ;
		}
		else {
			dp[i] = (dp[i] + dp[i - 1]) % mod ;

			int val = 1ll * dp[i] * m % mod ;

			dp[i + 1] = (dp[i + 1] + val) % mod ;
		
			if (i + d < h) dp[i + d + 1] = (dp[i + d + 1] + mod - val) % mod ;
		}
	}		

	cout << dp[h] << '\n' ;
}


Measured memory_bytes: 4224
/*
* welcome to my code!
* ------------------------------------------
* author : lynmisakura(twitter : @andoreiji11)
*/

#include<bits/stdc++.h>
using namespace std;

using ll = long long;

// macro templates

#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < n;i++)
#define dv(TYPE,VAL) TYPE VAL;cin >> VAL;
#define vi(TYPE,NAME,SIZE,INIT) vector<TYPE> NAME(SIZE,(INIT))
#define vin(TYPE,NAME,SIZE) vector<TYPE> NAME(SIZE);rep(i,SIZE)cin >> NAME[i]
#define vout(ARRAY) for(auto i : ARRAY)cout << i << ' ';cout << '\n'
#define vvi(TYPE,NAME,LOW,COL,INIT) vector<vector<TYPE>> NAME(LOW,vector<TYPE>(COL,INIT))
#define vpi(T1,T2,NAME,SIZE,I1,I2) vector<pair<T1,T2>> NAME(SIZE,make_pair(I1,I2))
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define dup(x,y) (x + y - 1)/y
#define sz(v) (int64_t)v.size()
#define CUM(arr,cum) vector<ll> cum(sz(a)+1,0); rep(i,sz(a)) cum[i+1] = cum[i] + 1
#define PY(COND) if(COND){cout << "YES" << '\n';return;}
#define PN(COND) if(COND){cout << "NO" << '\n';return;}
#define PYN(COND) cout << ((COND) ? "YES" : "NO") << '\n';
#define Py(COND) if(COND){cout << "Yes" << '\n';return;}
#define Pn(COND) if(COND){cout << "No" << '\n';return;}
#define Pyn(COND) cout << ((COND) ? "Yes" : "No") << '\n';return

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pi acos(-1)
#define fi first
#define se second
#define pq priority_queue

#define MULTITEST; int t;cin >> t;rep(_,t)main2();
#define IOB; cin.tie(0);ios::sync_with_stdio(false);

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

// templates end

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

    int n;
    cin >> n;
    vector<int> v(n),w(n);
    rep(i,n)cin >>v[i] >> w[i];

    const int limit = min(512,n);
    const int MAX = 1e5 + 1;

    vector<vector<int>> dp(limit,vector<int>(MAX));

    for(int i = 0;i < MAX;i++){
        dp[0][i] = (i >= w[0] ? v[0] : 0);
    }
    for(int t = 1;t < limit;t++){
        int p = (t - 1) / 2;
        for(int i = 0;i < MAX;i++){
           chmax(dp[t][i] , dp[p][i]);
           if(i >= w[t]) chmax(dp[t][i],dp[p][i - w[t]] + v[t]);
        }
    }

    int q;cin >> q;
    rep(_,q){
        int ver,L;cin >> ver >> L;
        ver--;
        vector<int> ids;
        while(ver >= limit){
            ids.push_back(ver);
            ver = (ver - 1) / 2;
        }

        int ans = 0;
        int sz = (int)ids.size();

        for(int t = 0;t < (1 << sz);t++){
            int vs = 0,ws = 0;
            for(int i = 0;i < sz;i++){
                if(t & (1 << i)){
                    vs += v[ids[i]];
                    ws += w[ids[i]];
                }
            }
            if(ws <= L){
                chmax(ans,vs + dp[ver][L - ws]);
            }
        }
        cout << ans << '\n';
    }
}



Measured memory_bytes: 206488
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		
		boolean val = true;
		
		if(s.length()%2!=0)
			val = false;
		else {
			for(int i=0;i<n/2;i++) {
				if(s.charAt(i)!=s.charAt(i+n/2)) {
					val = false;
					break;
				}
			}
		}
		
		System.out.println(val ? "Yes" : "No");
	}
}


Measured memory_bytes: 21716
# coding: utf-8
from math import sqrt


def solve(*args: str) -> str:
    k = int(args[0])

    l = 9*(k//7 if 0 == k % 7 else k)
    if 0 == l % 2 or 0 == l % 5:
        return '-1'

    r = phi = l
    for i in range(2, int(sqrt(l)+1)):
        if 0 == r % i:
            phi = phi*(i-1)//i
            while 0 == r % i:
                r //= i
    if 1 < r:
        phi = phi*(r-1)//r

    D = set()
    for d in range(1, int(sqrt(phi)+1)):
        if 0 == phi % d:
            D.add(d)
            D.add(phi//d)

    ret = -1
    for m in sorted(D):
        if 1 == pow(10, m, l):
            ret = m
            break

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

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

  std::vector<int> L(2 * N, 0);;
  for (int i = 0; i < 2 * N; ++i) {
    cin>>L[i];
  }
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += L[2 * i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    vector<int> s(1e7+1);
    s[0] = 0;
    for(int i = 1; i <= 1e7; i++){
        s[i] = i + s[i-1];
    }

    int l = 0;
    int r = 1e7;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(s[mid] >= n){
            r = mid;
        }else{
            l = mid;
        }
    }
    int except = s[r] - n;

    for(int i = 1; i <= r; i++){
        if(i == except){
            continue;
        }
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
long long a,b,m,n,d,x,ans;
int main()
{
	cin>>n>>a>>b;
	m=a+b;
	x=n/m;
	d=n%m;
	if(d>a) d=a;
	ans=x*a+d;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10**9
MOD = 10**9+7

N, M = map(int, input().split())
dp = [[INF] * (1<<N) for i in range(M+1)]
dp[0][0] = 0
for i in range(M):
    a, b = map(int, input().split())
    c = [int(x)-1 for x in input().split()]
    mask = 0
    for x in c:
        mask |= 1<<x
    for s in range(1<<N):
        dp[i+1][s] = min(dp[i+1][s], dp[i][s])
        dp[i+1][s|mask] = min(dp[i+1][s|mask], dp[i+1][s]+a)
ans = dp[M][(1<<N)-1] if dp[M][(1<<N)-1] != INF else -1
print(ans)



Measured memory_bytes: 76124
n,T = map(int,input().split())
c = [0]*n
t = [0]*n
for i in range(n):
    c[i],t[i] = map(int,input().split())

for i in range(n):
    if t[i] > T:
        c[i] = 1001

if min(c) <= 1000:
    print(min(c))
else:
    print('TLE')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
int cnt = 0;
ll s[500100];

void merge(int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<ll> L(n1 + 1), R(n2 + 1);
	for (int i = 0; i < n1; i++)L[i] = s[left + i];
	for (int i = 0; i < n2; i++)R[i] = s[mid + i];
	L[n1] = INF;
	R[n2] = INF;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			s[k] = L[i];
			i = i + 1;
		}
		else {
			s[k] = R[j];
			j = j + 1;
		}
	}
}

//[left,right)????????????
void mergeSort(int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(left, mid);
		mergeSort(mid, right);
		merge(left, mid, right);
	}
}

int main() {
	cin >> n;
	rep(i, n)cin >> s[i];
	mergeSort(0, n);
	rep(i, n) {
		if (i != n - 1)cout << s[i] << " ";
		else cout << s[i] << endl;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 10544
s = gets.chomp
aa, bb = s.scan(/../).map(&:to_i)

if (aa > 12 || aa.zero?) && (bb > 12 || bb.zero?)
  puts "NA"
elsif aa > 12 || aa.zero?
  puts "YYMM"
elsif bb > 12 || bb.zero?
  puts "MMYY"
else
  puts "AMBIGUOUS"
end

Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int A[3];

int main()
{
	in >> A[0] >> A[1] >> A[2];
	
	std::sort(A, A + 3);
	if (A[0] == 5 && A[1] == 5 && A[2] == 7)
	{
		out << "YES" << std::endl;
	}
	else
	{
		out << "NO" << std::endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> ans(n);
  rep(i,n){
    ans[a[i]-1] = i+1;
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
}

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

int main()
{

        int K, N;
        cin >> K >> N;
        int A[N];
        for (int i = 0; i < N; ++i) {
                cin >> A[i];
        }
        int t[N];
        int total = 0;
        int max = -1;
        for (int i = 0; i < N; ++i) {
                if (i == N-1) {
                        t[i] = K + A[0] - A[i];
                }
                else {
                        t[i] = A[i+1] - A[i];
                }
                total += t[i];
                if (max == -1) max = t[i];
                else if (max < t[i]) max = t[i];
        }
        total -= max;
        cout << total << endl;


}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf\n",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int,int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;


signed main ( ) {
    IOS
    ll n , r ;
    cin >> n >> r;
    ll res = 0;
    while ( n > 0){
        n/=r;
        res++;
    }
    cout << res ;
    return 0;
}



















Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1&&b!=1)
	cout<<"Alice"<<endl;
	else if(b==1&&a!=1)
	cout<<"Bob"<<endl;
	else if(a==b)
	cout<<"Draw"<<endl;
	else if(a<b)
	cout<<"Bob"<<endl;
	else cout<<"Alice"<<endl; 
	return 0;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int va,vb,vc;
	cin>>va>>vb>>vc;
	int a,b,c,cnt=0;
	a=va,b=vb,c=vc;
	while(1) {
		if(va&1||vb&1||vc&1) {
			cout<<cnt;
			return;
		}
		int ta=vb/2+vc/2,tb=va/2+vc/2,tc=va/2+vb/2;
		cnt++;
		va=ta,vb=tb,vc=tc;
		if(va==a&&vb==b&&vc==c) {
			cout<<-1;
			return;
		}
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3560
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  def prefix(p:String) = {
    val m = p.length
    val a = new Array[Int](m)
    var k=0

    a(0) = 0
    for(q<-1 until m) {
      while(k>0 && p(k)!=p(q)) k = a(k-1)
      if(p(k) == p(q)) k = k+1
      a(q) = k
    }

    a
  }

  def main(args:Array[String]) = {
    val t = readLine.trim
    val p = readLine.trim
    val b = new ArrayBuffer[Int]
    var q = 0

    val f = prefix(p)

    for(i<-0 until t.length) {
      while(q>0 && p(q)!=t(i)) q = f(q-1)
      if(p(q)==t(i)) q = q+1
      if(q==p.length) {
        b += i-p.length+1
        q = f(q-1)
      }
    }

    if(b.length>0) println(b.mkString("\n"))
  }
}

Measured memory_bytes: 181276
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double


int main(void){
  ull n;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
    return 0;
  }
  if(n<=6){
    cout<<0<<endl;
    return 0;
  }
  while(n%5!=0){
    n-=2;
  }
  ull ans=0;
    ull now5=5;
    while(now5<=n){
      ans+=(n/now5)/2;
      if(now5>200000000000000000){
        break;
      }
      now5*=5;
    }
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
int main()
{
    ll s,c,cc;
    scanf("%lld%lld",&s,&c);
    cc=c/2;
    if(s>cc) printf("%lld",cc);
    else if(s==cc)
    {
        printf("%lld\n",cc);
    }
    else
    {
//        for(;s<cc;s++,cc--);
//            printf("%lld\n",cc);
        printf("%lld\n",(cc+s)/2);
    }
    return 0;
}


Measured memory_bytes: 128
N = int(input())
a = input().rstrip().split()
P = [0] * N
for i in range(N):
  P[i] = int(a[i])
minP = P[0]
ans = 1
for i in range(N - 1):
  if minP >= P[i + 1]:
    ans += 1
    minP = P[i + 1]
print(ans)

Measured memory_bytes: 24616
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#define NOT_FOUND -1 
class Array 
{
    protected:
        int *Sarray, *Tarray, slen, tlen;
    
    public:
        Array() : Sarray(NULL), Tarray(NULL), slen(0), tlen(0)
        {

        }

        void SetArray() {
            scanf("%d", &slen);
            Sarray = (int *)malloc(slen * sizeof(int));
            for(int i=0; i<slen; ++i)
                scanf("%d", &Sarray[i]);

            scanf("%d", &tlen);
            Tarray = (int *)malloc(tlen * sizeof(int));
            for(int i=0; i<tlen; ++i)
                scanf("%d", &Tarray[i]);
        }

        void PrintArray() {
            for(int i=0; i<slen; ++i) {
                if(!i) printf("Sarray ");
                if(i) printf(" ");
                printf("%d", Sarray[i]);
            }
            printf("\n");

            //printf("tlen=%d\n",tlen);
            for(int i=0; i<tlen; ++i) {
                if(!i) printf("Tarray ");
                if(i) printf(" ");
                printf("%d", Tarray[i]);
            }
            printf("\n");
        }

        int getslen() {
            return slen;
        }

        int gettlen() {
            return tlen;
        }
        
        int* getSptr() {
            return (&Sarray[0]);
        }

        int* getTptr() {
            return (Tarray);
        }
};

class BinarySearch : public Array
{
    private:
        int left, right, mid, cnt;
        Array _array;

    public:
        BinarySearch() : left(0), right(0), mid(0), cnt(0)
        {
            
        }

        void SetPoint() {
            left = 0;
            right = slen;
        }

        
        int search(int key) {
            SetPoint();
            while(left < right) {
                mid = (left + right) / 2;
                if(Sarray[mid] == key) {
                    return mid;
                }
                else if(key < Sarray[mid]) {
                    right = mid;
                }
                else 
                    left = mid + 1;
            }
            return NOT_FOUND;
        }
        void searching() {
            SetArray();
            for(int i=0; i<tlen; ++i) {
                if(search(Tarray[i]) != -1) 
                    ++cnt;
            }
            printf("%d\n",cnt);
        };
};

int main() {
    BinarySearch _binary;
    _binary.searching();
    return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	int n,m=100000;
	cin>>n;
	for(int i=0;i<n;i++){
			m +=m/20;
		if(m%1000!=0){
			m=m-m%1000+1000;
		}
	}
	cout<<m<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <vector>
#define Inf 10000*100000+100
using namespace std;

vector<pair<int,int> >A[500010];
int S[500010],T[500010],D[500010];
bool flag[100010];
int C[100010];
int main()
{
    priority_queue<pair<int,int> > Q;
    int V,E,R,i;
    //scanf("%d %d %d",&V,&E,&R);
    cin >> V >> E >> R;
    for(i=0;i<E;i++)
    {
        //scanf("%d %d %d",&S[i],&T[i],&D[i]);
        cin >> S[i] >> T[i] >> D[i];
        A[S[i]].push_back(make_pair(T[i],D[i]));
    }
    for(i=0;i<V;i++)
    {
        C[i]=Inf;
        flag[i]=true;
    }
    C[R]=0;
    Q.push(make_pair(0,R));
    while(!Q.empty())
    {
        pair<int,int> m = Q.top();
        Q.pop();
        flag[m.second]=false;
        int length=A[m.second].size();
        for(i=0;i<length;i++)
        {
            if(flag[A[m.second][i].first]==true && C[A[m.second][i].first]!=0 && C[A[m.second][i].first]>A[m.second][i].second+C[m.second])
            {
                C[A[m.second][i].first] = A[m.second][i].second+C[m.second];
                Q.push(make_pair(C[A[m.second][i].first]*(-1),A[m.second][i].first));
            }
        }
    }
    for(i=0;i<V;i++)
    {
        if(C[i]!=Inf)
            //printf("%d\n",C[i]);
            cout << C[i] << endl;
        else    //printf("INF\n");
                cout << "INF" << endl;
    }
    return 0;
}


Measured memory_bytes: 28220