akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    static List<ban> bans;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int C = scan.nextInt();
        bans = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            bans.add(new ban(scan.nextInt() * 2,scan.nextInt() * 2,scan.nextInt()));
        }
        bans.sort(Comparator.comparingInt(x -> x.s));

        for (int i = 1; i <= C; i++) {
            boolean success = func(i);
            if (success) {
                System.out.println(i);
                return;
            }
        }
    }

    private static boolean func(int num) {
        List<tv> tvs = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            tvs.add(new tv(-1, -1));
        }
        for (int i = 0; i < bans.size(); i++) {
            int now = bans.get(i).s;
            int can = bans.get(i).c;
            Optional<tv> tmp = tvs.stream().filter(x -> x.c == -1 || (x.c == can && x.t <= now) || x.t <= now - 1).sorted(Comparator.comparingInt(x -> x.t)).findFirst();
            if(tmp.isPresent()) {
                tv temp = tmp.get();
                temp.t = bans.get(i).t;
                temp.c = can;
            }
            else {
                return false;
            }
        }
        return true;
    }

    static class tv{
        int t;
        int c;
        public tv(int t, int c) {
            this.t = t;
            this.c = c;
        }
    }

    static class ban{
        int s;
        int t;
        int c;
        ban(int s, int t, int c) {
            this.s = s;
            this.t = t;
            this.c = c;
        }
    }
}

Measured memory_bytes: 115908
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 00:27:20 2020

