akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int,input().split()))

ans = 0
if 2 <= N:
    isBigger = A[0] < A[1] 
    isEqual = A[0] == A[1]
    for i in range(1,N):
        if isEqual:
            if A[i] < A[i-1]:
                isBigger = False
                isEqual = False
            elif A[i-1] < A[i]:
                isBigger = True
                isEqual = False
            else:
                continue
        elif isBigger:
            if A[i] < A[i-1]:
                ans += 1
                if i < N-1:
                    isBigger = A[i] < A[i+1]
                    isEqual = A[i] == A[i+1]
                else:
                    break
        else:
            if A[i-1] < A[i]:
                ans += 1
                if i < N-1:
                    isBigger = A[i] < A[i+1]
                    isEqual = A[i] == A[i+1]
                else:
                    break

ans += 1
print(ans)

Measured memory_bytes: 14480
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void shortestPath(const vector<vector<int> >& graph, int start, vector<int>& dist)
{
    int n = graph.size();
    dist.assign(n, INT_MAX);
    dist[start] = 0;
    priority_queue<pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(int i=0; i<n; ++i){
            if(graph[v][i] >= 0 && dist[v] + graph[v][i] < dist[i]){
                dist[i] = dist[v] + graph[v][i];
                q.push(make_pair(dist[i], i));
            }
        }
    }

    replace(dist.begin(), dist.end(), INT_MAX, -1);
}

double dfs1(vector<vector<int> >& graph, vector<int>& dist, vector<double>& num, int pos){
     if(num[pos] != -1)
         return num[pos];

     int n = graph.size();
     if(pos == n-1)
         return num[pos] = 1;

     double tmp = 0;
     for(int i=0; i<n; ++i){
         if(graph[pos][i] != -1 && dist[pos] + graph[pos][i] == dist[i])
             tmp += dfs1(graph, dist, num, i);
     }
     return num[pos] = tmp;
}

double dfs2(vector<vector<int> >& graph, vector<int>& dist, vector<double>& num, int pos){
     if(num[pos] != -1)
         return num[pos];

     int n = graph.size();
     if(pos == 0)
         return num[pos] = 1;

     double tmp = 0;
     for(int i=0; i<n; ++i){
         if(graph[i][pos] != -1 && dist[pos] == dist[i] + graph[i][pos])
             tmp += dfs2(graph, dist, num, i);
     }
     return num[pos] = tmp;
}

void solve(vector<vector<int> >& graph, vector<double>& p)
{
    int n = graph.size();
    vector<int> dist;
    shortestPath(graph, 0, dist);

    vector<double> num1(n, -1), num2(n, -1);
    dfs1(graph, dist, num1, 0);
    dfs2(graph, dist, num2, n-1);

    p.resize(n, 0.0);
    for(int i=0; i<n; ++i){
        if(num1[i] != -1 && num2[i] != -1)
            p[i] = num1[i] * num2[i] / num1[0];
    }
}

