akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int antennaNum = 5;
            var antennaList = new List<int>();
            for (int i = 0; i < antennaNum; i++)
            {
                antennaList.Add(int.Parse(Console.ReadLine()));
            }
            int K = int.Parse(Console.ReadLine());

            for (int i = 0; i < antennaNum - 1; i++)
            {
                for (int j = i + 1; j < antennaNum; j++)
                {
                    if (antennaList[j] - antennaList[i] > K)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }
            Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

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

	string s;
	cin >> s;
	
	if(s=="AKIHABARA"){cout << "YES" << endl;return 0;}
	else if(s=="KIHBR"){cout << "YES" << endl;return 0;}
	
	else if(s=="AKIHBR"){cout << "YES" << endl;return 0;}
	else if(s=="KIHABR"){cout << "YES" << endl;return 0;}
	else if(s=="KIHBAR"){cout << "YES" << endl;return 0;}
	else if(s=="KIHBRA"){cout << "YES" << endl;return 0;}
	
	else if(s=="KIHABARA"){cout << "YES" << endl;return 0;}
	else if(s=="AKIHBARA"){cout << "YES" << endl;return 0;}
	else if(s=="AKIHABRA"){cout << "YES" << endl;return 0;}
	else if(s=="AKIHABAR"){cout << "YES" << endl;return 0;}
	
	else if(s=="KIHBARA"){cout << "YES" << endl;return 0;}
	else if(s=="KIHABRA"){cout << "YES" << endl;return 0;}
	else if(s=="KIHABAR"){cout << "YES" << endl;return 0;}
	else if(s=="AKIHBRA"){cout << "YES" << endl;return 0;}
	else if(s=="AKIHBAR"){cout << "YES" << endl;return 0;}
	else if(s=="AKIHABR"){cout << "YES" << endl;return 0;}
	
	else {cout << "NO" << endl;return 0;}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 110
#define LL long long 
#define INF 0x3f3f3f3f


int main(){
	//freopen("test.in","r",stdin);
	
	int n;
	cin>>n;
	cout<<(n/2)*((n+1)/2)<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int n,k;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>k;
	int a=n%k,b=k-a;
	cout<<min(a,b);
	re 0;
}

Measured memory_bytes: 3632
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include <string.h>
using namespace std;
int a[2][105];
int dp[2][105];
int n;
int solve(int i, int j, int p) {
	if (i > 1 || j > n - 1) {
		return p;
	}
	if (i >= 1 && j >= n - 1) {
		p += a[i][j];
		return p;
	}
	int r, l,rs;
	p += a[i][j];
	if (i == 1) {

		r = solve(i, j + 1,p);
		rs = r;
	}
	else {
		r = solve(i + 1, j, p);
		l = solve(i, j + 1,p);
		rs = max(r, l);
	}
	return rs;
}

int main() {
	cin >> n;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	cout << solve(0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
(n,),*g=$<.map{|s|s.split.map &:to_i};N=0..n;d=N.map{[1e9]*-~n};g.map{|a,b,c|d[a][b]=d[b][a]=c};N.map{|k|N.map{|i|N.map{|j|d[i][j]=[d[i][j],d[i][k]+d[k][j]].min}}};p g.count{|a,b,c|d[a][b]<c}

Measured memory_bytes: 13180
#include <stdio.h>

#define MEW 112345

int N, W;
int w[128], v[128];

int ayaneru[MEW];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &W) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &w[i], &v[i]) != 2) return 1;
	}
	for (i = 0; i < MEW; i++) {
		ayaneru[i] = W + 1;
	}
	ayaneru[0] = 0;
	for (i = 0; i < N; i++) {
		int j;
		for (j = MEW - 1; j >= v[i]; j--) {
			if (ayaneru[j - v[i]] + w[i] < ayaneru[j]) ayaneru[j] = ayaneru[j - v[i]] + w[i];
		}
	}
	for (i = MEW - 1; i >= 0; i--) {
		if (ayaneru[i] <= W) {
			printf("%d\n", i);
			return 0;
		}
	}
	puts("error!");
	return 0;
}