@author: Kanaru Sato
"""

import heapq

n,m = list(map(int, input().split()))
a = list(map(int, input().split()))

a = [-1*i for i in a]
heapq.heapify(a)
sum = 0

for trial in range(m):
    min = heapq.heappop(a)
    min = -1*((-1*min)//2)
    heapq.heappush(a,min)

sum = 0
for i in range(len(a)):
    sum += -1*a[i]

print(sum)

Measured memory_bytes: 14380
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
string a[55],b[55];
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<m;i++)cin>>b[i];
  bool ok=false;
  for(int i=0;i<n;i++)if(i+m-1<n){
    for(int j=0;j<n;j++)if(j+m-1<n){
      ok=true;
      for(int k=0;k<m && ok;k++){
        for(int l=0;l<m && ok;l++){
          if(a[i+k][j+l]!=b[k][l])ok=false;
        }
      }

      if(ok){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int H,A,cnt=1;
	
	scanf("%d %d",&H,&A);
	
	H = H - A;
	
	while(H>0){
		H = H - A;
		cnt = cnt +1;
	}
	
	printf("%d",cnt);
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>	
int main(void)
{
		int h,w,i,j; 
		while(1) {
			scanf("%d %d",&h,&w);
			if(h==0 && w==0)  break;
			for(i=0;i<h;i++){
				for(j=0;j<w;j++){
					printf("#");
				}
				printf("\n");
			}	
			printf("\n");
		}	
		return 0;		
}							


Measured memory_bytes: 2604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec p(n);
  for(ll i=0;i<n;i++) {
    cin >> p[i];
    p[i]--;
  }
  vec a(n);
  vec b(n);
  for(ll i=0;i<n;i++) {
    a[i]=(i+1)*30000;
    b[i]=(n-i)*30000;
  }
  for(ll i=0;i<n;i++) {
    a[p[i]]+=i;
  }
  for(ll i=0;i<n;i++) {
    if(i!=0) {
      cout << " ";
    }
    cout << a[i];
  }
  cout << endl;
  for(ll i=0;i<n;i++) {
    if(i!=0) {
      cout << " ";
    }
    cout << b[i];
  }
  cout << endl;
}

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

int main() {
  long long n, k;
  cin >> n >> k;
  
  int i;
  vector<long long> a(n), b(n), c(n);
  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  int j;
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(a.at(j) < a.at(i) && j > i){
        b.at(i)++;
        c.at(i)++;
      }
      else if(a.at(j) < a.at(i)) c.at(i)++;
    }
  }
  
  long long ans = 0;
  for(i = 0; i < n; i++){
    ans += (b.at(i) * k) % 1000000007;
    ans += (((((k - 1) * k) / 2) % 1000000007) * c.at(i)) % 1000000007;
  }
  
  cout << ans % 1000000007 << endl;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int n, a, b;
  int t;

  scanf("%d %d %d",&n, &a, &b);

  int ans = 0;
  REP (i, n) {
    scanf("%d",&t);
    if (t < a || b <= t) ans++;
  }

  printf("%d\n",ans);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader (is);
		String input[] = br.readLine().split(" ");
		//[x][0] = ボールの個数  -1以上
		//[x][1] = 赤のボールがある 1 0
		//[x][2] = 赤のボールが入れられた 1 0
		int boxCount = Integer.parseInt(input[0]);
		int[][] box =new int [boxCount][3];
		for(int i=0;i<boxCount;i++) {
			for(int j=0;j<3;j++) {
				box[i][j]=0;
			}
		}
		box[0][1] = 1;
		box[0][2] = 1;
		int order = Integer.parseInt(input[1]);
		while(br.ready()) {
			String temp[] = br.readLine().split(" ");
			int before = Integer.parseInt(temp[0])-1;
			int after = Integer.parseInt(temp[1])-1;
			if(box[before][0] >= 0) {
				//赤のボールが移されたなら
				if(box[before][1]==1) {
					box[before][1] = 0;
					box[after][1] = 1;
					box[after][2] = 1;
				}
				//赤のボールが入れられた可能性があるなら、受け先も可能性アリ
				if(box[before][2]==1) {
					box[after][2] = 1;
				}
				//ボールがなくなる場合は赤のボールのある可能性はない
				if(box[before][0] == 0) {
					box[before][2] = 0;
				}
				box[before][0]--;
				box[after][0]++;
			}
		}
		int result = 0;
		for(int i =0 ;i<boxCount ; i++) {
			if(box[i][0] >= 0) {
				if(box[i][2] == 1) {
					result++;
				}
			}
		}
		if(result==0) {
			System.out.println(1);
		}else {
			System.out.println(result);
		}
	}

}

Measured memory_bytes: 48608
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

string str;
ll dp[100005][5];
//dp[i][j] = num
//i-1番目まで見たとき、j番目まで選べたとき、残りはnum通り選べる

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> str;
    
    dp[str.size()][3] = 1;
    
    
    
    
    
    for(ll i = str.size() -1; i >= 0; i--){
        if(str[i] == '?')dp[i][3] =  dp[i+1][3] * 3;
        else dp[i][3] = dp[i+1][3];
        dp[i][3] %= MOD;
    }
        
    for(ll i = str.size() - 1;i>= 0; i--){
        for(ll j = 2; j >= 0; j--){
            ll c = -1;
            if(str[i] != '?') c = str[i]-'A';
            
            if(c == -1) dp[i][j] = 3 * dp[i+1][j] + dp[i+1][j+1];
            else if(c == j) dp[i][j] = dp[i+1][j] + dp[i+1][j+1];
            else dp[i][j] = dp[i+1][j];
            
            dp[i][j] %= MOD;
        }
    }
    
    /*
    cerr << "----  debug  ---" << endl;
    cerr << "----------------" << endl;
    rep(i, str.size()){
        cerr << str[i] << " ";
    }
    cerr << endl;
    cerr << "----------------" << endl;
    rep(i, str.size()+1){
        cerr << dp[i][0] << " ";
    }
    cerr << endl;
    cerr << "----------------" << endl;
    rep(i, str.size()+1){
        cerr << dp[i][1] << " ";
    }
    cerr << endl;
    cerr << "----------------" << endl;
    rep(i, str.size()+1){
        cerr << dp[i][2] << " ";
    }
    cerr << endl;
    cerr << "----------------" << endl;
    rep(i, str.size()+1){
        cerr << dp[i][3] << " ";
    }
    cerr << endl;
    cerr << "----------------" << endl;
     */
    cout << dp[0][0] << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 4432
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N;
  string s;
  cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

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

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
main(){
	string str;
	int ans[4]={0,0,0,0};
	while(cin>>str){
		int n;
		for(int i=0;;++i){
			if(str[i]==','){
				n=i;
				break;
			}
		}
		string s="";
		for(int i=n+1;i<=str.size()-1;++i){
			s+=str[i];
		}
		if(s=="A")ans[0]++;
		if(s=="B")ans[1]++;
		if(s=="AB")ans[2]++;
		if(s=="O")ans[3]++;
	}
	for(int i=0;i<4;++i)cout<<ans[i]<<endl;
}

Measured memory_bytes: 1192
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;

# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12



template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

int main()
{
	INT(n);
	int a[110][110];
	FOR(i, 110)FOR(j, 110)a[i][j] = (i != j ? INF:0);
	FOR(i, n)
	{
		INT(r);
		INT(k);
		FOR(j, k)
		{
			INT(t);
			a[r][t] = 1;
		}
	}
	FOR(k, n+1)FOR(i, n+1)FOR(j, n+1)a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
	INT(p);
	FOR(i, p)
	{
		INT(s); 
		INT(g);
		INT(t);
		if (a[s][g]+1 <= t)cout << a[s][g]+1 << endl;
		else cout << "NA" << endl;
	}

}

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

bool CIRCLE(int num1, int num2, int num3, int num4, int num5) {
	if (num3 >= 0 && num4 >= 0) {
		if (num3 - num5 >= 0 && num4 - num5 >= 0) {
			if (num3 + num5 <= num1 && num4 + num5 <= num2) {
				return true;
			}
			else {
				return false;
			}
		}
		else {
			return false;
		}
	}
	else {
		return false;
	}
}

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if ((int)CIRCLE(W, H, x, y, r) == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
import sys
input=sys.stdin.readline
inf=10**9+7
n,m,l=map(int,input().split())
D=[[inf]*(n+1) for _ in range(n+1)]
for _ in range(m):
    a,b,c=map(int,input().split())
    D[a][b]=c
    D[b][a]=c

for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            D[i][j]=min(D[i][j],D[i][k]+D[k][j])

DD=[[inf]*(n+1) for _ in range(n+1)]
for x in range(1,n+1):
    for y in range(1,n+1):
        if D[x][y]<=l:
            DD[x][y]=1

for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            DD[i][j]=min(DD[i][j],DD[i][k]+DD[k][j])

q=int(input())
for _ in range(q):
    s,t=map(int,input().split())
    if DD[s][t]==inf:
        print(-1)
    else:
        print(DD[s][t]-1)

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

#define rep(i,n) for(long long (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(long long (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = max((a),(b))
#define chmin(a, b) a = min((a),(b))
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;

int main(){
    int n,k;
    cin>>n>>k;
    vint road(n);
    rep(i,n)cin>>road[i];
    int ans=inf;
    rep(i,n-k+1){
        ans=min(ans,min(abs(road[i]),abs(road[i+k-1]))+road[i+k-1]-road[i]);
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 640
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<assert.h>
#include<stack>
ll z = 1000000007 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b <= 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
using namespace std ;


//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);

 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	ll h , cnt = 1, ans = 0 ;
	cin >> h ;
	while(h != 0)
	{
		ans += cnt ;
		cnt *= 2 ;
		h /= 2 ;
	}
	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 __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    int x,k,d;
    cin>>x>>k>>d;

    if(x < 0) x *= -1;

    if(k > x/d)
    {
        int right = x/d;
        if((k-right)%2==0)
        {
            cout<< x - right*d;
        }
        else
        {
            cout<<abs(x-(right+1)*d);
        }
    }
    else
    {
        cout<< x - k*d;
    }

}


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

using namespace std;

int main()
{

  int m, f, r, count, sum, i;
  string ans[50];

  i = 0;
  while (true)
  {
    cin >> m >> f >> r;

    sum = m + f;
    if (m == -1 && f == -1 & r == -1)
    {
      break;
    }
    if (m == -1 || f == -1)
    {
      ans[i] = "F";
      i++;
      continue;
    }
    if (80 <= sum)
    {
      ans[i] = "A";
      i++;
      continue;
    }
    else if (65 <= sum && sum < 80)
    {
      ans[i] = "B";
      i++;
      continue;
    }
    else if (50 <= sum && sum < 65)
    {
      ans[i] = "C";
      i++;
      continue;
    }
    else if (30 <= sum && sum < 50)
    {
      if (50 <= r)
      {
        ans[i] = "C";
        i++;
        continue;
      }
      else
      {
        ans[i] = "D";
        i++;
        continue;
      }
    }
    else if (sum < 30)
    {
      ans[i] = "F";
      i++;
      continue;
    }
  }

  for (int j = 0; j < i; j++)
  {
    cout << ans[j] << endl;
  }
}


Measured memory_bytes: 3172
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  double a = (static_cast<float>(N) / 2.0f);
  if (N % 2 == 1) {a += 0.5f;}
  printf("%.10f", a / static_cast<double>(N));
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	ll A,B,K; cin>>A>>B>>K;
	if(A>K){
		A -= K;
	}
	else{
		B = K-A>B?0:B-K+A;
		A = 0;
	}
	cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 256
from math import sqrt

N, M = [int(_) for _ in input().split()]
m = M

a = 0
flg = False
for i in range(1, int(sqrt(M)) + 1):
    if M % i==0:
        if i <= M / N:
            a = max(a, i)
        b = M // i
        if b <= M / N:
            a = max(a, b)

print(a)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	int n, k;
	cin >> n >> k;

	int d = 1;
	while (n /= k) {
		d++;
	}
	cout << d << endl;
}

int main() {
	solve();
	return 0;
}

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

int main() {
	string tmp;
	string body;
	int pos;
	cin >> body;
	while(cin >> tmp)
	{
		if ((pos = tmp.find("peach"))!=string::npos)
		{
			tmp.erase(pos,5);
			tmp.insert(pos,"apple");
		} else if ((pos =tmp.find("apple"))!=string::npos) {
			tmp.erase(pos,5);
			tmp.insert(pos,"peach");
		}
		body += " " + tmp;
	}
	cout << body << endl;
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
int main(){
    int n,ja,ma,japd,mapd,jad,mad,bigd;
    scanf("%d%d%d%d%d",&n,&ja,&ma,&japd,&mapd);
    jad=ja/japd+1;
    if(ja%japd==0)
        jad--;
    mad=ma/mapd+1;
    if(ma%mapd==0)
        mad--;
    if(jad<mad)
        bigd=mad;
    else
        bigd=jad;
    printf("%d\n",n-bigd);
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a,0,sizeof(a))
#define sqr(x) ((x)*(x))

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

const int mn = 2e5 + 5;
const int mm = 2100;
const int mod = 1e9 + 7;
#define P mod

int n,q;
char s[mn];

char d[mn],t[mn];

bool cl(int pos){
	for(int i=1;i<=q;i++){
		if (d[i]!=s[pos]) continue;
		if (t[i]=='L') pos--;
		else pos++;
		if (!pos) return 1;
		if (pos>n) return 0;
	}
	return 0;
}

int solvel(){
	int ans=0;
	int L=1,R=n;
	while(L<=R){
		int mid=L+R>>1;
		if (cl(mid)) L=mid+1,ans=mid;
		else R=mid-1;
	}
	return ans;
}

bool cr(int pos){
	for(int i=1;i<=q;i++){
		if (d[i]!=s[pos]) continue;
		if (t[i]=='L') pos--;
		else pos++;
		if (!pos) return 0;
		if (pos>n) return 1;
	}
	return 0;
}

int solver(){
	int ans=n+1;
	int L=1,R=n;
	while(L<=R){
		int mid=L+R>>1;
		if (cr(mid)) R=mid-1,ans=mid;
		else L=mid+1;
	}
	return ans;
}

int main() {
	//cin.sync_with_stdio(0);
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
#endif
	scanf("%d%d",&n,&q);
	scanf("%s",s+1);
	getchar();
	for(int i=1;i<=q;i++){
		scanf("%s%s",d+i,t+i);
	}
	int l=solvel(),r=solver();


	//printf("%d %d\n",l,r);
	int ans=r-l-1;
	if (ans<0) ans=0;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rua system("pause")
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) {x = x * 10 + c - '0', c = getchar();}
	return x * f;
}

const int MAXN = 4e5 + 10;
int n, a[MAXN], st[MAXN], top, val[MAXN];

inline bool check(int x)
{
	st[top = 1] = 1, val[1] = 0;
	for (int i = 2; i <= n; i ++)
	{
		if (a[i] > a[i - 1])
		{
			if (val[top])
			{
				val[++ top] = 0, st[top] = a[i - 1] + 1;
			}
			continue;
		}
		if (!x) return 0;
		while (top && st[top] > a[i]) top --;
		if (!top) return 0;
		while (top > 1 && val[top] == val[top - 1]) top --;
		if (top == 1 && val[1] == x) return 0;
		if (val[top] == x)
		{
			int pre = val[top - 1];
			if (st[top - 1] < st[top] - 1)
			{
				int cur = st[top];
				st[top] --, val[top] = pre + 1;
				st[++ top] = cur, val[top] = 0;
			}
			else
			{
				if (top <= 2 || val[top - 2] != val[top - 1] + 1)
					val[top - 1] ++, val[top] = 0;
				else st[top - 1] = st[top], val[top - 1] = 0, top --;
			}
		}
		else
		{
			int pre = val[top];
			if (st[top] < a[i])
				st[++ top] = a[i];
			val[top] = pre + 1;
		}
	}
	return 1;
}

int main()
{
//	freopen("in21.txt", "r", stdin);
	n = read();
	for (int i = 1; i <= n; i ++) a[i] = read();
	int L = 1, R = n, res = n;
	while (L <= R)
	{
		int MID = (L + R) >> 1;
		if (check(MID - 1)) res = MID, R = MID - 1;
		else L = MID + 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

void chmax(int &a, int b) { a = max(a, b); }

int INF = 1e+15;
int n;
int a[200000];
int dp[200001][3];

int tle() {
	int i, j;
	
	int ret = -INF;
	for (i = 0; i < (1 << n); i++) {
		bool used[20] = {false};
		int ucnt = 0;
		rep(j, n) {
			if ((i >> j) & 1) {
				used[j] = true;
				ucnt++;
			}
		}
		if (ucnt != n / 2) continue;
		
		rep(j, n - 1) {
			if (used[j] && used[j + 1]) break;
		}
		if (j < n - 1) continue;
		
		int s = 0;
		rep(j, n) if (used[j]) s += a[j];
		ret = max(ret, s);
	}
	return ret;
}

int solveOdd() {
	int i, j;

	rep(i, n) rep(j, 3) dp[i][j] = -INF;
	
	dp[0][2] = a[0];
	dp[1][1] = a[1];
	dp[2][0] = a[2];
	rep(i, n) {
		rep(j, 3) {
			if (dp[i][j] <= -INF) continue;
			if (i + j >= n - 1) continue;
			
			for (int k = 0; k <= j; k++) {
				if (i + 2 + k >= n) continue;
				chmax(dp[i + 2 + k][j - k], dp[i][j] + a[i + 2 + k]);
			}
		}
	}
	
	int ans = -INF;
	rep(i, n) rep(j, 3) if (i + j == n - 1) ans = max(ans, dp[i][j]);
	return ans;
}

int solveEven() {
	int i, j;

	rep(i, n) rep(j, 2) dp[i][j] = -INF;
	
	dp[0][1] = a[0];
	dp[1][0] = a[1];
	rep(i, n) {
		rep(j, 2) {
			if (dp[i][j] <= -INF) continue;
			if (i + j >= n - 1) continue;
			
			for (int k = 0; k <= j; k++) {
				if (i + 2 + k >= n) continue;
				chmax(dp[i + 2 + k][j - k], dp[i][j] + a[i + 2 + k]);
			}
		}
	}
	
	int ans = -INF;
	rep(i, n) rep(j, 2) if (i + j == n - 1) ans = max(ans, dp[i][j]);
	return ans;
}

int solve() {
	if (n % 2 == 0) return solveEven();
	return solveOdd();
}

void stress(int ln) {
	n = ln;
	for (int t = 0; t < 100000; t++) {
		if (t % 1000 == 0) cerr << "t = " << t << endl;
		
		int i;
		rep(i, n) {
			a[i] = rand() % 100 - 50;
		}
		int res1 = tle();
		int res2 = solve();
		if (res1 != res2) {
			cout << "Wrong Answer [" << i << "]" << endl;
			cout << "res1 = " << res1 << endl;
			cout << "res2 = " << res2 << endl;
			cout << "a = " << endl;
			rep(i, n) {
				cout << a[i] << " ";
			}
			cout << endl;
			return;
		}
	}
	
	cout << "AC" << endl;
}

signed main() {
	cin >> n;
	int i; rep(i, n) cin >> a[i];
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 9884
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
    int r;
    int g;
    int b;
    cin >> r >> g >> b;
    int number = r * 100 + g * 10 + b;
    if (number % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
li = lambda: list(map(int,input().split()))

n = int(input())
A = [li() for _ in range(n-1)]
c,s,f = [i for i in zip(*A)]
for k in range(n-1):
    t = s[k]+c[k]
    for i in range(k+1, n-1):
        if t < s[i]:
            t = s[i]
        else:
            t = -(-t//f[i]) * f[i]
        t += c[i]
    print(t)
print(0)

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, M;
int P[1100];
signed main() {
    while (true) {
        cin >> N >> M;
        if (N == 0) break;
        for (int i = 0; i < N; i++) cin >> P[i];
        P[N] = 0;
        vint half;
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                half.push_back(P[i] + P[j]);
            }
        }
        sort(half.begin(), half.end());
        int ans = 0;
        for (int i = 0; i < half.size(); i++) {
            auto it = upper_bound(half.begin(), half.end(), M - half[i]);
            if (it != half.begin()) {
                int cur = half[i] + *(it - 1);
                if (M - cur < M - ans) ans = cur;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 18972
import java.util.*;

public class Main {
	
	static long[] layer;
	
	public static void main(String args[]){
		Scanner sc= new Scanner (System.in);
		int n = sc.nextInt();
		long x = sc.nextLong();
		
		layer=new long [n];
		for(int i=0;i<n;i++){
			if(i==0)layer[i]=1;
			else layer[i]=layer[i-1]*2+3;
		}
		
		
		long ans = pati(n,x);
		
		
		
		System.out.println(ans);
		
		
	}
	
	
	public static long pati(int n, long x){
		if(n==0)return 1;
		else if(x<=1)return 0;
		else if(x<=1+layer[n-1])return pati(n-1,x-1);
		else if(layer[n-1]+2==x)return pati(n-1,x-2)+1;
		else if(x<2*layer[n-1]+2)return pati(n-1,layer[n-1])+1+pati(n-1,x-1-layer[n-1]-1);
		else return 2*pati(n-1,layer[n-1])+1;
		
		
	}

}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;


int main(){
  int k,n;
  cin >> k >> n;
  vector<int>a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  vector<int>b(n);
  rep(i,n){
    if(i == 0){
      b[0] = a[0] + (k - a[n-1]);
      continue;
    }
    b[i] = a[i] - a[i-1];
  }
  sort(b.begin(),b.end());
  cout << k - b[n-1] << endl;
  return 0;
}

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

void Main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        ans += (n-1) / i;
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3648
using System;

namespace abc049A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string A = Console.ReadLine();
            if (A == "a" || A == "i" || A == "u" || A == "e" || A == "o")
                Console.WriteLine("vowel");
            else
                Console.WriteLine("consonant");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string S; cin >> S;
	int len = S.length();
	string dupS = S;
	reverse(dupS.begin(),dupS.end());
	
	int counter = 0;
	
	for(int i=0;i<len;i++){
		if(S[i]==dupS[i]) continue;
		else counter++;
	}
	
	cout << counter/2;
	
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N,0);
  for (int i = 0; i < M; i++) {
    vector<int> road(2);
    cin >> road.at(0) >> road.at(1);
    ans.at(road.at(0)-1)+=1;
    ans.at(road.at(1)-1)+=1;
  }
  for (int i = 0; i < N; i++) {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n){
    cin>>a[i];
  }
  vector<ll>b(n+1),c(n+1);
  b[0]=0;
  stack<pair<ll,ll>> st;
  rep(i,n-1){
    ll cnt=0;
    ll tc=0;
    ll ta=a[i];
    while(ta<a[i+1]){
      ta<<=2;
      cnt+=2;
    }
    while(ta/4>=a[i+1]){
      ta>>=2;
      tc+=1;
    }
    if(a[i]<=a[i+1]){
      ll ts=0;
      pair<ll,ll>tp={1,0};
      ll cc=(i+1)*cnt;
      while(!st.empty()&&cc>=ts){
        tp=st.top();st.pop();
        ts+=tp.first*tp.second;
      }
      ts-=tp.first*tp.second;
      if((cc-ts)/tp.first<tp.second)st.push({tp.first,tp.second-((cc-ts)/tp.first)});

      ts+=min((cc-ts)/tp.first,tp.second)*tp.first;
      ll d=cc-ts;
      b[i+2]=b[i+1]+d;
    }
    else {
      b[i+2]=b[i+1];
      if(tc>0)st.push({(i+1)*2,tc});
    }

  }
  c[n]=0;
  c[n-1]=0;
  while(!st.empty())st.pop();
  rrepi(i,1,n){
    ll ta=a[i];
    ll cnt=0;
    ll tc=0;
    while(a[i-1]>ta){
      ta<<=2;
      cnt+=2;
    }
    while(a[i-1]<=ta/4){
      ta>>=2;
      tc+=1;
    }
    if(a[i-1]>=a[i]){
      ll ts=0;
      pair<ll,ll>tp={1,0};
      ll cc=(n-i)*cnt;
      while(!st.empty()&&cc>=ts){
        tp=st.top();st.pop();
        ts+=tp.first*tp.second;
      }
      ts-=tp.first*tp.second;
      if((cc-ts)/tp.first<tp.second)st.push({tp.first,tp.second-((cc-ts)/tp.first)});

      ts+=min((cc-ts)/tp.first,tp.second)*tp.first;
      ll d=cc-ts;
      c[i-1]=c[i]+d;
    }
    else {
      c[i-1]=c[i];
      if(tc>0)st.push({(n-i)*2,tc});
    }
  }
  ll res=1e17;
  rep(i,n+1){
    //cout<<b[i]<<" "<<c[i]<<endl;
    chmin(res,b[i]+i+c[i]);
  }
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 4992
def bingo(appear):
	for j in range(3):
		if appear[0][j] and appear[1][j] and appear[2][j]:
			return "Yes"
	for i in range(3):
		if appear[i][0] and appear[i][1] and appear[i][2]:
			return "Yes"
	if appear[0][0] and appear[1][1] and appear[2][2]:
		return "Yes"
	if appear[0][2] and appear[1][1] and appear[2][0]:
		return "Yes"
	return "No"


card = []
for _ in range(3):
	arr = list(map(int, input().split()))
	card.append(arr)
appear = [[False for _ in range(3)] for _ in range(3)]
n = int(input())
for _ in range(n):
	a = int(input())
	for i in range(3):
		for j in range(3):
			if a == card[i][j]:
				appear[i][j] = True

print(bingo(appear))

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define int long long
#define MAX_V 1000
#define N MAX_V
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

/*?????§?????¢?????´?????????(Ford_Fulerson????????¨)???O(F|E|)*/

//????????¨????§???????(???????????????????????????)
struct edge{int to, cap, rev;};

vector<edge> G[MAX_V]; //??°???????????£??\?????????
bool used[MAX_V];      //DFS??§?????§??????????????????????????°

//from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from,int to,int cap=1){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});  
}

//?¢?????????????DFS??§??¢???
int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  for(int i=0; i<G[v].size() ;i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to ,t , min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

//s??????t???????????§???????±???????
int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

signed main(){

  int cnt = 0;

  while(1){
    cnt ++;
    int H, W, C, M, N_W, N_C, N_M;
    cin >>H>>W>>C>>M>>N_W>> N_C>>N_M;
    if(H==-1) return 0;
    for(int i=0;i<N;i++)G[i].clear();
    
    const int S = N-1, T = S-1;
    const int NW = H+W+C+M, NC = NW+1, NM = NC+1;
    const int of = 500; //ofset
    
    add_edge(NW,of+NW,N_W);
    add_edge(NC,of+NC,N_C);
    add_edge(NM,of+NM,N_M);
    for(int i=0;i<H;i++) add_edge(i,of+i); //hero
    for(int i=0;i<W;i++) add_edge(H+i,of+H+i); // warriror
    for(int i=0;i<C;i++) add_edge(H+W+i,of+H+W+i); // Cleric
    for(int i=0;i<M;i++) add_edge(H+W+C+i,of+H+W+C+i); //Mage
  
    
    for(int i=0;i<H;i++) add_edge(S,i); // S -> Hero

    
    for(int i=0;i<H;i++) add_edge(of+i,NW); // Hero -> no warrior
    for(int i=0,k;i<W;i++){
      cin>>k;
      for(int j=0,a;j<k;j++) {
        cin>>a; a--;
        add_edge(of+a,H+i); // hero -> warrior
      }
    }

    
    for(int i=0;i<W;i++) add_edge(of+H+i,NC); // warrior -> no cleric
    for(int i=0;i<C;i++) add_edge(of+NW,H+W+i); // no warrior -> cleric
    for(int i=0,k;i<C;i++){
      cin>>k;
      for(int j=0,a;j<k;j++){
        cin>>a,a--;
        add_edge(of+H+a,H+W+i); // warrior -> cleric 
      }
    }

    
    for(int i=0;i<C;i++) add_edge(of+H+W+i,NM); // cleric -> no mage
    for(int i=0;i<M;i++) add_edge(of+NC,H+W+C+i); // no cleric -> mage   
    for(int i=0,k;i<M;i++){
      cin>>k;
      for(int j=0,a;j<k;j++){
        cin>>a;a--;
        add_edge(of+H+W+a,H+W+C+i); // cleric -> mage
      }
    }

    add_edge(of+NM,T,N_M);//no mage -> T 
    for(int i=0;i<M;i++) add_edge(of+H+W+C+i,T); // mage -> T
    cout<<max_flow(S,T)<<endl;
  }

  return 0;
}

Measured memory_bytes: 3696
class SearchableBIT():
    def __init__(self,size):
        self.size=size
        self.data=[0]*(size+1)
        self.cnt=0
    def add(self,a):
        x=a
        self.cnt+=1
        while x<=self.size:
            self.data[x]+=1
            x+=x&-x
    def delete(self,x):
        self.cnt-=1
        while x<=self.size:
            self.data[x]-=1
            x+=x&-x
    def count(self,x):
        ret=0
        while x>0:
            ret+=self.data[x]
            x-=x&-x
        return ret
    def get_lower_i(self,i):
        ng=-1
        ok=self.size+1
        while ok-ng>1:
            mid=(ok+ng)//2
            if self.count(mid)>=i:
                ok=mid
            else:
                ng=mid
        return ok

n=int(input())
P=list(map(int,input().split()))
Idx=[0]*(n+1)
for i,p in enumerate(P):
    Idx[p]=i+1
BIT=SearchableBIT(n)
ans=0
for i in reversed(range(1,n+1)):
    idx=Idx[i]
    BIT.add(idx)
    cnt=BIT.count(idx)
    l_idx1=BIT.get_lower_i(cnt-1)
    l_idx2=BIT.get_lower_i(cnt-2)
    r_idx1=BIT.get_lower_i(cnt+1)
    r_idx2=BIT.get_lower_i(cnt+2)
    l1=idx-l_idx1
    l2=l_idx1-l_idx2
    r1=r_idx1-idx
    r2=r_idx2-r_idx1
    if r_idx1!=n+1:
        ans+=i*l1*r2
    if l_idx1!=0:
        ans+=i*l2*r1
print(ans)

Measured memory_bytes: 58220
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
S = str(input())

dp = [0]*(N+1)
temp = 0
for i in range(N):
    if S[i] == '.':
        temp += 1

dp[0] = temp

for i in range(1,N+1):
    if S[i-1] == '.':
        dp[i] = dp[i-1]-1
    else:
        dp[i] = dp[i-1]+1

print(min(dp))

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

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference, debug statements can also cause TLE.
//priority_queue implements max heap by default

int main(){
    fastio;
    // think about edge cases like n=1(especially graph questions).
    int k;
    cin>>k;
    ll tmp = 7;
    if(k%2 == 0){
        cout<<-1;
        return 0;
    }
    string ans = "7";
    int cnt = 1;
    while(1){
        if(tmp%k == 0){
            break;
        }
        if(ans.size()>7*k){
            cout<<-1;
            return 0;
        }
        tmp = ((tmp * 10)+7)%k;
        ans += "7";
    }
    cout<<ans.size();
    return 0;
}

Measured memory_bytes: 10728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, R;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> R;
    cout << (N >= 10 ? R : R + 100 * (10 - N)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

#define MAX_N 410

// 全対全の距離を求める N^3
int n;
int d[MAX_N][MAX_N]; // i->jのコスト あらかじめINF初期化してから入力を反映させる
void warshall_floyd() { 
    for (int k=0; k<n; k++)
        for (int i=0; i<n; i++)
            for (int j=0; j<n; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

using P = pair<int, int>;
#define fi first
#define se second

#include <map>
#include <set>
// vecのなかの全要素について座標圧縮を行い、元座標->圧縮後座標というmapを作る
// O(NlogN) 座圧後のサイズを返す
// org: もともとの各iに対する座標 値渡しなので破壊しません
// zip: 圧縮
// unzip: 復元
template <typename T>
int compress(vector<T> org, map<T, int> &zip, vector<T> &unzip) {
    sort(org.begin(), org.end()); 
    org.erase(unique(org.begin(), org.end()), org.end()); // vecの各要素を小さい順に重複を無くして並べたもの
    int i = 0;
    for (auto &oi : org) {
        zip[oi] = i;
        unzip.push_back(oi);
        i++;
    }
    return i;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<P> roads;
    for (int i=0; i<h; i++) {
        string s;
        cin >> s;
        for (int j=0; j<w; j++) {
            if (s[j] == '.') roads.push_back(P{i, j});
        }
    }
    map<P, int> zip;
    vector<P> unzip;
    int m = compress(roads, zip, unzip);
    n = m;
    fill(d[0], d[MAX_N], MAX_N);
    for (int i=0; i<m; i++) d[i][i] = 0;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (!zip.count(P{i, j})) continue;
            int x = zip[P{i, j}], y;
            if (zip.count(P{i, j+1})) {
                y = zip[P{i, j+1}];
                d[x][y] = 1;
            }
            if (zip.count(P{i, j-1})) {
                y = zip[P{i, j-1}];
                d[x][y] = 1;
            }
            if (zip.count(P{i+1, j})) {
                y = zip[P{i+1, j}];
                d[x][y] = 1;
            }
            if (zip.count(P{i-1, j})) {
                y = zip[P{i-1, j}];
                d[x][y] = 1;
            }
        }
    }
    warshall_floyd();
    int ans = 0;
    for (int i=0; i<m; i++) {
        for (int j=0; j<i; j++) {
            ans = max(ans, d[i][j]);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
int main(){
    
    int t = 0;
    std::cin >> t;
    
    if(t == 1){
        
     std::cout << "Hello World" << std::endl;   
        
    }else if(t == 2){
        
        int n = 0,m = 0;
        std::cin >> n >> m;
        std::cout << n+m << std::endl;
        
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
const int MOD = 1e9+7;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept { return this->val == r.val; }
    constexpr bool operator != (const Fp& r) const noexcept { return this->val != r.val; }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept { return os << x.val; }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

const int MAX = 2e6 + 500;
mint fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i;
    inv[i] = -inv[MOD%i] * (MOD / i);
    finv[i] = finv[i - 1] * inv[i];
  }
}

mint f(int r, int c) {
  return fac[r+c] * finv[r] * finv[c];
}

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  comb_init();

  mint ans = f(r2+1, c2+1) - f(r2+1, c1) - f(r1, c2+1) + f(r1, c1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 47104
//author-Abhijit Dey
//Welcome to my code. btw I hate coding 😉




#include <bits/stdc++.h>
using namespace std;
#define     ff first
#define     ss second
#define     pb push_back
#define     mp make_pair
#define     INF 1000000005
#define     MOD 1000000007
#define     ninf -1000000000
#define     all(c) c.begin(), c.end()
#define     tinput long long int t;cin>>t;
#define     mem(a,x) memset(a,x,sizeof a)
#define     for0(i,n) for(long long int i=0;i<n;i++)
#define     pi 3.141592653589793238462643383279502884
#define     fori(i,a,n) for(long long int i=a;i<n;i++)
#define     forxy(i,x,y) for(int i=x;i<=y;i++)
#define     rfor(i,n) for(long long int i=n-1;i>=0;i--)
#define     ainput for(int i=0; i<n; i++) cin>>a[i];
#define     fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);




typedef     long long int ll;
typedef     vector<long long int>vll;
typedef     vector<vector<int> >vvll;
typedef     pair<long long int,long long int>pr;
typedef     vector<pair<long long int,long long int> >vp;





inline long long  min2(long long  a, long long  b)  {return (a)<(b)?(a):(b);}
inline long long  max2(long long  a, long long  b)  {return (a)>(b)?(a):(b);}
inline long long  max3(long long  a, long long  b, long long  c)    {return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  min3(long long  a, long long  b, long long  c)    {return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std::chrono;
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){if(x<0 or y<0)return false;else if(x>=n or y>=m)return false;else return true;}

void process()
{
    ll n;cin>>n;
    string s;cin>>s;
    ll rc=0,ans=0;
    for(ll i=0;i<n;i++)if(s[i]=='R')rc++;
    for(ll i=0;i<rc;i++)if(s[i]=='W')ans++;
        cout<<ans<<endl;
}
int main()
{
    fastio;
    //tinput;
    //while(t--)
        process();
}

Measured memory_bytes: 3768
#ONE TRUTH PREVAILS
import sys
A,B=map(int,input().split())
if(B%2!=0):
    print("No")
    exit()
y=B-(2*A)
if y%2 or y<0:
    print("No")
    exit()
y=y//2
x=A-y
if x<0:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 61776