int main()
{
    for(;;){
        int n, m, p;
        cin >> n >> m >> p;
        if(n == 0)
            return 0;

        vector<vector<int> > graph(n, vector<int>(n, -1));
        for(int i=0; i<m; ++i){
            int a, b, c;
            cin >> a >> b >> c;
            graph[a][b] = graph[b][a] = c;
        }

        vector<double> prob;
        solve(graph, prob);
        for(int i=0; i<p; ++i){
            int a;
            cin >> a;
            printf("%.10f\n", prob[a]);
        }
        cout << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(){
  int n;
  long int maxv=-10e9, minv=10e9, R[200000];
  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> R[i];
  }
  
  for(int i = 0; i < n ; i++){
    maxv = max(maxv, R[i]-minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;
  return 0;
}



Measured memory_bytes: 4656
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, D = map(int, input().split())
    X_l = [[int(x) for x in input().split()] for _ in range(N)]

    import math

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            s = 0
            for k in range(D):
                s = s + (X_l[i][k] - X_l[j][k])**2
            r = math.floor(math.sqrt(s))
            if (s - r**2) == 0:
                ans = ans + 1
    
    print(ans)



    

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc133","b",main)

Measured memory_bytes: 3188
n = int(input())
l = [0]*100
ans = 0

for i in range(1, n + 1):
    s = str(i)
    l[int(s[0])*10 + int(s[-1])] += 1

for i in range(1, 10):
    for j in range(1, 10):
        ans += l[i*10 + j]*l[j*10 + i]

print(ans)

Measured memory_bytes: 8992
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i; i<N; i++) {
    cin >> W[i];
  }
  int L,R;
  int sum;
  sum = accumulate(W.begin(), W.end(), 0);
  vector<int> P(N);
  for (int T; T<N; T++) {
    L = accumulate(W.begin(), next(W.begin(), T), 0);
    P[T]=abs(sum-2*L);
  }
  sort(P.begin(), P.end() );
  cout << P[0] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in);){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for (int i=0;i<values.length;i++){
                values[i] = i+1;
            }
            for(int i= 0;i<n;i++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0])-1;
                int b = Integer.parseInt(ab[1])-1;
                int temp  = values[a];
                values[a] = values[b];
                values[b] = temp;
            }
            for(int i = 0; i<w; i++){
                System.out.println(values[i]);
            }
        }
    }
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
bool used[200000];

signed main(){
    cin>>N>>M;
    vint q(M);
    rep(i,M)cin>>q[i],q[i]--;
    for(int i=M-1;i>=0;i--){
        int a=q[i];
        if(used[a])continue;
        used[a]=true;
        printf("%lld\n",a+1);
    }
    rep(i,N)if(!used[i])printf("%lld\n",i+1);
    return 0;
}

Measured memory_bytes: 3924
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<vector>
using namespace std;

int main(){
    long long N, ans = 0, res;
    cin >> N;
    for(long long i = 1; i * i + 2 * i <= N; i++){
        res = N - i;
        if(res % i == 0){
            ans += res/i;
        }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
struct Node {
    int key;
    struct Node *next;
    struct Node *prev;
};
typedef struct Node node_t;
node_t *root;
 
int N;
 
void insert(int x)
{
    node_t *new = (node_t*)malloc(sizeof(node_t));
    new->key = x;
    new->next = root->next;
    new->prev = root;
    root->next->prev = new;
    root->next = new;
}

/*void insertLast(int x)
{
    node_t *new = (node_t*)malloc(sizeof(node_t));
    new->key = x;
    new->next = root;
    new->prev = root->prev;
    root->prev->next = new;
    root->prev = new;
}*/


 
void deleteNode(node_t *p)
{
    p->prev->next = p->next;
    p->next->prev = p->prev;
    free(p);
}
 
void delete(int x)
{
    node_t *p = root->next;
    while (p != root) {
        if (p->key == x) {
            deleteNode(p);
            return;
        }
        p = p->next;
    }
}
 
void deleteFirst()
{
    deleteNode(root->next);
}
 
void deleteLast()
{
    deleteNode(root->prev);
}
 
void printList()
{
    node_t *p = root->next;
     
     while (p != root) {
        printf("%d", p->key);
        p = p->next;
        if (p != root) {
            printf(" ");
        }
    }
    puts("");
}
 
int main()
{
    root = (node_t*)malloc(sizeof(node_t));
    root->next = root->prev = root;
     
    int i, j;
    char cmd[15];
    int x;
     
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%s", cmd);
        switch (cmd[0]) {
        case 'i':
            scanf("%d", &x);
            insert(x);                
            break;

        case 'd':
            switch (cmd[6]) {
            case 'F':
                deleteFirst();
                break;
            case 'L':
                deleteLast();
                break;
            default:
                scanf("%d", &x);
                delete(x);
                break;
            }
            break;                
        }
    }
     
    printList();
     
    return 0;
}

Measured memory_bytes: 31788
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, M = map(int, input().split())
ans = 1
factor_dic = {}
for i in range(2,M):
    count = 0
    while M % i == 0:
        count += 1
        M = M // i
    if count:
        factor_dic[i] = count
        if M == 1:
            break
for key,value in factor_dic.items():
    ans = ans * cmb(N+value-1,value,mod)
    ans = ans % mod
print(ans)

Measured memory_bytes: 128456
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){ return (a % b)? gcd(b, a%b) : b; }
template<typename T> T lcm(T a, T b){ return a * b / gcd(a, b); }