Measured memory_bytes: 2172
#include <algorithm>  //min, max, sort, unique, fiint
#include <cassert>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int n;
  long long count = 0;
  int tmp;

  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  vector<int> v;
  REP(i, n) {
    cin >> tmp;
    v.push_back(tmp);
  }
  int acm = 0;
  long long o = 0;
  long long i = 0;
  for (i = 0; i < n; i++) {
    assert(acm < 1 << 21);
    while (o < i && (acm & (v[i]))) {
      count += i - o;
      assert(acm - v[o] == (acm ^ (v[o])));
      acm -= v[o];
      o++;
    }
    assert((acm + v[i]) == (acm | v[i]));
    acm += v[i];
  }
  assert(i == n);

  count += (i - o) * (i - o + 1) / 2;

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1400
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if p[i] == (i + 1):
        tmp = p[i]
        p[i] = p[i + 1]
        p[i + 1] = tmp
        ans += 1
if p[n - 1] == n:
    ans += 1
print(ans)

Measured memory_bytes: 14008
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,x,y;
	std::cin >> n >> x >> y;
	std::vector<std::vector<int> > g(n);
	rep(i,n-1) {
		g[i].emplace_back(i+1);
		g[i+1].emplace_back(i);
	}
	x--;y--;
	g[x].emplace_back(y);
	g[y].emplace_back(x);
	std::vector<int> ans(n+1,0);
	// bfs
	rep(i,n) {
		std::vector<int> went(n,0);
		std::queue<std::pair<int,int> > que;
		que.emplace(i,0);
		went[i]=1;
		while(!que.empty()) {
			auto o=que.front();que.pop();
			int c=o.first,d=o.second;
			for(auto to:g[c]) {
				if(went[to]) continue;
				que.emplace(to,d+1);
				went[to]=d+1;
			}
		}
		rep(j,n) if(j>i) ans[went[j]]++;
	}
	for(int i=1;i<n;i++) {
		print(ans[i]);
	}
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r, g, b;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
            r.push_back(i);
        else if (s[i] == 'G')
            g.push_back(i);
        else
            b.push_back(i);
    }
    long long int ans = 0;
    for (int i = 0; i < r.size(); i++)
        for (int j = 0; j < g.size(); j++)
        {
            int i1 = min(r[i], g[j]), j1 = max(g[j], r[i]);
            long long int h = b.size();
            int ch = lower_bound(b.begin(), b.end(), 2 * j1 - i1) - b.begin();
            if (ch < b.size() && b[ch] == 2 * j1 - i1)
                h--;
            ch = lower_bound(b.begin(), b.end(), 2 * i1 - j1) - b.begin();
            if (ch < b.size() && b[ch] == 2 * i1 - j1)
                h--;
            ch = lower_bound(b.begin(), b.end(), (i1 + j1) / 2) - b.begin();
            if (ch < b.size() && 2 * b[ch] == i1 + j1)
                h--;
            ans = ans + h;
        }
    cout << ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int n=s.size();
    ll ans=0;
    rep(i,n) ans+=s[i]-'0';
    if (ans%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
     
    return 0;   
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
    if(a < b)
        swap(a, b);

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

int main(){
    ll A, B;
    cin >> A >> B;

    ll g = gcd(A, B);
    ll ans = g * A/g * B/g;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n , k;
    cin>>n>>k;
    int a[n];
    int maxi = 0;
    int gcd = 0;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        maxi = max(maxi , a[i]);
        gcd = __gcd(a[i] , gcd);
    }
    if(k > maxi){
        cout<<"IMPOSSIBLE"<<endl;
    }else{
        if(k % gcd == 0){
            cout<<"POSSIBLE"<<endl;
        }
        else cout<<"IMPOSSIBLE"<<endl;
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
"""
9x+4y=Y-N=t
xを固定すると
y=(Y-N-9i)/4 （余りが０でなければ打ち切り）
(0<=i<=N)
z=N-i-y
i,y,zが非負なら出力（O(N)）
"""
ip=input().split()
N=int(ip[0])
Y=int(ip[1])
Y/=int(1000)
xans=-1
yans=-1
zans=-1
for i in range(N+1):
    temp = Y-N-9*i
    if((temp%4)!=0):
        continue
    y=temp/4
    z=N-i-y
    if(y>=0 and z>=0):
        xans=int(i)
        yans=int(y)
        zans=int(z)
        break
print('{0} {1} {2}'.format(xans,yans,zans))

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

#define ll long long

vector<int> adj[200001];
int vis[200001];
ll cntx,cnty;

void dfs(int v){
	vis[v]=1;
	if(v>100000) cnty++;
	else cntx++;
	for(int u:adj[v]){
		if(vis[u]) continue;
		dfs(u);
	}
	return;
}

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

	int n,x,y;
	ll ans=0;
	cin>>n;
	memset(vis,0,sizeof(vis));
	for(int i=0;i<n;i++){
		cin>>x>>y;
		adj[x].push_back(100000+y);
		adj[100000+y].push_back(x);
	}
	for(int i=1;i<=100000;i++){
		if(adj[i].size()){
			if(vis[i]==0){
				cntx=cnty=0;
				dfs(i);
				ans+=(cntx*cnty);
			}
		}
	}
	cout<<ans-n<<"\n";
	return 0;
}

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

int main(){
    int ar[3],cost;
    for(int i=0; i<3; i++){
        cin >> ar[i];
    }
    sort(ar,ar+3);
    cost = ar[1] - ar[0];
    cost += ar[2] - ar[1];
    cout << cost << endl;
    return 0;
}



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

int main(){
 ll n, k;
  cin >> n >> k;
  ll ans = min( n%k, k-n%k );
  
  cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 3604
import java.util.*;

public class Main {           
    
    public static void main(String[] args) {		        
        Scanner sc = new Scanner(System.in);                               
        
        String ans = "ABC";
        
        int N = sc.nextInt();
                
        ans += String.valueOf(N);
        
        System.out.println(ans);
              
    }                   
    
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
long long i,j,n,m,a,b,c,x,y,rez;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> a >> b >> c >> x >> y;
    if (c*2<a+b)
    {
        n=min(x,y);
        rez=n*c*2;
        x-=n;
        y-=n;
    }
    if (x==0&&c*2<b)
    {
        rez+=2*c*y;
        y=0;
    }
    if (y==0&&c*2<a)
    {
        rez+=2*c*x;
        x=0;
    }
    rez+=a*x+b*y;
    cout << rez;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;



int main(){
    string S;
    cin >> S;
    ll N=S.size();
    ll ans=(N+1)/2;
    for(ll i=N/2-1;i>=0;i--){
        if(S[i]==S[N-1-i]&&S[i]==S[N/2])ans++;
        else break;
    }
    print(ans)
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N];
		boolean finish = false;
		int count = 0;
		for(int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}
		while(true) {
			for(int i = 0; i < N; i++) {
				if(A[i] % 2 == 0) {
					A[i] = A[i] / 2;
				} else {
					finish = true;
					break;
				}
			}
			if(finish) {
				break;
			} else {
				count++;
			}
		}
		System.out.println(count);
		scan.close();

	}

}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int s,w;
    cin >> s >> w;

    if(w >= s) cout << "unsafe\n";
    else cout << "safe\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 3820
N,M=map(int,input().split())
Goodtower=["1"]*N

H=list(map(int,input().split()))
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1] > H[B-1]:
        Goodtower[B-1]=0
        #print(B+"is NOT good!")
    elif H[A-1] < H[B-1]:
        Goodtower[A-1]=0
        #print(str(A)+"is NOT good!")
    else:
        Goodtower[A-1]=0
        Goodtower[B-1]=0
        #print(str(A)+"is NOT good!")
        #print(str(B)+"is NOT good!")
