akhauriyash/Code-Regression huggingface dataset:
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define NUM 16

bool from_left_block[NUM][NUM];
bool from_up_block[NUM][NUM];

long long dp[NUM][NUM];

int main(void) {
    int N;
    cin >> N;
    int gx, gy;
    for (int i = 0; i < N; i++) {
        cin >> gx >> gy;
        for (int k = 0; k < NUM; k++) {
            for (int j = 0; j < NUM; j++) {
                from_left_block[k][j] = false;
                from_up_block[k][j] = false;
                dp[k][j] = 0;
            }
        }
        int p;
        cin >> p;
        for (int i = 0; i < p; i++) {
            int x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;
            if (x1 == x2) {
                from_up_block[max(y1, y2)][x1] = true;
            }
            if (y1 == y2) {
                from_left_block[y1][max(x1, x2)] = true;
            }
        }
        dp[0][0] = 1;
        for (int y = 0; y <= gy; y++) {
            for (int x = 0; x <= gx; x++) {
                if (x > 0) {
                    if (!from_left_block[y][x]) dp[y][x] += dp[y][x-1];
                }
                if (y > 0) {
                    if (!from_up_block[y][x]) dp[y][x] += dp[y-1][x];
                }
            }
        }
        if (dp[gy][gx] == 0) cout << "Miserable Hokusai!" << endl;
        else cout << dp[gy][gx] << endl;
    }
    return 0;
}

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

int main()
{
    char S[255], T[255];
    scanf("%s%s", S, T);
    int A,B;
    scanf("%d%d", &A, &B);
    char U[20];
    scanf("%s", U);

    int result1 = strcmp(S,U);
    int result2 = strcmp(T,U);

    if (result1 == 0)
    {
        A = A - 1;
    }
    if (result2 == 0)
    {
        B = B - 1;
    }
    printf("%d%s%d", A," ", B);
    return 0;
}