int main(void){
    int n, A, B;
    cin >> n >> A >> B;
    string s;
    cin >> s;

    int a = 0, b = 0;
    REP(i,n){
        if(s[i] == 'a'){
            if(a+b < A+B){
                cout << "Yes" << endl;
                a++;
            } else cout << "No" << endl;
        } else if(s[i] == 'b'){
            if(a+b < A+B && b < B){
                cout << "Yes" << endl;
                b++;
            } else cout << "No" << endl;
        } else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x;
    cin>>n>>x;
    if(n*500>=x){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

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

using namespace std; 

string s;
string ans; // 最後に出力する文字列

void dfs(int i, int value, string equation){
  if (i == s.size()){
    if(value == 7){
        ans = equation;
    }
  } else {
    dfs(i+1, value+(s.at(i)-'0'), equation+"+"+s.at(i));
    dfs(i+1, value-(s.at(i)-'0'), equation+"-"+s.at(i));
  }
}

int main() {
  cin >> s;
  dfs(1,(s.at(0)-'0'),s.substr(0, 1));
  cout << ans << "=7" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
#define INF 1e9
using namespace std;
//for (int i = 0; i < N; i++){}
int N;

int main() {
    cin >> N;
    int a[N], b[N], c[N];
    for (long long i = 0; i < N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    int dp[N][3];

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 1; i < N; i++){
        for (int j = 0; j < 3; j++){
            //i番目でaを選ぶとき
            if(j == 0){
                dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
            }else if(j == 1){
                dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
            }else if(j == 2){
                dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
            }
        }
    }
    int maxs = 0;
    for (int i = 0; i < 3; i++){
        maxs = max(maxs, dp[N-1][i]);
    }
    cout << maxs << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int to[MN*8],nxt[MN*8],h[2][MN*2],cnt=1;
inline void ins(int s,int t,int* h){
	to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];h[t]=cnt;
}
int n,fa[2][MN],root[2],deg[2][MN];
void dfs1(int st,int idx){
	for(reg int i=h[idx][st];i;i=nxt[i])
		if(to[i]!=fa[idx][st])
			deg[idx][st]^=1,dfs1(to[i],idx);
}
int vis[MN*4],id[MN];
void dfs2(int st){
	for(reg int& i=h[0][st];i;i=nxt[i])
		if(!vis[i/2])
			vis[i/2]=(to[i]>n)+1,dfs2(to[i]);
}
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++){
		scanf("%d",fa[0]+i);deg[0][i]=1;
		if(fa[0][i]==-1)root[0]=i;
		else ins(fa[0][i],i,h[0]);
	}
	for(reg int i=1;i<=n;i++){
		scanf("%d",fa[1]+i);deg[1][i]=1;
		if(fa[1][i]==-1)root[1]=i;
		else ins(fa[1][i],i,h[1]);
	}
	dfs1(root[0],0);dfs1(root[1],1);
	for(reg int i=1;i<=n;i++)
		if(deg[0][i]^deg[1][i])
			return 0*puts("IMPOSSIBLE");
	for(reg int i=1;i<=n;i++){
		if(~fa[1][i])ins(fa[1][i]+n,i+n,h[0]);
		if(deg[0][i])ins(i,i+n,h[0]),id[i]=cnt/2;
	}
	ins(root[0],n+n+1,h[0]);
	ins(root[1]+n,n+n+1,h[0]);
	dfs2(n+n+1);puts("POSSIBLE");
	for(reg int i=1;i<=n;i++){
		if(deg[0][i])printf("%d ",vis[id[i]]==1?-1:1);
		else printf("0 ");
	}
	return 0;
}

Measured memory_bytes: 16128
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var cnt = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == 'o') cnt++;
            }

            Console.WriteLine((15 - S.Length + cnt) >= 8 ? "YES" : "NO");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