print(Goodtower.count("1"))

Measured memory_bytes: 20924
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9;
vector<int> vt;

void init() {
    for(int i = 0; ; ++i) {
        vt.push_back(i * i);
        if(i * i >= M) break;
    }
}

int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    init();
    int n;
    while(cin >> n) {
        int pos = lower_bound(vt.begin(), vt.end(), n) - vt.begin();
        if(vt[pos] > n) pos--;
        cout << vt[pos] << endl;
    }
}


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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int N; cin >> N;
  UM<int,int>freq;
  vi A(N); FORE(i,A)cin>>i;
  ll ans = 0;
  REP(i,N){
    ans+=freq[A[i]-i];
    freq[-A[i]-i]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 19396
H_1,M_1,S_1,H_2,M_2,S_2=0,0,0,0,0,0
X=0
for i in range(3):
  H_1,M_1,S_1,H_2,M_2,S_2=map(int,input().split())
  X=-(H_1*3600+M_1*60+S_1-(H_2*3600+M_2*60+S_2))
  print(X//3600,(X//60)%60,X%60)


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

using static Input;
using static Util;
class Program
{
    static int N;
    static long[] H;
    static void INPUT()
    {
        N = NextInt();
        H = LineLong();
    }
    static void OUTPUT()
    {
        var max = 0;
        var c = 0;
        var prev = -1L;
        for (int idx = 0; idx < N; idx++)
        {
            if (prev >= H[idx])
                c++;
            else
            {
                max = Math.Max(max, c);
                c = 0;
            }
            prev = H[idx];
        }
        max = Math.Max(max, c);

        Console.WriteLine(max);

    }

    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
        N = 7;
        H = new long[]{ 4 ,4 ,5, 6 ,6, 5 ,5 };
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 29532
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N, K;
        cin >> N >> K;

        vector<int> a(N + 1);
        rep(i, 1, N + 1) cin >> a[i];

        vector<vector<ll> > dp(N + 1, vector<ll>(K + 2));
        dp[0][0] = 1ll;

        for (int i = 0; i < N; ++i) {
            for (int j = 0; j <= K; ++j) {
                //dp[i+1][j] ~ dp[i+1][j + a[i+1]]に加算
                int las = min(K + 1, j + a[i + 1] + 1);
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][las] -= dp[i][j];
            }

            for (int j = 0; j <= K; ++j) {
                dp[i + 1][j + 1] += dp[i + 1][j];
            }

            for (int j = 0; j <= K + 1; ++j) {
                dp[i + 1][j] %= MOD;
            }
        }

        ll ans = dp[N][K];
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 80256
#include <iostream>

using namespace std;
int v[100000],cost[100000];
inline int abs(int x) {
  return x<0?-x:x;
}
int main()
{
  int n,k;
  cin >> n >> k;
  cin >> v[0];
  for(int i=1; i<k; i++) {
    cin >> v[i];
    cost[i]=2100000000;
    for(int j=0; j<i; j++)
      cost[i]=min(cost[i],cost[j]+abs(v[i]-v[j]));
  }
  for(int i=k; i<n; i++) {
    cin >> v[i];
    cost[i]=2100000000;
    for(int j=i-k; j<i; j++)
      cost[i]=min(cost[i],cost[j]+abs(v[i]-v[j]));
  }
  cout << cost[n-1];
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    j = a[i]-1
    ans += b[j]
    if i>0:
        if a[i]==a[i-1]+1:
            ans += c[j-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string S; cin >> S;
    bool f = true;
    REP(i, SZ(S)){
        if(i % 2 == 0 && S[i] == 'L') f = false;
        if(i % 2 == 1 && S[i] == 'R') f = false;
    }
    Ans(f, "Yes", "No");

    return 0;
}


Measured memory_bytes: 256
// chal ab jayda mat udd, agle me niche jaega...

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

#define rep(i,st,en) for(__typeof(en) i=(st)-(st>en); i!=(en)-(st>en); i+=1-2*(st>en))
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(), v.end()
#define COVID_19 ios_base::sync_with_stdio(0);  cin.tie(NULL);  cout.tie(NULL);
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{cout << *it << " = " << a << endl;    err(++it, args...);}
typedef long long ll;
const ll mod = 1e9+7;

int main() {
    COVID_19
    string s;   cin>>s;
    if(s[2] == s[3] and s[4] == s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = 1e9 + 7;

int main() {
	double A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
	double maxV = 0;
	double maxW, maxS;
	repe(a, 0, 30) repe(b, 0, 30) repe(c, 0, 100) repe(d, 0, 100) {
		double w = 100 * a * A + 100 * b * B;
		double s = c * C + d * D;
		if (w + s > F)continue;
		if (w == 0 || s > w * E / 100)continue;
		if (maxV <= s / (s + w)) {
			maxV = s / (s + w);
			maxW = w;
			maxS = s;
			//cout << maxW << " " << maxS << endl;
		}
	}
	cout << maxW + maxS << " " << maxS << endl;
	return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = (double)w * h / 2;
    int cnt = (w/2 == x && w % 2 == 0) + (h/2 == y && h % 2 == 0) - 1;
    cout << ans << " " << max(cnt,0) << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;

class Main{
    public static void main(String[] args){
	BufferedReader br
	    = new BufferedReader(new InputStreamReader(System.in), 1);
	int n;
	int[] array;
	String[] tmp = null;

	try{
	    n = Integer.parseInt(br.readLine());
	    tmp = br.readLine().split(" ");
	}catch(IOException e){
	    e.getStackTrace();
	}
	if(tmp == null)
	    System.exit(1);

	array = new int[tmp.length];
	for(int i=0; i<tmp.length; i++){
	    array[i] = Integer.parseInt(tmp[i]);
	}
	    
	
	//sort
	int t;
	int cnt = 0;
	for(int i = 0; i < array.length; i++){
	    for(int j = array.length-1; j > i; j--){
		if( array[j] < array[j-1]){
		    t = array[j];
		    array[j] = array[j-1];
		    array[j-1] = t;
		    cnt++;
		}
	    }
	}
	for(int i = 0; i < array.length; i++)
	    System.out.print(array[i] + (i != array.length-1 ? " " : "\n") );
	System.out.println(cnt);
    }
}

Measured memory_bytes: 17072
<?php
    fscanf(STDIN, "%d %d %d", $n, $a, $b);
    $answer = 0;

    for($i=1; $i<=$n; $i++)
    {
        $tmp = str_split($i);
        $total = 0;

        for($j=0; $j<count($tmp); $j++)
        {
            $total = $total + $tmp[$j];
        }

        if(($a <= $total) && ($total <= $b))
        {
            $answer = $answer + $i;
        }
    }

    echo $answer;
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int
int used[1000005] = {};
void solve(long long N, std::vector<long long> A) {
  sort(A.begin(), A.end());
  map<int, int> m;
  rep(i, N) m[A[i]]++;
  int ma = 1e6 + 1;
  int cnt = 0;
  rep(i, N) {
    if (!used[A[i]]) {
      if (m[A[i]] == 1)
        cnt++;
      for (int j = A[i]; j < ma; j += A[i]) {
        used[j] = true;
      }
    }
  }
  cout << cnt << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 25048
#include <stdio.h>
#pragma warning(disable : 4996)
int n, q, a[16][16], b[16][16], com, r, c, s, z;
void rec(int r_, int c_) {
	a[r_][c_] ^= 1;
	for (int i = -1; i <= 1; i++) {
		for (int j = -1; j <= 1; j++) {
			if (i * j == 0 && i + j && 0 <= r_ + i && r_ + i < n && 0 <= c_ + j && c_ + j < n && a[r_ + i][c_ + j] != a[r_][c_]) rec(r_ + i, c_ + j);
		}
	}
}
int main() {
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &com, &r), r--;
		switch (com) {
		case 0:
			scanf("%d%d%d", &c, &s, &z), c--;
			for (int i = 0; i < z / 90; i++) {
				for (int j = r; j < r + s; j++) {
					for (int k = c; k < c + s; k++) {
						b[j][k] = a[(s - 1 - (k - c) + r)][(j - r) + c];
					}
				}
				for (int j = r; j < r + s; j++) {
					for (int k = c; k < c + s; k++) a[j][k] = b[j][k];
				}
			}
			break;
		case 1:
			scanf("%d%d", &c, &s), c--;
			for (int i = r; i < r + s; i++) {
				for (int j = c; j < c + s; j++) a[i][j] ^= 1;
			}
			break;
		case 2:
			for (int i = 0; i < n; i++) b[r][i] = a[r][(i + 1) % n];
			for (int i = 0; i < n; i++) a[r][i] = b[r][i];
			break;
		case 3:
			for (int i = 0; i < n; i++) b[r][(i + 1) % n] = a[r][i];
			for (int i = 0; i < n; i++) a[r][i] = b[r][i];
			break;
		case 4:
			scanf("%d", &c), c--; rec(r, c);
			break;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) printf(j ? " %d" : "%d", a[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 2692
#include<stdio.h>
int main(){
  double n;
  char a[12];
  int m,i;
  while(1){
    scanf("%lf",&n);
    if(n<0)break;
    n*=16;
    m=n;
    if(m-n){
      printf("NA\n");
      continue;
    }
    for(i=12;i;i--){
      a[i-1]=m%2+'0';
      m/=2;
    }
    if(m){
      printf("NA\n");
      continue;
    }
    for(i=0;i<12;i++){
      if(i==8)printf(".");
      printf("%c",a[i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 620
/* AtCoder Beginner Contest abc132
 * Problem B
 * Au: SJoshua
 */
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector <int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int cnt = 0;
	for (int i = 1; i < n - 1; i++) {
		int nmin = min(min(p[i - 1], p[i]), p[i + 1]);
		int nmax = max(max(p[i - 1], p[i]), p[i + 1]);
		if (nmin < p[i] && p[i] < nmax) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2228
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()re


int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  
  int ans = 1e9;
  if (a+b > c*2) {
    if (x > y) {
      for (int numc = y*2; numc <= x*2; numc += 2) {
        ans = min(ans, c*numc + a*(x - numc/2));
      }
    } else {
      for (int numc = x*2; numc <= y*2; numc += 2) {
        ans = min(ans, c*numc + b*(y - numc/2));
      }
    }
  } else {
    ans = a*x +b*y;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
card = [list(map(int,input().split())) for i in range(3)]
N = int(input())
List = [int(input()) for i in range(N)]

def disclose(card, n, lst):
  for i in range(n):
    for j in range(3):
      for k in range(3):
        if card[j][k] == lst[i]:
          card[j][k] = 0
  return card
          
def trans(matrix):
  tr = []
  for i in range(len(matrix[0])):
    vector = []
    for j in range(len(matrix)):
      vector.append(matrix[j][i])
    tr.append(vector)
  return tr

def bingo(card):
  if card[0] == [0,0,0]:
    return True
  if card[1] == [0,0,0]:
    return True
  if card[2] == [0,0,0]:
    return True
  card = trans(card)
  if card[0] == [0,0,0]:
    return True
  if card[1] == [0,0,0]:
    return True
  if card[2] == [0,0,0]:
    return True
  for i in range(3):
    if card[i][i] != 0:
      break
    if i == 2:
      return True
  for i in range(3):
    if card[i][2-i] != 0:
      break
    if i == 2:
      return True
  return False
    
def judge(x):
  if x:
    return "Yes"
  return "No"

print(judge(bingo(disclose(card, N, List))))



Measured memory_bytes: 3064
dice_1 = input().split()
dice_2 = input().split()

rolls = {' ':[0, 1, 2, 3, 4, 5], 
         'W':[2, 1, 5, 0, 4, 3], 
         'N':[1, 5, 2, 3, 0, 4], 
         'E':[3, 1, 0, 5, 4, 2], 
         'S':[4, 0, 2, 3, 5, 1]
        }
orders = [' ', 'N', 'W', 'E', 'S', 'NN']
tf = 0
for order in orders:
    copy_2 = dice_2
    for d in order:
        roll = rolls[d]
        copy_2 = [copy_2[i] for i in roll]    
    l = [1, 2, 4, 3]
    a0 = copy_2[0] == dice_1[0]
    a1 = copy_2[5] == dice_1[5]
    a2 = ' '.join([copy_2[s]for s in l]) in ' '.join([dice_1[s]for s in l] * 2)
    if  a0 and a1 and a2:
        tf += 1
if tf>0:
    print('Yes')
else:
    print('No')


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



using namespace std;
const int MaxN = 1e5;
typedef long long LL;

string s;
int k;


int main()
{
	cin >> s;
int len = s.length();
	cin >> k;
	for(int i = 0;i < len;i++)
	{
		int y = 'z' - s[i] + 1 ;
		if(k >= y && k != 0 && y != 26)
		{
			s[i] = 'a';
			k = k - y;
		}
	}
	if(k > 0)
	{
		int h = k % 26;
		for(int i = 1;i <= h;i++)
		{
			if(s[len - 1] == 'z')
			{
				s[len - 1] = 'a';
			}
			else 
			s[len - 1]++;
		}
	}

	for(int i = 0;i < len;i++)
	{
		printf("%c",s[i]);
	}
	cout << endl;
}







Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s, ans;
  ll k;
  cin >> k >> s;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  if(s.size() > k) {
    ans = s.substr(0, k);
    ans += "...";
  }
  else ans = s;
    
  cout << ans << "\n";
  //cout << (  ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 3644
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {

      
 public static void main(String[] args) {
    
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = in.nextInt();
    
    boolean yes = false;
    
    while(N > 0) {
        int d = N%10;
        N /= 10;
        if(d == 7) {
            yes = true;
        }
    }
    
    System.out.println(yes ? "Yes" : "No");
    
  }
  
  
}

Measured memory_bytes: 35804
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())

b = 111
if N <= b :
  print (b)
  exit()

while N-b > 111 :
  b += 111
b += 111
print (b)  
  

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;


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

    int N, K;
    cin >> N >> K;

    long long val = 0;
    int i = 0;
    while (val <= N) {
        val = pow(K, ++i);
    }

    cout << i;

    return 0;
}

/*
file=a
g++ -W -Wall -pedantic --std=c++17 -ggdb3 -o ${file}.out ${file}.cpp && ./${file}.out


1000000000 2
1000000000 10
*/


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

int main()
{
	int n;
	cin >> n;
	vector<short> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

	sort(a.begin(), a.end(), greater<short>());
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (i % 2 == 1)
		{
			a[i] *= -1;
		}
		ans += a[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    double x=N/1.08;
    if(floor(floor(x)*1.08)==N) cout<<floor(x)<<endl;
    else if(floor(ceil(x)*1.08)==N) cout<<ceil(x)<<endl;
    else cout<<":("<<endl;
}

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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	int N;
	cin>>N;

	vector<long> A(N);
	for(int i=0; i<N; i++){
		cin>>A[i];
	}
	sort(A.begin(), A.end());

	for(int i=1; i<N; i++){
		A[i]+=A[i-1];
	}

	int ans=0;
	for(int i=N-1; i>0; i--){
		if(2 * A[i-1] < A[i]-A[i-1]){
			ans=i;
			break;
		}
	}

	cout<<N-ans<<endl;

	return 0;
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };
 
 
int main(void) {
 
	int n, k;
 
	cin >> n >> k;
 
	if (n%k == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
 
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string t; cin >> t;
	bool n = false, e = false, w = false, s = false;
	REPC(i, t) {
		*(i == 'N' ? &n : i == 'E' ? &e : i == 'W' ? &w : &s) = true;
	}
	cout << ((n == s) & (e == w) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($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")};}

fn solve() {
    input! {
        s: chars
    }

    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

int main() {
  int n=0;
  cin>>n;
  bool fizz,buzz=false;
  long sum=0;
  
  for(int i=1;i<=n;i++){
    if(i%3==0){
      fizz=true;
    }
    if(i%5==0){
      buzz=true;
    }
    if(fizz==true||buzz==true){
      fizz=false;
      buzz=false;
      continue;
    }else{
      sum+=i;
    }
    fizz=false;
    buzz=false;
  }
  
  cout<<sum;
}

Measured memory_bytes: 3620
let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d %d %d\n" @@ fun n m k ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let bs = Array.init m @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  let inc = Array.make (n + 1) 0 in
  let inc' = Array.make (m + 1) 0 in
  for i = 0 to n - 1 do
    inc.(i + 1) <- inc.(i) + as_.(i)
  done;
  for i = 0 to m - 1 do
    inc'.(i + 1) <- inc'.(i) + bs.(i)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left max min_int @@
  Array.init (n + 1) @@ fun i ->
    if k < inc.(i)
    then 0
    else i + upper_bound 0 (m + 1) (fun j -> inc.(i) + inc'.(j) <= k)


Measured memory_bytes: 13996
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 8e4+5;
const int INF = 1e17 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn];
int32_t main()
{
    IOS;
    int x,y ,z;
    cin>>x>>y>>z;
    cout<<(x+y+z)-max({x,y,z});
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 2e5 + 5;
ll n, m, sum;
ll a[maxn];
int main(){
	scanf("%lld", &n);
	for(ll i = 2; i <= n; i++){
		scanf("%lld", &m);
		a[m]++;
	}
	for(ll i = 1; i <= n; i++){
		printf("%lld\n", a[i]);
	}
	return 0;
}

Measured memory_bytes: 5320