Measured memory_bytes: 1704
/*
By Tianyi Chen. All rights reserved.
Date: 2017-03-12
*/
#include<bits/stdc++.h>
using namespace std;
int n,c,k,t[100001],ans,cnt,mustgo;
int main() {
 scanf("%d%d%d",&n,&c,&k);for(int i=0;i<n;++i)scanf("%d",t+i);
 sort(t,t+n);
 for(int i=0;i<n;++i)if(mustgo<t[i]||cnt==c) {
  cnt=1;mustgo=t[i]+k;++ans;
 } else ++cnt;
 printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    
    ll a[n], delta[n], s = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s += a[i];
    }
    ll rm_sum = n * (n+1) / 2;
    
    if (s % rm_sum != 0) {
        cout << "NO" << endl;
    } else {
        ll k = s / rm_sum;
        for (int i = 0; i < n; ++i) {
            delta[i] = a[(i+1)%n] - a[i];
            if (delta[i] - k > 0 || (k - delta[i]) % n != 0) {
                cout << "NO" << endl;
                return 0;
            }
            
        }
        cout << "YES" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <vector>
#include <algorithm>



using namespace std;
typedef long long ll;

#define In_(x) scanf("%lld",&x)

ll n, k;
vector<ll>xtag, ytag, dtag;
ll x1[50], y1__[50], d1[50];
ll x2[50], y2[50], d2[50];
ll area[123][123][123];

ll compress(ll t1[],ll t2[],vector<ll>&tmp)
{
	for (int i = 0; i < n; ++i)
	{
		tmp.push_back(t1[i]);
		tmp.push_back(t2[i]);
	}
	sort(tmp.begin(), tmp.end());
	tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
	for (int i = 0; i < n; ++i)
	{
		t1[i] = find(tmp.begin(), tmp.end(), t1[i]) - tmp.begin();
		t2[i] = find(tmp.begin(), tmp.end(), t2[i]) - tmp.begin();
	}
	return tmp.size();
}

int main()
{
	In_(n);
	In_(k);
	for (int i = 0; i < n; ++i)
	{
		In_(x1[i]);
		In_(y1__[i]);
		In_(d1[i]);
		In_(x2[i]);
		In_(y2[i]);
		In_(d2[i]);
	}
	ll xlen = compress(x1, x2, xtag);
	ll ylen = compress(y1__, y2, ytag);
	ll dlen = compress(d1, d2, dtag);
	for (int i = 0; i < n; ++i)
	{
		area[x1[i]][y1__[i]][d1[i]] += 1;
		area[x1[i]][y1__[i]][d2[i]] -= 1;
		area[x1[i]][y2[i]][d1[i]] -= 1;
		area[x1[i]][y2[i]][d2[i]] += 1;
		area[x2[i]][y1__[i]][d1[i]] -= 1;
		area[x2[i]][y1__[i]][d2[i]] += 1;
		area[x2[i]][y2[i]][d1[i]] += 1;
		area[x2[i]][y2[i]][d2[i]] -= 1;
	}
	for (int x = 0; x < xlen; ++x)
	{
		for (int y = 0; y < ylen; ++y)
		{
			for (int d = 0; d < dlen; ++d)
			{
				area[x][y][d + 1] += area[x][y][d];
			}
		}
	}
	for (int x = 0; x < xlen; ++x)
	{
		for (int y = 0; y < ylen; ++y)
		{
			for (int d = 0; d < dlen; ++d)
			{
				area[x][y + 1][d] += area[x][y][d];
			}
		}
	}
	for (int x = 0; x < xlen; ++x)
	{
		for (int y = 0; y < ylen; ++y)
		{
			for (int d = 0; d < dlen; ++d)
			{
				area[x + 1][y][d] += area[x][y][d];
			}
		}
	}
	ll answer = 0;
	for (int x = 0; x < xlen; ++x)
	{
		for (int y = 0; y < ylen; ++y)
		{
			for (int d = 0; d < dlen; ++d)
			{
				if (area[x][y][d] >= k)
				{
					answer += (xtag[x + 1] - xtag[x]) * (ytag[y + 1] - ytag[y]) * (dtag[d + 1] - dtag[d]);
				}
			}
		}
	}
	printf("%lld\n",answer);
	return 0;
}

Measured memory_bytes: 12996
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC103C
{
    class Program
    {
        struct Count
        {
            public int Number;
            public int Counts;
        }
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int[] vn = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //aの最頻値，bの最頻値を求める
            Count[] a = new Count[100001];
            Count[] b = new Count[100001];
            for(int i = 0; i < 100000; i++)
            {
                a[i].Number = i;
                b[i].Number = i;
            }
            for(int i = 0; i < n; i++)
            {
                if (i % 2 == 0) a[vn[i]].Counts++;
                else b[vn[i]].Counts++;
            }

            //max(aの最頻値+bの最頻値,aの最頻値＋bの第二最頻値，bの最頻値+aの第二最頻値)採用
            a = a.OrderByDescending(x => x.Counts).ToArray();
            b = b.OrderByDescending(x => x.Counts).ToArray();
            int amax = a[0].Counts;
            int amax2 = a[1].Counts;
            int bmax = b[0].Counts;
            int bmax2 = b[1].Counts;

            int minus = amax + bmax;
            if (a[0].Number == b[0].Number) minus = Math.Max(amax + bmax2, amax2 + bmax);

            int ans = n - minus;
            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 31456
def g_c_d(x, y):
    if x == 0:
        return y
    elif y == 0:
        return x
    else:
        return g_c_d(y, x % y)


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
d = 0
for i in range(len(c)):
    d = g_c_d(d, abs((c[i] - c[i-1])))
print(d)


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

int main() {
    int N, a, b, c, d;
    cin >> N;
    
    a = N % 10;
    N = N / 10;
    
    b = N % 10;
    N = N / 10;
    
    c = N % 10;
    N = N / 10;
    
    d = N % 10;
    
    if ((a == b && a == c) || (b == c && b == d)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(string, a, b);


    if (a == b) {
        print("EQUAL");
        return 0;
    }

    if (a.length() == b.length()) {
        print(a > b ? "GREATER" : "LESS");
    } else {
        print(a.length() > b.length() ? "GREATER" : "LESS");
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<queue>
     
    using namespace std;
     
    long long int gcd(long long int a,long long int b)
    {
    	if(b==0)return a;
    	else return gcd(b,a%b);
    }
     
    long long int lcm(long long int a,long long int b)
    {
    	long long int g=gcd(a,b);
    	return a/g*b;
    }
     
    int main()
    {
    	int n;
    	cin>>n;
     
    	long long int ans=1;
    	long long int t;
    	for(int i=0;i<n;i++){
    		cin>>t;
    		ans=lcm(ans,t);
    	}
    	cout<<ans<<endl;
     
    	return 0;
    }

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


void solve(long long N, map<tuple<string, long long>, long long> tab){
  for(auto &a : tab) {
    cout << a.second << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    long long idx, p;
    string s;
    map<tuple<string, long long>, long long> tab;

    cin >> N;
  for(int i = 0 ; i < N ; i++){
    std::cin >> s >> p;
    tab[make_tuple(s, (100-p))] = (i+1);
  }
    solve(N, std::move(tab));
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
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;
}

#define pb(a) push_back(a)
#define mp(a , b) make_pair((a) , (b))
#define fore(i,a,b) for(int  i = (int)(a) ; i < (int)(b) ; ++i)
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main(){
	FIN;

	int n,a,b;
	cin>>n>>a>>b;
	if(n*a < b)	
		cout<<n*a;
	else
		cout<<b;

	return 0;
}

Measured memory_bytes: 256
s = int(input())
ans = 1
list = [0]
list.append(s)
n = 2
while n < 1000001:
  if list[n-1] % 2 ==0:
    list.append(list[n-1]//2)
  else:
    list.append(3 * list[n-1] + 1)
  if len(set(list)) == len(list):
    n += 1
  else:
    print(n)
    exit()

Measured memory_bytes: 3060
import math

# X, K, D = 6, 2, 4

# X, K, D = 7, 4, 3

# X, K, D = 10, 1, 2


# X, K, D = 1000000000000000, 1000000000000000, 1000000000000000

# X, K, D = 4, 4, 4


X, K, D = map(int,input().split())

def calculate(x, k, d):
    x = abs(x)
    d = abs(d)
    n = x / d
    kk = math.floor(n)

    if k <= kk:
        return x - k * d

    k = k - kk

    if k % 2 == 0:
        return x - kk * d
    else:
        current = x - kk * d
        return abs(current - d)


result = calculate(X, K, D)

print(result)


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;
  return 0;
}


Measured memory_bytes: 256
A,B,K = map(int,input().split())
flg = True
for k in range(K):
  if flg:
    if A%2 != 0:
      A-=1
    A//=2
    B+=A
    flg = False
  else:
    if B%2 != 0:
      B-=1
    B//=2
    A+=B
    flg = True

print(A,B)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,ac=0,wa=0,tle=0,re=0;
	string s;
	cin>>n;
	while(n--) {
		cin>>s;
		if(s=="AC")
			ac++;
		else if(s=="TLE")
			tle++;
		else if(s=="WA") 
			wa++;
		else
			re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	 		
	return 0;
}

Measured memory_bytes: 3620
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    for line in readlines():
        U = [0]*11
        a, b, c = map(int, line.split())
        U[a] = U[b] = U[c] = 1
        res = 0
        for x in range(1, 11):
            if U[x]:
                continue
            if a + b + x <= 20:
                res += 1
        if res*2 > 7:
            write("YES\n")
        else:
            write("NO\n")
solve()


Measured memory_bytes: 5600
// pdf これ賢い
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end()); // greater書いたらerror吐かれた
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char str[1200];
	char *p;
	int l;
	int i;
	gets(str);
	for(p = str; *p!='\0'; p++){
		if('a' <= *p && *p <= 'z')*p+='A'-'a';
		else if('A' <= *p && *p <= 'Z')*p+='a'-'A';
	}
	printf("%s\n", str);

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t n; cin >> n;
	cout << n * (n - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        h: i64, n: usize,
        a: [i64; n],
    }
    let s: i64 = a.iter().sum();
    puts!("{}\n", if s >= h { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

int main()
{
	ll n,m;
	cin >> n >> m;
	if(n>m/2){
		cout << m/2 << "\n";
	}else{
		ll k = m - 2*n;
		cout << n + k/4 << "\n";
	}
	return 0;
}

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

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

  bool isGood = false;
  int num[4];
  for (int i = 0; i < 4; i++) {
    num[3 - i] = N % 10;
    N /= 10;
  }

  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        int result = num[0];
        result = (i == 0) ? result + num[1] : result - num[1];
        result = (j == 0) ? result + num[2] : result - num[2];
        result = (k == 0) ? result + num[3] : result - num[3];
        if (result == 7) {
          char pm[3];
          pm[0] = (i == 0) ? '+' : '-';
          pm[1] = (j == 0) ? '+' : '-';
          pm[2] = (k == 0) ? '+' : '-';

          cout << num[0] << pm[0] << num[1] << pm[1] << num[2] << pm[2]
               << num[3] << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = map(int, input().split())
num4 = 0
num1 = 0
for i in a:
    if i % 4 == 0:
        num4 += 1
        continue
    if i % 2 == 1:
        num1 += 1
if num4 >= num1:
    print("Yes")
elif num4 + 1 == num1 and (num4 + num1) % 2 == 1 and n - (num4 + num1) == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 11096
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
    if (x >= 1200) cout << "ARC";
    else cout << "ABC";
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static long mini(int a[],int n,int k)
    {
       int dp[]=new int[n];
       dp[0]=0;
       dp[1]=Math.abs(a[1]-a[0]);
       for(int i=2;i<k;i++)
       {
           int min=Integer.MAX_VALUE;
           for(int j=0;j<i;j++)
           {
               min=Math.min(min,Math.abs(a[j]-a[i])+dp[j]);
           }
           dp[i]=min;
       }
       for(int i=k;i<n;i++)
       {
           int min=Integer.MAX_VALUE;
           for(int j=i-k;j<i;j++)
           {
               min=Math.min(min,Math.abs(a[j]-a[i])+dp[j]);
           }
           dp[i]=min;
       }
       return dp[n-1];
    }
    public static void main(String args[]) {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int k=s.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
        {
            a[i]=s.nextInt();
        }
        if(n<=k)
        {
            System.out.println(Math.abs(a[n-1]-a[0]));
        }
        else{
        System.out.println(mini(a,n,k));
        }
    }
}

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


void solve(long long K, long long S){
int ans=0;
for(int i=0; i<=K; i++){
for(int j=0; j<=K; j++){
if((0<=S-i-j)&&(S-i-j<=K))ans++;
}   
}
cout<< ans <<endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(K, S);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();    
    int c = sc.nextInt();    
    int d = sc.nextInt();

    if(a+b==c+d){
    System.out.println("Balanced");
    }else if(a+b>c+d){
    System.out.println("Left");
    }else{
    System.out.println("Right");  
    }
}
}

Measured memory_bytes: 35820
#include<iostream>
using namespace std;
int main(){
  int n,sum = 100000;
  cin >>n;
  while(n--){
    sum = (int)(sum*1.05);
    if(sum%1000){sum = (sum/1000)*1000+1000;}
  }
  cout <<sum<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long long int a, b, c, d;

	cin >> a >> b >> c >> d;

	/*
	int max1 = max(a, b);
	int min1 = min(a, b);

	int max2 = max(c, d);
	int min2 = min(c, d);*/

	cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;

}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007LL
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	if(exponent<0) exponent+=MOD-1;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int val[1000];
bool taken[1000],flag[1000];
ll at[27];
int main()
{
	//csl;
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	string a,b;
	for(int i=0;i<26;i++)
		at[i]=i;
	cin>>a>>b;
	string aa=a;
	for(int i=0;i<a.length();i++)
	{
		char temp=char(at[a[i]-'a']+'a');
		if(temp!=b[i])
		{
			for(int j=0;j<26;j++)
				if(at[j]==temp-'a')
				{
					// cout<<char(j+'a')<<" "<<b[i]<<endl;
					at[j]=b[i]-'a';
				}
				else if(at[j]==b[i]-'a')
					at[j]=temp-'a';
			/*for(int j=0;j<26;j++)
				if(at[j]==b[i]-'a')
				{
					cout<<char(j+'a')<<" "<<temp<<endl;
					at[j]=temp-'a';
				}*/
			a[i]=b[i];
		}
	}
	for(int i=0;i<a.length();i++)
	{
		aa[i]=char(at[aa[i]-'a']+'a');
	}
	// cout<<aa<<" "<<b<<endl;
	if(aa==b)	
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 904
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  cin >> s;
  rep(i, s.size()) cout << 'x';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,s) for(int i=s;i>=0;--i)

using namespace std;
int main() {
	int n, m, h, ans = 0, A[101010], B[101010];
	cin >> n >> m;
	rep(i, n) cin >> A[i];
	h = A[n - 1];
	FOR(i, n - 2) {
		if (A[i + 1] - A[i] > h - A[i]) {
			B[i] = A[i + 1] - A[i];
			h = A[i + 1];
		}
		else
			B[i] = h - A[i];
	}
	sort(B, B + n - 1, greater<int>());
	h = B[0];
	rep(i, n) if (B[i] == h) ans++;

	cout << ans << 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 REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;

int N, K;
int A[101010];
vector<int> edges[101010];
int indeg[101010];
bool ok[101010];


int dfs(int n) {
    if (edges[n].size() == 0) {
        ok[n] = true;
        return 1;
    }

    if (indeg[n] == 0)
        ok[n] = true;

    int ret = 1 << 29;
    for (auto m: edges[n])
        ret = min(ret, dfs(m));

    if (ret < K)
        ok[n] = true;

    return ret + 1;
}


int main() {
    memset(ok, 0, sizeof(ok));
    memset(indeg, 0, sizeof(indeg));

    cin >> N >> K;
    REP(i, N) {
        int a; cin >> a;
        A[i] = a - 1;
    }

    REP(i, N) if (A[i] >= 0) {
        edges[A[i]].push_back(i);
        indeg[i] += 1;
    }

    REP(i, N) if (indeg[i] == 0) dfs(i);

    int ans = 0;
    REP(i, N) if (ok[i]) ans += 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14156
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
viran = 0
for i in range(n):
    if a[i] + a[i + 1] - b[i] >= 0:
        viran += b[i]
        if a[i] > b[i]:
            a[i] -= b[i]
        else:
            b[i] -= a[i]
            a[i] = 0
            a[i + 1] -= b[i]
        b[i] = 0
    else:
        viran += a[i] + a[i + 1]
        a[i] = 0
        a[i + 1] = 0
        b[i] -= a[i] + a[i + 1]
print(viran)

Measured memory_bytes: 23984
#include "bits/stdc++.h"
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
using namespace std;

int main(){
    int n,x,y,b,p;
    double memo = 0,memo2 = 0;
    
    cin >> n;
    
    rep(i,0,n){
        cin >> x >> y >> b >> p;
        memo = (double)(x*b+y*p);
        memo2 = (double)(max(b,5)*x+max(p,2)*y)*(0.8);
        cout << min(memo,memo2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3300
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
const int maxn=100000;

int n,m,fat[maxn+5],ans;

#define EOLN(x) ((x)==10 || (x)==13 || (x)==EOF)
inline char readc(){
	static char buf[100000],*l=buf,*r=buf;
	return l==r && (r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<typename T> int readi(T &x){
	T tot=0;char ch=readc(),lst='+';
	while (!isdigit(ch)) {if (ch==EOF) return EOF;lst=ch;ch=readc();}
	while (isdigit(ch)) tot=(tot<<1)+(tot<<3)+(ch^48),ch=readc();
	lst=='-'?x=-tot:x=tot;return EOLN(ch);
}
int getfa(int x) {return x==fat[x]?x:fat[x]=getfa(fat[x]);}
int main(){
	scanf("%d%d",&n,&m);for (int i=1;i<=n;i++) fat[i]=i;
	for (int i=1,x,y;i<=m;i++) scanf("%d%d",&x,&y),fat[getfa(x)]=getfa(y);
	for (int i=1;i<=n;i++) if (getfa(i)==i) ans++;
	printf("%d\n",ans-1);return 0;
}

Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define f(i,x,n) for(ll int i=x;i<n;i++) 
#define re(j,x,n) for(ll int j=x;j>=n;j--)
#define f1(k,x,n) for(ll int k=x;k<=n;k++)
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define MAX 1000001
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int a,b;
    cin>>a>>b;
    if(a>=1&&a<=9&&b>=1&&b<=9)
     cout<<a*b;
    else
     cout<<-1;   
}

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

using namespace std;

int main()
{
    int a,b;
    string s;
    cin >> a >> b;
    if(a<=b){
        string A = to_string(a);
        while(b--)
            s+=A;}
    else{
        string B = to_string(b);
        while(a--)
            s+=B;}
    cout << s;

    return 0;
}

Measured memory_bytes: 256
<?php
  $N = (int)trim(fgets(STDIN));
  $S = trim(fgets(STDIN));
  $splitStr = str_split($S);
  $res = '';

  foreach ($splitStr as $str) {
    $ch = $N;
    $asci = ord($str);
    if ($asci + $N > 90) {
      $ch = $asci + $N - 91;
      $asci = 65;

    }
    $res = $res . chr($asci + $ch);
  }
  echo $res . PHP_EOL;

Measured memory_bytes: 5496
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll k;
  cin >> k;
  string s;
  cin >> s;

  string ans = s.substr(0, k) + "...";
  if (s.size() <= k) {
    ans = s;
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void){
    
    string s;
    cin>>s;
    bool a[26]={0};
    for(int i=0;i<s.size();i++){
        a[s[i]-'a']=1;
    }
    for(int i=0;i<26;i++){
        if(!a[i]){
            cout<<(char)('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}


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

typedef pair<int,int> pii;
const int N=2005;
const int INF=123456789;
int n,tmx=-INF,ans;
int a[N*3];
vector<pair<pii,int> > vtr;
int dp[N][N],mx[N];

inline void chmax(int &x,int y){x=max(x,y);}

inline void update(int x,int y,int t){
//	printf("upd %d %d %d\n",x,y,t);
	chmax(dp[x][y],t);
	chmax(dp[y][x],t);
	chmax(mx[x],t);
	chmax(mx[y],t);
	chmax(tmx,t);
}

void tr1(int x){
	for(int i=1;i<=n;i++) vtr.push_back(make_pair(make_pair(i,x),mx[i]));
}

void tr2(int x,int y){
	vtr.push_back(make_pair(make_pair(x,y),tmx));
}

void tr3(int x,int y,int z){
	vtr.push_back(make_pair(make_pair(y,z),dp[x][x]+1));
}

int main(){
	scanf("%d",&n);
	tmx=-INF;
	for(int i=1;i<=n;i++) mx[i]=-INF;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) dp[i][j]=-INF;
	for(int i=1;i<=n*3;i++) scanf("%d",a+i);
	update(a[1],a[2],0);
	for(int i=1;i<n;i++){
		vtr.clear();
		sort(a+i*3,a+i*3+3);
		int A=a[i*3],B=a[i*3+1],C=a[i*3+2];
		if(A==B&&B==C){
			ans++;
			continue;
		}
		if(A==B||B==C){
			if(B==C) swap(A,C);
			for(int j=1;j<=n;j++) vtr.push_back(make_pair(make_pair(C,j),dp[A][j]+1));
		}
		tr1(A);tr1(B);tr1(C);
		tr2(A,B);tr2(A,C);tr2(B,C);
		tr3(A,B,C);tr3(B,A,C);tr3(C,A,B);
		for(int i=0;i<vtr.size();i++) update(vtr[i].first.first,vtr[i].first.second,vtr[i].second);
	}
//	printf("%d\n",ans);
	printf("%d\n",max(tmx,dp[a[n*3]][a[n*3]]+1)+ans);
	return 0;
}

Measured memory_bytes: 19644
#include<bits/stdc++.h>
using namespace std;
#define deb(x) cout<<#x<<" "<<x<<endl;  //for debugging variables 
#define check cout<<"check"<<endl; // checking 







void solve(){


int n,k;

cin>>n>>k;


vector<int>v(n);


for(int i=0;i<n;i++) cin>>v[i];




for(int i=0;i<n-k;i++){


if(v[i]>=v[k+i]){

	cout<<"No"<<endl;
}
else{

	cout<<"Yes"<<endl;
}


}









}






int main(){




int t;
//cin>>t;

t=1;
while(t--){
solve();
}
	return 0;
} 

Measured memory_bytes: 4044
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
 
using ld = long double;
using ll = long long;
using ii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vii = vector <ii>;
using vpll = vector<pll>;

vector < vector <int> > seg;
vi a,b;
void build(int pos,int l, int r){
  if(l == r){
    seg[pos].push_back(b[l]);
    return;
  }
  int m = (l+r)/2;
  build(2*pos,l,m);
  build(2*pos+1,m+1,r);
  seg[pos].insert(seg[pos].end(),seg[2*pos].begin(),seg[2*pos].end());
  seg[pos].insert(seg[pos].end(),seg[2*pos+1].begin(),seg[2*pos+1].end());
  sort(seg[pos].begin(),seg[pos].end());
}

int query(int pos,int l,int r,int ql,int qr){
  if(qr < l || ql > r)
    return 0;

  if(l >= ql && r <= qr){
    int qtd = lower_bound(seg[pos].begin(),seg[pos].end(),ql) - seg[pos].begin();
    return qtd;
  }

  int m = (l+r)/2;
  int left = query(2*pos,l,m,ql,qr);
  int right = query(2*pos+1,m+1,r,ql,qr);
  
  return left + right;
}
int main(){
 
  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);
  
  int n,q;
  cin >> n >> q;
  a.resize(n);
  b.resize(n);
  seg.resize(4*n);

  for(int i=0;i<n;i++)
    cin >> a[i];

  vi last(n+1,-1);

  for(int i=0;i<n;i++){
    b[i] = last[a[i]];
    last[a[i]] = i;
  }

  build(1,0,n-1);

  while(q--){
    int l,r;
    cin >> l >> r;
    l--,r--;
    cout << query(1,0,n-1,l,r) << endl;
  }

  return 0;
}

Measured memory_bytes: 120292
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

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

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

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//







int main(){

        priority_queue<P> que;

        int n,m;
        cin >> n >> m;
        vector<ll> a(n);
        for(int i = 0; i < n; i++){
                cin >> a[i];
                que.push(make_pair(a[i],1));
        }

        vector<ll> b(m), c(m);
        for(int i = 0; i < m; i++){
                cin >> b[i] >> c[i];
                que.push(make_pair(c[i],b[i]));
        }

        ll sum = 0;
        for(int i = 0; i < n; i++){
                auto p = que.top();
                que.pop();

                sum += p.first;
                p.second--;

                if(p.second > 0){
                        que.push(p);
                }
        }

        cout << sum << endl;
        return 0;
}



















Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
 
  int lank = 0;
  
  if (x < 600) {
    lank = 8;
  } else if (x < 800) {
  	lank = 7;
  } else if (x < 1000) {
  	lank = 6;
  } else if (x < 1200) {
  	lank = 5;
  } else if (x < 1400) {
  	lank = 4;
  } else if (x < 1600) {
  	lank = 3;
  } else if (x < 1800) {
  	lank = 2;
  } else {
  	lank = 1;
  } 
  
  cout << lank << endl;
  return 0;
}

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

int gcd(int a, int b) {
    int r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int a, b;
    while (cin >> a >> b) {
        int GCD = gcd(a, b);
        int LCM = a / GCD * b;
        cout << GCD << " " << LCM << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b;
	cin >> a >> b;
	cout << a * a - b << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
/*
double squareRoot(long long number, int precision) 
{ 
    long long start = 0, end = number; 
    long long mid; 
    double ans; 
    while (start <= end) { 
        mid = (start + end) / 2; 
        if (mid * mid == number) { 
            ans = mid; 
            break; 
        }  
        if (mid * mid < number) { 
            start = mid + 1; 
            ans = mid; 
        } 
        else { 
            end = mid - 1; 
        } 
    } 
    double increment = 0.1; 
    for (long long i = 0; i < precision; i++) { 
        while (ans * ans <= number) { 
            ans += increment; 
        } 
        ans = ans - increment; 
        increment = increment / 10; 
    } 
    return ans; 
} 
*/
bool ispalin(string str)
{
	int i = 0, j = str.length() - 1;
	while (i < j)
	{
		if (str[i] != str[j]) return false;
		i++, j--;
	}
	return true;
}
void solve()
{
int n,r; cin>>n>>r;
int ans=(log(n)/log(r))+1;
cout<<ans;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t =1;
	//cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 512
//https://atcoder.jp/contests/agc010/tasks/agc010_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<ll> an(N);
    ll oddn=0;
    for(auto&& a:an){
        cin>>a;
        oddn += (a%2);
    }
    cout<<(oddn%2==0?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys

p = []
path = [ 0 for i in range(10**5+1)]
def main():

    sys.setrecursionlimit(1000000)

    N = int(input())

    e = [ [] for i in range(N)]
    for i in range(N-1):
        a,b = map(int,input().split())
        a-=1
        b-=1
        e[a].append(b)
        e[b].append(a)

    col = [ -1 for i in range(N)]
    col[0] = 0
    
    #def dfs(n,c,path):
    def dfs(n,c):
        global p
        #path =  path  + [n]
        #path.append(n)
        #print(path)
        if n == N - 1:
            p = path
        path[c] = n
        for v in e[n]:
            if col[v] == -1:
                col[v] = c + 1
                dfs(v,c+1)
                #dfs(v,c+1,path)
                if p:
                    return
    dfs(0,0)
    #print(p[:N+10])
    #dfs(0,0,[])

    t = col[N-1] + 1
    if t % 2 ==0:
        sn = p[t//2]
    else:
        sn = p[t//2+1]


    colfn = [ -1 for i in range(N)]
    colfn[0] = 0
    def dfs2(n,c):

        for v in e[n]:
            if v == sn:
                continue
            elif colfn[v] == -1:
                colfn[v] = c + 1
                dfs2(v,c+1)

    dfs2(0,0)

    fennec = -1
    for i in range(N):
        if colfn[i] != -1:
            fennec += 1

    snuke = N - fennec - 2
    if fennec > snuke:
        print("Fennec")
    else:
        print("Snuke")



if __name__ == '__main__':
    main()



Measured memory_bytes: 137104
import sys

n = int(sys.stdin.readline().rstrip())
*a, = map(int, sys.stdin.readline().split())
*b, = map(int, sys.stdin.readline().split())

def main():
    cnt = 0
    for i in range(n):
        if b[i] <= a[i]:
            a[i] -= b[i]
            cnt += b[i]
            b[i] = 0
        else:
            b[i] -= a[i]
            cnt += a[i]
            a[i] = 0
        
        if b[i] >= a[i+1]:
            cnt += a[i+1]
            b[i] -= a[i+1]
            a[i+1] = 0
        else:
            a[i+1] -= b[i]
            cnt += b[i]
            b[i] = 0
    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 19228
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    char tarou[101],hanako[101];
    int n = 1000, i, k, T = 0, H = 0;;
    scanf("%d", &n);
    getchar();
    for (i = 0; i < n; i++)
    {
        scanf("%s %s", tarou, hanako);
        if (strcmp(tarou, hanako) == 0)
        {
            T++; H++;
        }else if (strcmp(tarou, hanako) < 0)
        H += 3;
        else
        T += 3;
    }
    printf("%d %d\n", T, H);
    
}


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

int main() {
  int a, b,c,d;
  cin >> a >> b >> c>> d;
  if (a+b > c+d){
    cout << "Left" << endl;
  } if(a+b == c+d){
    cout << "Balanced" << endl;
  } if(a+b < c+d) {
    cout << "Right" << endl;
  }
}


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

int main(){
  vector<int> vec(5);
  for(int i=0; i<5; i++){
    cin>>vec.at(i);
  }
  vector<int> data(5);
  for(int i=0; i<5; i++){
    if(vec.at(i)%10==0){
      data.at(i)=vec.at(i)%10;
    }
    else{
      data.at(i)=10-vec.at(i)%10;
    }
  }
  sort(data.begin(),data.end());
  int ans=0;
  for(int i=0; i<4; i++){
    ans+=vec.at(i)+data.at(i);
  }
  ans+=vec.at(4);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(){
	string str ;
	int i , j , k ;
	getline( cin , str );
	for( i=0 ; i<str.size() ; i++ ){
		if( !islower( str[i] ) )
			str[i]= tolower( str[i] );
		if( !isupper( str[i] ) )
			str[i] = toupper( str[i] );
		cout << str[i];
	}
	cout << endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int n,k; cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(all(p));
    ll ans = 0;
    rep(i,k) ans += p[i];
    cout << ans << endl;
}


Measured memory_bytes: 3636
N, Y = map(int, input().split())

flag = False

for i in range(N + 1) :
    for j in range(N + 1) :
        k = N - i - j
        if k < 0 :
            continue
        if 10000 * i + 5000 * j + 1000 * k == Y :
            print(i, j, k)
            flag = True
            break
    if flag == True :
        break

if flag == False :
    print(-1, -1, -1)

Measured memory_bytes: 3188
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n = readline() |> parseInt
    s = readline() |> chomp
    if n%2==1
        println("No")
    else
        f = 0
        k = n>>1
        for i in 1:k
            if s[i]!=s[i+k]
                f = 1
            end
        end
        println(f==0?"Yes":"No")
    end
end
main()

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

const static int INF = 1001001001;

int main(void){
    int n, m, x;
    std::cin >> n >> m >> x;
    std::vector<int> c(n);
    std::vector<std::vector<int>> w;
    w.resize(n);

    for(int i = 0; i < n; i++){
	w[i].resize(m+1);
	for(int j = 0; j <= m; j++){
	    std::cin >> w[i][j];
	}
    }

    int ans = INF;
    std::vector<int> tmp(m+1, 0);
    bool flag = 0;

    for(int i = 0; i < (1 << n); i++){
	for(int j = 0; j < n; j++){
	    if(i & (1 << j)){
		for(int k = 0; k < m+1; k++){
		    tmp[k] += w[j][k];
		}
	    }else{
	    }
	}
	for(int j = 1; j <= m; j++){
	    if(tmp[j] < x){
		flag = 1;
		break;
	    }
	}
	// for(int j = 0; j <= m; j++){
	//     std::cout << tmp[j] << " ";
	// }
	// std::cout << std::endl;

	if(flag == 0 && tmp[0] < ans){
	    ans = tmp[0];
	}
	flag = 0;
	for(int j = 0; j <= m; j++){
	    tmp[j] = 0;
	}
    }
    if(ans == INF) std::cout << -1 << std::endl;
    else std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3600