#define REP(i,n) for(i=n;i>0;i--)

int gcd(int a,int b);

int main(void)
{
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);
  int g;
  g = gcd(a,b);
  int i,flag=0;
  REP(i,g)
  {
    if(g%i==0) flag++;
    if(flag==k)
    {
      printf("%d\n",i);
      break;
    }
  }
  return 0;
}

int gcd(int a,int b)
{
  int max,min,tmp;
  max = MAX(a,b);
  min = MIN(a,b);
  if(max%min==0) return min;
  else
  {
    tmp = min;
    min = max%min;
    max = tmp;
    return gcd(max,min);
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#define MAX 100005
using namespace std;

int timer,N,E;
vector<int> G[MAX];
int V[MAX],parent[MAX],lowest[MAX],pre[MAX];

void dfs(int current,int prev){
    V[current]=1;
    lowest[current]=pre[current]=timer++;
    int i;
    for(i=0;i<G[current].size();i++){
        int next=G[current][i];
        if(!V[next]){
            parent[next]=current;
            dfs(next,current);
            lowest[current]=min(lowest[current],lowest[next]);
        }else if(next!=prev){
            lowest[current]=min(lowest[current],pre[next]);
        }
    }
}

int main()
{
    memset(pre,0,sizeof(pre));
    memset(parent,0,sizeof(parent));
    memset(lowest,0,sizeof(lowest));
    memset(V,0,sizeof(V));
    timer=1;
    cin>>N>>E;
    int i,j;
    for(i=0;i<E;i++){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,-1);
    int np;
    set<int> ans;
    for(i=1;i<N;i++){
        int p=parent[i];
        if(p==0)np++;
        else if(pre[p]<=lowest[i])ans.insert(p);
    }
    if(np>1)ans.insert(0);
    for(set<int>::iterator it=ans.begin();it!=ans.end();it++){
        cout<<*it<<endl;
    }
    return 0;
}

Measured memory_bytes: 8344
n = int(raw_input())
a, b = map(float, raw_input().split(" "))
c = float(raw_input())

toppings = []
for i in range(n):
    toppings.append(float(raw_input()))

toppings.sort(cmp=(lambda x,y:cmp(y,x)))

cal_sum = c
doll_sum = a
for i in range(n):
    if cal_sum/doll_sum < (cal_sum+toppings[i])/(doll_sum+b):
        cal_sum += toppings[i]
        doll_sum += b
    else: break;

print int(cal_sum/doll_sum)

Measured memory_bytes: 4248
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

template<typename T>
T bit_count(T N) {
	T cnt = 0;
	while (N) {
		if (N & 1) cnt++;
		N >>= 1;
	}
	return cnt;
}

template<typename T>
void print_vec(ostream& ostream, vector<T> a) {
	rep(i, a.size() - 1) ostream << a[i] << " ";
	ostream << a.back() << endl;
}

template<class T>
T pow_n(T x, T n) {
	T res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

class Solver {
public:
	int H, W;

	bool grid_ok(int y, int x) {
		return 0 <= y && y < H && 0 <= x && x < W;
	}

	int A, B, C;
	int K;

	void solve() {
		cin >> A >> B >> C;
		cin >> K;
		int max_v = max(max(A, B), C);
		int D = max_v * (1 << K);
		dumpl(D);
		cout << A + B + C - max_v + D << endl;
	}

};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int n, a, b, c, x;
	int[] y;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for (;;) {
			n = sc.nextInt(); a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); x = sc.nextInt();
			if ((n|a|b|c|x) == 0) break;
			y = new int[n];
			for (int i=0;i<n;i++) {
				y[i] = sc.nextInt();
			}
			
			System.out.println (solve());
		}
	}
	
	int solve() {
		int p = 0;
		for (int t = 0;t <= 10000;t++) {
			if (y[p] == x) p++;
			if (p == n) return t;
			x = (a * x + b) % c;
		}
		return -1;
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 31768
h,w = map(int,input().split())

f = 1
k = 0
p = 0
for _ in range(h):
  s = input()
  k += s.count("#")
  if s[p] == ".":
    f = 0
    break
  else:
    for i in range(p,w):
      if s[i] == ".":
        break
      else:
        p = i

if f == 1 and k == h+w-1:
  print("Possible")
else:
  print("Impossible")
  
 

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main () {
  int x = 1000000;
  int y = -1000000;
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i < X + K - 1; i ++) {
    cout << i << ' ';
  }
  cout << X + K - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin >> k;
	k--;
	cout << a[k] << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int dp[2][(1<<24)];
string s[501];
int n,m;
bool a[501][501];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  while(cin>>n>>m,n|m){
    for(int i=0;i<n;i++){
      cin>>s[i];
      for(int j=0;j<m;j++){
        a[i][j]=(s[i][j]=='1');
      }
    }
    if(n<=m){
      int ans=0;
      for(int i=0;i<(1<<n);i++){
        if(ans>=__builtin_popcount(i))continue;
        bool ok=1;
        for(int j=0;j<m;j++){
          int cont=0;
          for(int k=0;k<n;k++){
            if(a[k][j] && i&(1<<k))cont++;
          }
          if(cont&1){ok=0;break;}
        }
        if(ok)ans=max(ans,__builtin_popcount(i));
      }
      cout<<ans<<endl;
    }else{
      int list[501];
      fill(list,list+n,0);
      for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
          if(a[i][j]){
            list[i]=list[i]|(1<<j);
          }
        }
      }
      for(int i=0;i<2;i++)for(int j=0;j<(1<<m);j++)dp[i][j]=-1;
      dp[0][0]=0;
      for(int i=0;i<n;i++){
        for(int j=0;j<(1<<m);j++)dp[(i+1)&1][j]=-1;
        for(int j=0;j<(1<<m);j++){
          if(dp[i&1][j]==-1)continue;
          dp[(i+1)&1][j^list[i]]=max(dp[(i+1)&1][j^list[i]],dp[i&1][j]+1);
          dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
        }
      }
      cout<<dp[n&1][0]<<endl;
    }
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000009;





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

	int n;
	cin >> n;

	set<pair<int, int>> s;


	if (n < 400) {
		REP(i, n) {
			REP(j, n) {
				if ((i+j) % 2==1) {
					s.insert({ i,j });
				}
			}
		}
		cout << s.size() << endl;
		for (auto i : s) {
			cout << i.first << ' ' << i.second << endl;
		}
		return 0;
	}


	for (int i = 1; i < n; i += 3) {
		REP(j, n) {
			if ((i + j) % 2 == 1) {
				s.insert({ i,j });
			}
		}
	}

	REP(i, n) {
		if (i % 2 == 1 && i % 3 != 1) {
			s.insert({ i,0 });
		}
	}

	REP(i, n) {
		if ((n - 1 + i) % 2 == 1) {
			s.insert({ n - 1,i });
			s.insert({ i,n-1 });
		}
		if (i % 2 == 1) {
			s.insert({ i,0 });
			s.insert({ 0,i });
		}
	}

	cout << s.size() << endl;

	for (auto i : s) {
		cout << i.first << ' ' << i.second << endl;
	}

	return 0;
}

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

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI=3.141592653589793;

void solve(){
	int n,m;
	cin >> n >> m;
	vector<vector<int>> adj(n);
	forn(i,m){
		int u,v;
		cin >>u >> v;
		u--;v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	vector<int> par(n,-1);
	queue<int> proc;
	
	proc.push(0);
	par[0]=0;
	while(!proc.empty()){
		int u=proc.front();
		proc.pop();
		for(auto v:adj[u]){
			if(par[v]!=-1) continue;
			par[v]=u;
			proc.push(v);
		}
	}
	forn(i,n){
		if(par[i]==-1){
			cout << "No";
			return;
		}
	}
	cout << "Yes\n";
	forse(i,1,n) cout << par[i]+1 << '\n';
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forn(c,T){
//		cout << "Case #" << c+1 << ": ";
		solve();
	}
}


Measured memory_bytes: 10252
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main()
{
    ll a[] = {  1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    ll n; cin >> n;
    for(ll i = 0 ; i < 32; i++)
    {
        if((i + 1) == n)
        {
            cout << a[i] << '\n';
            break;

        }
    }
}


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

int main() {
	int n, k;
	while(cin >> n >> k && (n || k)){
		int card[10] = {0};
		map<string, int> m;
		for(int i = 0; i < n; ++i)
			cin >> card[i];
			
		int ans = 0;
		if(k == 2){
			for(int i = 0; i < n; ++i){
				for(int j  = 0; j < n; ++j){
					if(i == j)
						continue;
					string str = to_string(card[i]) + to_string(card[j]);
					if(m[str] == 0){
						ans++;
						m[str] = 1;
					}
				}
			}
		}
		else if(k == 3){
			for(int i = 0; i < n; ++i){
				for(int j  = 0; j < n; ++j){
					if(i == j)
						continue;
					for(int k = 0; k < n; ++k){
						if(i == k || j == k)
							continue;
						string str = to_string(card[i]) + to_string(card[j]) + to_string(card[k]);
						if(m[str] == 0){
							ans++;
							m[str] = 1;
						}
					}
				}
			}
		}
		else if(k == 4){
			for(int i = 0; i < n; ++i){
				for(int j  = 0; j < n; ++j){
					if(i == j)
						continue;
					for(int k = 0; k < n; ++k){
						if(i == k || j == k)
							continue;
						for(int l = 0; l < n; ++l){
							if(i == l || j ==l ||  k == l)
								continue;
							string str = to_string(card[i]) + to_string(card[j]) + to_string(card[k]) + to_string(card[l]);
				 			if(m[str] == 0){
								ans++;
								m[str] = 1;
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <string>
#include <vector>

int visit(int a, int b);

using namespace std;

vector<string> cell;
vector< vector<bool> > check;
int c, d;

int main(){
    
    while(cin >> c >> d, c | d){
        string temp;
        int x = 0, y = 0;
        
        for(int i = 0; i < d; i++){
            cin >> temp;
            cell.push_back(temp);
        }
        
        for(int i = 0; i < d; i++){
            for(int j = 0; j < c; j++){
                if(cell[i][j] == '@'){
                    x = j;
                    y = i;
                }
            }
        }
        
        for(int i = 0; i < d; i++){
            vector<bool> temp2;
            for(int j = 0; j < c; j++){
                temp2.push_back(false);
            }
            check.push_back(temp2);
        }
        
        cout << visit(y, x) << endl;
        
        cell.clear();
        check.clear();
        
        
    }
    
    return 0;
}

int visit(int a, int b){
    int ans = 0;
    
    check[a][b] = true;
    
    if(a + 1 < d && cell[a + 1][b] != '#' && !check[a + 1][b]){
        ans += visit(a + 1, b);
    }
    
    if(b + 1 < c && cell[a][b + 1] != '#' && !check[a][b + 1]){
        ans += visit(a, b + 1);
    }
    
    if(a - 1 > -1 && cell[a - 1][b] != '#' && !check[a - 1][b]){
        ans += visit(a - 1, b);
    }
    
    if(b - 1 > -1 && cell[a][b - 1] != '#' && !check[a][b - 1]){
        ans += visit(a, b - 1);
    }
    
    ans++;
    
    return ans;
}

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

int main() {
    string t;
    cin >> t;
    int n = t.size();
    for (int i = 0; i < n; i++){
        if(t[i] == '?'){
            cout << 'D';
        } else {
            cout << t[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 3724
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int t[n + 1], x[n + 1], y[n + 1];
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> t[i] >> x[i] >> y[i];
        if (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) > t[i] - t[i - 1]) {
            cout << "No" << endl;
            return 0;
        } else if ((t[i] - t[i - 1]) % 2 != (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> p(n, 0), q(n, 0);
		for(int i=0; i<n; i++)cin >> p[i];
		for(int i=0; i<n; i++)cin >> q[i];
		vector<int> x(n ,0);
		for(int i=0; i < n; i++)x[i] = i + 1;
		int i = 0, ip, iq;
		do{
			bool fp = true, fq = true;
			for(int i=0; i < n; i++)if(x[i] != p[i])fp = false;
			for(int i=0; i < n; i++)if(x[i] != q[i])fq = false;
			if(fp)ip = i;
			if(fq)iq = i;
			i++;
		}while(next_permutation(x.begin(), x.end()));
		cout << abs(ip-iq) << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b,c;
  cin >> a >> b >> c;
  if (a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
      cout << "YES" << endl;
  }else{
      cout << "NO" << endl;
  }
}

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

#define int long long int
#define vi vector<int>
#define pb push_back
#define vvi vector<vi>

signed main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++) {
        cout << s[i] << t[i];
    }
}

Measured memory_bytes: 3632
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars
    }

    let mut dp = vec![vec![0; s.len() + 1]; t.len() + 1];

    for i in 1..=t.len() {
        for j in 1..=s.len() {
            let ti = t[i - 1];
            let si = s[j - 1];

            if ti == si {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = std::cmp::max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    let mut len = dp[t.len()][s.len()];
    let mut ti = t.len();
    let mut si = s.len();

    let mut ans = vec!['a'; len];

    while len > 0 {
        if t[ti - 1] == s[si - 1] {
            ans[len - 1] = s[si - 1];
            ti -= 1;
            si -= 1;
            len -= 1;
        } else if dp[ti][si] == dp[ti - 1][si] {
            ti -= 1;
        } else {
            si -= 1;
        }
    }

    println!("{}", ans.iter().collect::<String>());
}


Measured memory_bytes: 72448
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP)
 { return firstP.first < secondP.first; }//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll n,a,b;
vi v;

string s;

int main(){
	cin>>s;
	switch(s[0]){
		case 'A':
			cout<<"T"<<endl;
			break;
		case 'T':
			cout<<"A"<<endl;
			break;
		case 'C':
			cout<<"G"<<endl;
			break;
		case 'G':
			cout<<"C"<<endl;
			break;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int main(){
   int D,N;
   cin >>D>>N;
   int a=pow(100,D);

   if(N==100){      
      cout<<101*a<<endl;
   }
   else{
      cout<<N*a<<endl;
   }
   return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder20200426first
{
    class Program
    {
        static void Main(string[] args)
        {
            var q = Console.ReadLine();
            var both = q.Split(" ");
            var fin = int.Parse(both[0]) > int.Parse(both[1]) ? "safe" : "unsafe";
            Console.WriteLine(fin);
        }
    }
}

Measured memory_bytes: 27528
using System;

class program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        for (int i = 1; i <= n; i++)
        {
            int x = i;
            if (x % 3 == 0)
            {
                Console.Write(" {0}", i);
            }
            else
            {
                while (true)
                {
                    if (x % 10 == 3)
                    {
                        Console.Write(" {0}", i);
                        break;
                    }
                    else
                    {
                        x /= 10;
                        if (x == 0) break;
                    }
                }
            }
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 20032
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n, K, Q;
    scanf("%d%d%d", &n, &K, &Q);
    vector<int> a(n, K - Q);
    int i;
    for (i = 0; i < Q; i++) {
        int tmp;
        scanf("%d", &tmp); tmp--;
        a[tmp]++;
    }
    for (i = 0; i < n; i++) {
        if (a[i] > 0) printf("Yes\n");
        else printf("No\n");
    }
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int x;cin>>x;

    if(x<1200){
      cout<<"ABC"<<endl;
    }else{
      cout<<"ARC"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	READV(K);
	ll ans=0;
	while (N>0)
	{
		ans++;
		N/=K;
	}
	cout<<ans<<endl;
	

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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

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

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

    int N;
    cin >> N;
    cout << (N + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
using namespace std;

int main()
{
	string s;
	cin >> s;

	map<char, int> cnt;
	for (int i = 0; i < s.size(); ++i)
		++cnt[s[i]];

	const string KUPC = "KUPC";
	int ans = 300;
	for (int i = 0; i < KUPC.size(); ++i)
		ans = min(ans, cnt[KUPC[i]]);

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

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

int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if (i % 2 == 0)
    {
      cout << s[i];
    }
  }
  cout << endl;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c)
    cout<<"Yes";
  else if(a+c==b)
    cout<<"Yes";
  else if(b+c==a)
    cout<<"Yes";
  else
  {
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
#define MAXN 10


int ans, n, zero, impar;
int v[MAXN];

void bkt(int i) {
    if (i == n) ans += (zero || impar < n);
    else {
        impar += (v[i] + 1) % 2;
        bkt(i + 1);
        impar -= (v[i] + 1) % 2;
        impar += (v[i]) % 2;
        bkt(i + 1);
        impar -= (v[i]) % 2;
        impar += (v[i] - 1) % 2;
        zero += v[i] == 1;
        bkt(i + 1);
        zero -= v[i] == 1;
        impar -= (v[i] - 1) % 2;
    }
}

int main() {
    cin >> n;

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

    bkt(0);
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] a = new int[n];
		
		for (int i = 0; i < n; i++)
			a[i] = scanner.nextInt();
		
		for (int i = 0; i < n; i++) {
			System.out.print(a[n - i - 1]);
			if (i < n - 1)
				System.out.print(' ');
		}
		System.out.println();
	}

}



Measured memory_bytes: 26328
#include <stdio.h>

void bubbleSort(int *,int);

int main(){
  int a[100],n,i;

  scanf("%d",&n);
  if(n < 1 || n > 100)return 0;
  
  for(i = 0; i < n; i++){
  scanf("%d",&a[i]);
  
  if(a[i] < 0 || a[i] > 100)return 0;
  }

  bubbleSort(a,n);

  return 0;
}

void bubbleSort(int a[],int n){
  int flag = 1,num = 0,b,j,i = 0;
  
  while(flag != 0){
    flag = 0;
    for(j = n-1; j > i; j--){
	 if (a[j-1] > a[j]){
	   b = a[j-1];
	   a[j-1] = a[j];
	   a[j] = b;
	   num++;
	   flag = 1;
	 }
       }
    i++;
  }
  
  
  for(j = 0; j < n; j++){
  printf("%d",a[j]);

  if(j != n-1)printf(" ");
  else printf("\n");
  }
  
  printf("%d\n",num);
  
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	string S;
	cin >> S;
	int i = 0;
	for (char ope : S) {
		if (ope == '+') {
			i++;
		}
		else {
			i--;
		}

	}
	cout << i;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 3002
using namespace std;
int n,m,k,l,r,u,d,i,j,ans[N][N];
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			int x=i+j,y=i-j+m-1;
			l=min(l,y);r=max(r,y);
			u=min(u,x);d=max(d,x);
		}
	}
	for(i=u;i<=d;i++){
		for(j=l;j<=r;j++){
			int x=i+1,y=j+1;
			if(((x-1)/k)%2==0){
				if(((y-1)/k)%2==0) ans[i][j]=1;
				else ans[i][j]=2;
			}
			else{
				if(((y-1)/k)%2==0) ans[i][j]=3;
				else ans[i][j]=4;
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			int x=i+j,y=i-j+m-1;
			if(ans[x][y]==1) printf("R");
			else if(ans[x][y]==2) printf("Y");
			else if(ans[x][y]==3) printf("G");
			else printf("B");
		}
		puts("");
	}
	return 0;
}


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

int main()
{
    long k, a, b;
    cin >> k >> a >> b;
    long max = 1 + k;
    for (long x = 0; x <= k; x++)
    {
        if ((x + 1) >= a && (k - x) >= 2)
        {
            long total = 1 + x + (b - a) * ((k - x) / 2);
            if (total > max)
                max = total;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
$satisfy = $a * $c;// 満足するために必要なお金
$count = floor($b / $a);//所持金で聞ける回数
if($b > $satisfy){
    echo $c;
}else{
    echo $count;
}


?>

Measured memory_bytes: 4728