akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

int ex(int n,ll x){
    if(n==0)return x;
    ex(n-1,(2*x)%MOD);
}

int main(){
    
    ll n,a,cnt[100000]={},ans,flag=0;
    
    cin>>n;
    rep(i,0,n){
        cin>>a;
        cnt[a]++;
    }
    if(n%2==0){
        rep(i,0,n/2){
            if(cnt[2*i+1]!=2){
                ans=0;
                flag=1;
                break;
            }
        }
        if(!flag)ans=ex(n/2,1);
    }
    else{
        rep(i,0,n/2+1){
            if(i==0){
                if(cnt[0]!=1){
                    ans=0;
                    flag=1;
                    break;
                }
            }
            else{
                if(cnt[2*i]!=2){
                    ans=0;
                    flag=1;
                    break;
                }
            }
        }
        if(!flag)ans=ex(n/2,1);
    }
    cout<<ans<<endl;
    
    return 0;
    
}

Measured memory_bytes: 1152
#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>
// using namespace __gnu_pdbs;
using namespace std;

// typedef tree<int, null_type, less<int>, rb_tree_tag,  
//             tree_order_statistics_node_update>  
//     ordered_set;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve()
{
	ll a, b, c;
	cin>>a>>b>>c;
	swap(a, b);
	swap(a, c);
	cout<<a<<" "<<b<<" "<<c<<endl;
}
int main()
{
	fastio();
	// citc(tc)
		solve();
}


Measured memory_bytes: 256
S = input()
li = [0] * len(S)
cnt = [0] * 2
for ind,s in enumerate(S):
    if(s=='R'):
        if(ind%2==0):
            cnt[0]+=1
        else:
            cnt[1]+=1
    elif(s=='L'):
        if(ind%2==0):
            li[ind] += cnt[0]
            li[ind-1] += cnt[1]
        else:
            li[ind-1] += cnt[0]
            li[ind] += cnt[1]
        cnt[0] = 0
        cnt[1] = 0

cnt[0] = 0
cnt[1] = 0
for ind,s in enumerate(S[::-1]):
    ind = len(S)-1-ind
    if(s=='L'):
        if(ind%2==0):
            cnt[0]+=1
        else:
            cnt[1]+=1
    elif(s=='R'):
        if(ind%2==0):
            li[ind] += cnt[0]
            li[ind+1] += cnt[1]
        else:
            li[ind+1] += cnt[0]
            li[ind] += cnt[1]
        cnt[0] = 0
        cnt[1] = 0
print(*li)


Measured memory_bytes: 6512
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << (((a < c && c < b) || (b < c && c < a))? "Yes" : "No") << endl;
}


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

int main()
{
	string s;
	long long n = 0, m = 0;

	cin >> s;

	for (long long i = 0; i < s.size(); i++) {
		if (s[i] == 'W') {
			n++;
			m += i;
		}
	}
	
	cout << m - (n * (n - 1)) / 2 << endl;

	return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    A = [[int(i) for i in input().split()] for j in range(N-1)]
    for i in range(N-1):
        ans = 0
        for j in range(i, N-1):
            if ans < A[j][1]:
                ans = A[j][1]
            elif A[j][1] < ans and ans % A[j][2] != 0:
                ans += A[j][2] - (ans % A[j][2])
            ans += A[j][0]
        print(ans)
    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41964
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std ;
inline LL read() {
	LL x = 0 , f = 1 ;
	char ch = getchar() ;
	while(ch<'0'||ch>'9') { if(ch=='-') f = -1 ; ch = getchar() ; }
	while(ch>='0'&&ch<='9') { x = x * 10+ch-48 ; ch = getchar() ; }
	return x * f ;
}

const int N = 1e5+11;
int n;
LL a[N],ans,x;

inline LL gcd(LL x,LL y) {
	if(!y) return x;
	return gcd(y, x%y);
}

inline LL lcm(LL x,LL y) {
	return x/gcd(x,y)*y;
}

int main() {
	n=read();
	For(i, 1, n) a[i]=read();
	ans = a[1];
	For(i, 2, n) 
		ans=lcm(ans,a[i]);
	printf("%lld\n",ans);
}









Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int c[3][3];
	for (int col=0; col<3; col++)
		scanf ("%d %d %d", c[col], c[col]+1, c[col]+2);
	int a[3], b[3];
	a[0] = 0;
	for (int i=0; i<3; i++)
		b[i] = c[0][i];
	for (int i=1; i<3; i++)
		a[i] = c[i][0] - b[0];
	int flag=1;
	for (int col=1; col<3; col++)
		for (int row=1; row<3; row++)
			if (c[col][row]!=a[col]+b[row])
				flag = 0;
	if (flag)
		printf ("Yes\n");
	else
		printf ("No\n");
	return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s1, s2;
	cin >> s1 >> s2;
	vector<int> a;
	for (int i = 0; i < n;) {
		if (s1[i] == s2[i]) {
			a.push_back(1);
			i++;
		} else {
			a.push_back(0);
			i += 2;
		}
	}

	ll ans = (a[0] == 1 ? 3 : 6);
	for (int i = 1; i < a.size(); i++) {
		if (a[i] == 1) {
			if (a[i - 1] == 1) {
				(ans *= 2) %= MOD;
			}
		} else {
			if (a[i - 1] == 1) {
				(ans *= 2) %= MOD;
			} else {
				(ans *= 3) %= MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import itertools

class RSQ:
    def __init__(self, n):
        self.sz = 1
        self.inf = (1 << 31) - 1
        while self.sz <= n: self.sz = self.sz << 1
        self.dat = [0] * (2 * self.sz - 1)
    
    def update(self, idx, x):
        idx += self.sz - 1
        self.dat[idx] += x
        while idx > 0:
            idx = (idx - 1) >> 1
            self.dat[idx] += x
            
    def query(self, a, b):
        return self.query_help(a, b, 0, 0, self.sz)
            
    def query_help(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.dat[k]
        else:
            return self.query_help(a, b, 2 * k + 1, l, (l + r)>>1) + \
                    self.query_help(a, b, 2 * k + 2, (l + r) >> 1, r)
    
    
if __name__ == '__main__':
    line = sys.stdin.readline()
    n, q = line.split()
    n, q = int(n), int(q)
    rmq = RSQ(n)
    
    for i in range(q):
        line = sys.stdin.readline()
        op, a, b = line.split()
        op, a, b = int(op), int(a), int(b)
        if op == 0: 
            rmq.update(a, b)
        else: 
            sys.stdout.write(str(rmq.query(a, b + 1)) + '\n')
    

Measured memory_bytes: 11948
def total(a):
    sumnum = 0
    for i in range(len(str(a))):
        sumnum += int(str(a)[i])
    return sumnum

N = int(input())

S = []
for i in range(int(N / 2)):
    num = N - i - 1
    S.append(total(i + 1) + total(num))
print(min(S))


Measured memory_bytes: 3480
#!/usr/bin/env python3
import sys

N = int(input())
A = list(map(int, input().split()))

S = N*(N+1) // 2
SA = sum(A)

if SA % S != 0:
    print("NO")
    sys.exit(0)

K = SA // S

# B = []
C = []
for i in range(N):
    # B.append(A[i] - A[i-1] - K)
    b = A[i] - A[i-1] - K
    if (b > 0) or (-b % N != 0):
        print("NO")
        sys.exit(0)
    C.append(-b//N)

print("YES")


Measured memory_bytes: 63728
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	#N, K = map(int, input().split(" "))
	S = input()
	S = S[:-1]
	S = list(S)

	fst_han = 0
	fst_str = S[:2]
	tmp = ""
	for i in fst_str:
		tmp += i
	fst = int(tmp)

	snd_han = 0
	snd_str = S[2:]
	tmp = ""
	for i in snd_str:
		tmp += i
	snd = int(tmp)

	if fst > 0 and fst < 13:
		fst_han = 1
	if snd > 0 and snd < 13:
		snd_han = 1
	
	if fst_han == 1 and snd_han == 1:
		print("AMBIGUOUS")
	elif fst_han == 1 and snd_han == 0:
		print("MMYY")
	elif fst_han == 0 and snd_han == 1:
		print("YYMM")
	else:
		print("NA")
	#print("{} {}".format(fst, snd))

		

if __name__ == "__main__":
	main()

Measured memory_bytes: 3700
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        l: u32,
        r: u32,
    }

    let mut ans = 2020;
    'outer: for i in l..r {
        if i % 2019 == l % 2019 && i != l {
            break;
        }
        for j in l + 1..r + 1 {
            if j % 2019 == (l + 1) % 2019 && j != (l + 1) {
                break;
            }
            ans = ans.min(((i % 2019) * (j % 2019)) % 2019);
            if ans == 0 {
                break 'outer;
            }
        }
    }
    println!("{}", ans);
}


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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++){
        cin >> X.at(i);
    }
    vector<int> Y(N);
    for(int i = 0; i < N; i++){
        cin >> Y.at(i);
    }

    vector<int> A(N);
    for(int i = 0; i < N; i++){
        A.at(i) = X.at(i) - Y.at(i);
    }

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

    int answer = 0;

    for(int i = 0; i < N; i++){
        if(A.at(i) > 0){
            answer += A.at(i);
        }
    }

    cout << answer << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, M;
  cin >> N >> M;
  int64_t x = N;
  int64_t y = M/2;
  if(x >= y){
    cout << y << endl;
  }
  else{
    cout << x + (y - x)/2 << endl;
  }
}

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

struct UnionFind {
  int n;
  vector<int> par, depth;

  UnionFind(int n) {
    par.resize(n);
    depth.resize(n);
    rep(i, n) par[i]=i;
  }
  
  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 (depth[x] < depth[y]) par[x] = y;
    else {
      par[y] = x;
      if (depth[x] == depth[y]) depth[x]++;
    }
  }

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


int main() {
  int n,m; cin>>n>>m;
  vector<int> p(n);
  rep(i, n) {
    cin>>p[i];
    p[i]--;
  }
  vector<int> x(m),y(m);
  rep(i, m) {
    cin>>x[i]>>y[i];
    x[i]--; y[i]--;
  }

  UnionFind uf(n);
  rep(i, m) uf.unite(x[i], y[i]);
  int sum=0;
  rep(i, n) {
    if (uf.same(i, p[i])) sum++;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 2176
n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
sl = []
for i in range(n):
    sl.append(int(input()))

total = sum(sl)
sl.sort()

if total % 10 == 0:
    ans = 0
    for i in range(n):
        if sl[i]%10!=0:
            ans=total-sl[i]
            break
else:
    ans = total
print(ans)


Measured memory_bytes: 9116
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	ll cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		if (to_string(i).length() % 2 != 0)
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}

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

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { 1, 0, -1, 0};
const int dy[4] = { 0, 1, 0, -1};

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x, y;
	cin >> x >> y;

	cout << gcd(x, y) << "\n";
	return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
int main(){
  
    char s[9];
    int i,c=0;
    scanf("%s",s);
  
    for(i=0;i<3;i++){
     if(s[i]=='1'){
       c+=1;
     }
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>
#include <stdlib.h>
#define M 2000001
#define X 10001

int main(){
  unsigned short *A, *B;

  int C[X];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for ( i = 0; i <= X; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]+=1;
  }

  for ( i = 1; i <= X; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]-=1;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

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

char S[100000*2][12];

int comp(const void* a, const void* b){
    return strcmp(S[*(int*)a], S[*(int*)b]);
}

int main(void){
    int N;
    int i;
    scanf("%d", &N);
    for(i=0;i<N;i++){
        scanf("%11s", S[i]);
    }
    int a[100000*2];
    for(i=0;i<N;i++){
        a[i]=i;
    }

    qsort(a, N, sizeof(int), comp);

    int ans = 1;
    for(i=1;i<N;i++){
        if(strcmp(S[a[i-1]], S[a[i]]) != 0){
            ans++;
        }
    }
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }




int main(){
    ll n;
    cin>>n;
    ll p=1;
    n-=1;
    while(n>0){
        if(n>=powl(26,p)){n-=powl(26,p);p++;}
        else break;
    }
    ll st=0;

    char x[1000];
    while(p>0){
        ll z=n%26;
        x[st]=(z+'a');
        n=(n-z)/26;
        st++;
        p--;
    }
    irep(i,st-1,0){
       cout<<char(x[i]);
        
    }
}



Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iterator>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i, a, cont, next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i, a, b, step) repfn(i, a, i < b, i + step)
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int w, n, a, b;
  char c;
  vi v;

  cin >> w;
  rep (i, w + 1) {
    v.pb(i);
  }

  cin >> n;
  while (n--) {
    cin >> a >> c >> b;
    swap(v[a], v[b]);
  }
  repab (i, 1, w + 1) {
    cout << v[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1212
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#pragma endregion

int main() {
    // AtCoder
    // template
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    vector<vector<ll>> r(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        r.at(a - 1).push_back(b - 1);
        r.at(b - 1).push_back(a - 1);
    }
    ll ans = 0;
    rep(i, n) {
        bool flag = true;
        rep(j, r.at(i).size()) {
            if(h.at(i) <= h.at(r.at(i).at(j)))
                flag = false;
        }
        if(flag)
            ans++;
    }
    cout << ans << endl;
}


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

long long calcNum_k(long long N,long long k){
    long long num = N*(N+1)/2-(N-k)*(N-k+1)/2-(k-1)*k/2+1;
    // cout<<num<<endl;
    return num;
}

int main(){
    int N,K;
    cin>>N>>K;
    long long ans = 0;
    for(long long i=K;i<=N+1;i++){
        ans += calcNum_k(N,i);
        if(ans>(long long)(pow(10,9)+7)) ans = ans%(long long)(pow(10,9)+7);
    }
    cout<<ans<<endl;
}

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



int main(){
  string s;
  cin >> s;
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int ans = 0;
  int memo = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H.at(i) >= H.at(i + 1)) {
      memo++;
    }
    else {
      ans = max(ans, memo);
      memo = 0;
    }
    if (i == N - 2) {
      ans = max(ans, memo);
    }
  }
  cout << ans << endl;   
}

Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
h = list(map(int,input().split()))
if n<=k+1:
    print(abs(h[n-1]-h[0]))
    exit()
dp = [0 for j in range(n)]
for i in range(1,k+1):
    dp[i] = abs(h[i]-h[0])
for i in range(k+1,n):
    a = []
    for j in range(i-k,i):
        a.append(dp[j] + abs(h[i]-h[j]))
    dp[i] = min(a)
print(dp[n-1])

Measured memory_bytes: 56544
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

ll getDivisor(ll n) {
    vector<ll> v;
    ll size = 0;
    for (ll i = 1; i*i <= n; i++) {
        if (n%i == 0) {
            v.push_back(i); size++;
            if (i != n/i) {
                v.push_back(n/i); size++;
            }
        }
    }
    return size;
}

int main() {
    ll n;
    cin >> n;
    ll cnt = 0;
    for (int i = 1; i <= n; i += 2) {
        if (getDivisor(i) == 8) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
import math

eps = 10**(-9)

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    circles = []
    C = []
    for _ in range(N):
        x, y, c = map(int, input().split())
        circles.append(Circle(Vector(x, y), c))
        C.append(c)

    def calc_meet(t):
        '''t秒後に焼ける肉の数の最大値を求める。
        '''
        # 候補点の列挙(交点と中心)
        candidates = []
        for i in range(N):
            candidates.append(circles[i].c)
            circles[i].r = t/C[i]
            for j in range(i+1, N):
                circles[j].r = t/C[j]
                candidates += circles[i].cp(circles[j])

        # t秒で焼ける肉の数の最大値を調べる
        m = 0
        for c in candidates:
            count = 0
            for i, meet in enumerate(circles):
                if (c - meet.c).length() * C[i] <= t + eps: count += 1
            m = max(m, count)

        return m

    under = 0
    r = 10**6
    while r-under>10**(-6):
        m = (r + under) / 2
        if calc_meet(m) >= K: r = m
        else: under = m
    print(r)
    
class Circle:
    def __init__(self, c, r):
        self.c, self.r = c, r
    
    def cp(self, other):
        v = other.c - self.c
        d = v.length()
        equal = lambda x,y: abs(x-y) < eps
        if equal(d, 0): return []
        if equal(sum([d, self.r, other.r]), 2 * max(d, self.r, other.r)):
            return [self.c + v*(self.r/d)]
        if sum([d, self.r, other.r]) < 2 * max(d, self.r, other.r): return [] #三角形ができない
        x = (d*d + self.r*self.r - other.r*other.r) / (2*d)
        h = math.sqrt(self.r*self.r - x*x)
        m = self.c + v*(x/d)
        return [m + v.rotate90()*(h/d), m - v.rotate90()*(h/d)]

class Vector:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def length(self): return math.sqrt(self.x*self.x + self.y*self.y)
    def rotate90(self): return Vector(self.y, -self.x)

    def __iadd__(self, other):
        self.x += other.x
        self.y += other.y
        return self
    def __add__(self, other):
        new_obj = Vector(self.x, self.y)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.x -= other.x
        self.y -= other.y
        return self
    def __sub__(self, other):
        new_obj = Vector(self.x, self.y)
        new_obj -= other
        return new_obj

    def __imul__(self, other_scalar):
        self.x *= other_scalar
        self.y *= other_scalar
        return self
    def __mul__(self, other_scalar):
        new_obj = Vector(self.x, self.y)
        new_obj *= other_scalar
        return new_obj

if __name__ == '__main__':
    main()

Measured memory_bytes: 79832
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a);
        a = (a*a);
        b >>= 1;
    }
    return prod;
}
int main()
{
    // debug(power(0 , 2));
    ll x;
    cin >> x;

    if(x == 0){
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    for(ll i = 0 ; i <= 100 ; i++){
        for(ll j = 0 ; j <= 100 ; j++){
            if(power(i , 5) + power(j , 5) == x){
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }

    for(ll i = 0 ; i <= 1000 ; i++){
        for(ll j = 0 ; j <= i ; j++){
            ll num = i - j;

            ll num2 = power(i , 4) + power(i , 3)*power(j , 1) + power(i , 2) * power(j , 2) + power(i , 1)*power(j , 3) + power(j , 4);

            if(num == 0 || num2 == 0)continue;
            if(x%num == 0 && x%num2 == 0 && num*num2 == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    
    return 0;
}

Measured memory_bytes: 3636
"""
DFS
"""
from collections import defaultdict
N,M = map(int, input().split())
pairs = []
for i in range(M):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    pairs.append((a,b))


def dfs(s):
    global visited,edges
    if visited[s]:return 0
    visited[s] = True
    ns = edges[s]
    for n in ns:
        dfs(n)
    
    
ans = 0  
for i in range(M):
    edges = defaultdict(list)
    visited = [False] * N
    for j,(a,b) in enumerate(pairs):
        if i == j: continue
        edges[b].append(a)
        edges[a].append(b)
    dfs(0)
    if sum(visited) != N:
        ans += 1
print(ans)

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

int main()
{
	char c;
  set<char> ch;
  for(int i=0;i<4;i++)
  {
    cin>>c;
    ch.insert(c);
  }
  if(ch.size()==2)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
n = int(input())
A, B, C = [], [], []
for i in range(n):
	a, b, c = map(int, input().split())
	A.append(a)
	B.append(b)
	C.append(c)

dp = [[0] * 3 for _ in range(n)]
dp[0] = [A[0], B[0], C[0]]

for i in range(n - 1):
	dp[i + 1][0] = max(dp[i][1] + A[i + 1], dp[i][2] + A[i + 1])
	dp[i + 1][1] = max(dp[i][2] + B[i + 1], dp[i][0] + B[i + 1])
	dp[i + 1][2] = max(dp[i][0] + C[i + 1], dp[i][1] + C[i + 1])

print(max(dp[-1]))

Measured memory_bytes: 78296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
        cout << 1 << endl;
    else if ((w * h) % 2 == 0)
        cout << (h * w) / 2 << endl;
    else
        cout << h * (w / 2) + (h + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

void solve (void)
{
  string s1,s2;
  cin>>s1;
  cin>>s2;
  string s3 = s2.substr(0,s1.size());
  if(s1 == s3)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  return; 
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 3600
use std::io::prelude::*;
fn main() {
    
    let scan = std::io::stdin();
    
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let w = line.trim();

    let mut count: u32 = 0;
    for line in scan.lock().lines() {
        let uline = line.unwrap();
        let vec: Vec<&str> = uline.split_whitespace().collect(); 
        if vec[0] == "END_OF_TEXT" {
            break;
        }
        for e in vec {
            if e.to_lowercase() == w {
                count += 1;
            }
        }
    }
    println!("{}", count);
}



Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
 
    int main() {
        int N,M;
        cin >> N >> M;
        vector<int> H(N);
        for(int i=0;i<N;i++) cin >> H.at(i);
        vector<int> A(M);
        vector<int> B(M);
        for(int i=0;i<M;i++) cin >> A.at(i) >> B.at(i);
        vector<int> C(N,0);
        for(int i=0;i<M;i++){
            if(H.at(A.at(i)-1)>H.at(B.at(i)-1)) C.at(B.at(i)-1)++;
            else if(H.at(A.at(i)-1)<H.at(B.at(i)-1)) C.at(A.at(i)-1)++;
            else {
                C.at(A.at(i)-1)++;
                C.at(B.at(i)-1)++;
            }
        }
        int count=0;
        for(int i=0;i<N;i++){
            if(C.at(i)==0)count++;
        }
        cout << count << endl;
    }
  

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

int a, n, mn = INF, res = 0, cnt = 0;
string s, t;
main(){
    INCANT;
    in(n);
    while(n--){
        in(a);
        chmin(mn, abs(a));
        res += abs(a);
        if(a < 0){
            cnt++;
        }
    }
    if(cnt % 2){
        print(res - 2 * mn);
    }else{
        print(res);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf          0x3f3f3f3f
#define go(a,b,c)    for(int a=b;a<=c;a++)
#define gov(a,b)     for(int a=0;a<b.size();a++)
#define rgo(a,b,c)   for(int a=b;a>=c;a--)
#define sf(a)        scanf("%d",&a)
#define sff(a,b)     scanf("%d%d",&a,&b)
#define sfff(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define eps          1e-9
#define ft           first
#define sd           second
#define prt(a)       printf("%d\n",a)
#define prn(i,n,a)   printf("%d%c",a,i==n?'\n':' ')
#define pb           push_back
typedef long long LL;
typedef pair<int,int> pii;
typedef set<int> si;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef double db;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int maxn=1e5+10;
const LL mod=1e9+7;
int read()
{
	int f=0,x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
//=======================================================
int n,m,rm[maxn],vis[maxn];
vi v[maxn],ans;
deque<int> dq;
void ini()
{
	dq.clear(); 
	ans.clear();
	go(i,0,n)v[i].clear();
	memset(vis,0,sizeof(vis));
	memset(rm,0,sizeof(rm));
}
/*
void solve(vi p)
{
	if(p.size()==0)dfs(1);
	else dfs2(p[0]);
}
*/
void work()
{
	ini(); 
	go(i,1,m)
	{
		int a,b;
		sff(a,b);
		rm[a]++;
		rm[b]++;
		v[a].pb(b);
		v[b].pb(a);
	}
	dq.pb(1);
	vis[1]=1;
	while(1)
	{
		int flag=1;
		int t1=dq.back(),t2=dq.front();
		gov(i,v[t1])
		if(!vis[v[t1][i]])
		{
			dq.pb(v[t1][i]);
			vis[v[t1][i]]=1;
			flag=0;
			break;
		}
		gov(i,v[t2])
		if(!vis[v[t2][i]])
		{
			dq.push_front(v[t2][i]);
			vis[v[t2][i]]=1;
			flag=0;
			break;
		}
		if(flag)break;
	}
	prt((int)dq.size());
	gov(i,dq)prn(i,(int)dq.size()-1,dq[i]);
}
int main()
{
	while(~sff(n,m))
	{
		work();	
	}	
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  
  int right=0;
  int sum=0;
  ll ans=0;
  rep(left,n){
    while(right<n && ((sum+a[right])==(sum^a[right]))){
      sum+=a[right];
      right++;
    }
    
    ans+=(ll)(right-left);
    
    if(right==left) right++;
    else sum-=a[left];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    cout << (1000-n%1000)%1000 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,c=0;
    cin>>n;
    a=n/2;
    //if(n%2!=0) a+=1;
    for(int i=1;i<=a;i++){
        int j=n-i;
        if(j!=i) c++;
    }
    cout<<c<<endl;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> v(n);
    for (auto &it : v) cin >> it;
    long long ans = 0;
    for (int i = 0; i < n-1; i++) {
        if (v[i+1] < v[i]) {
            ans += v[i] - v[i+1];
            v[i+1] = v[i];
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3948
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int INF = 100000000;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> node(n+1);
	for(int i=0;i<n;i++){
		int u,k,tmp;
		cin >> u >> k;
		for(int j=0;j<k;j++){
			cin >> tmp;
			node[u].push_back(tmp);
		}
	}
	
	//search
	vector<int> res(n+1,INF);
	queue<int> que;
	queue<int> copied;
	queue<int> zeros;
	que.push(1);
	
	int count = 0;
	for(int i=0;i<n;i++){
		while(que.size()){
			int k = que.front(); que.pop();
			//cout << "-> " << k << endl;
			if(res[k] >= INF) res[k] = count;
			for(int v:node[k]){
				if(res[v] >= INF) copied.push(v);
			}
		}
		count++;
		que = queue<int>(copied);
		copied = queue<int>(zeros);
	}

	//output
	for(int i=1;i<=n;i++){
		if(res[i] >= INF) res[i] = -1;
		cout << i << " " << res[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3288
/* ex3_2
   kento_titech*/
#include<stdio.h>
int main(void){
    int N,K;//N,K,iを変数とする
    int i=0;
    scanf("%d %d",&N,&K);
    while(1){
        N=N/K;
        ++i;//１回割れるごとにiのカウンターを1足す
         if(N==0){//商が0になるまでN/Kをする
            break;
        }
    }
    printf("%d\n",i);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
int cnt ;
int H,W;
bool flag;
char board[10][10];
void dfs(int i, int j, int dfsCnt){
  if(dfsCnt == cnt){
    flag = true;
  }
  if(i+1 < H && board[i+1][j] == '#'){
    dfs(i+1,j,dfsCnt+1);
  }

  if(j+1 < W && board[i][j+1] == '#'){
    dfs(i,j+1,dfsCnt+1);
  }
  return;
}
int main(){
  cin >> H >> W;

  rep(i,H)rep(j,W){
    cin >> board[i][j];
  }

  rep(i,H)rep(j,W){
    if(board[i][j] == '#') cnt ++;
  }

  dfs(0,0,1);
  if(flag)cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int x=0;x<n;++x){
		int from,to;
		cin>>from>>to;
		if(from<to)for(int i=from;i<=to;++i)cout<<i<<((i==to)?"":" ");
		else if(from<=5)for(int i=from;i>=to;--i)cout<<i<<((i==to)?"":" ");
		else if(to<=5){
			for(int i=from;i<=9;++i)cout<<i<<((i==9)?"":" ");
			for(int i=5;i>=to;--i)cout<<" "<<i;
		}else{
			for(int i=from;i<=9;++i)cout<<i<<((i==9)?"":" ");
			for(int i=5;i>=0;--i)cout<<" "<<i;
			for(int i=1;i<=to;++i)cout<<" "<<i;
		}
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

void trance(int A[], int N){
	int i;
	for( i =0; i < N; i++ ){
		if( i > 0 ) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N){
	int i, j, v;
	for( i = 1; i < N; i++ ){
		v = A[i];
		j = i - 1;
		while( j >= 0 && A[j] > v ){
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trance(A, N);
	}
}

int main(void){
	int N, i, j;
	int A[100];
	scanf("%d", &N);
	for( i = 0; i < N; i++ ) scanf("%d", &A[i]);
	
	trance(A, N);
	insertionSort(A, N);
	
	return 0;
}

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

int main(){
  int n,k,i;
  double temp,ans=0;
  cin>>n>>k;
  for(i=1;i<=n;i++){
    temp=1.0;
    int now=i;
    while(now<k){
      temp/=2;
      now*=2;
    }
    ans+=temp/n;
  }
  printf("%.12f",ans);
  return 0;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from math import factorial

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    N, M, K = map(int, input().split())
    MOD = 998244353
    COM_MAX = N

    fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2, COM_MAX + 1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def mod_com(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    ans = 0
    power = M % MOD
    for k in range(N - 1, -1, -1):
        if k <= K:
            ans += mod_com(N - 1, k) * power % MOD
        power = power * (M - 1) % MOD

    print(ans % MOD)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 32564
#include <iostream>
#include <iomanip>
#include <cmath>

#define PI          ( 3.1415926535897932384626433832795 )
#define SQ(x)       ( (x) * (x) )
#define LEN(x,y)    ( sqrt(SQ(x) + SQ(y)) )

using namespace std;

bool eq(double a, double b)
{
	return fabs(a - b) < 1e-8;
}

double prod(double x1, double y1, double x2, double y2)
{
	return x1 * x2 + y1 * y2;
}

int main()
{
	double D;
	while(cin>>D,D!=0.0)
	{
		double px,py,vx,vy;
		cin>>px>>py>>vx>>vy;

		double lp = LEN(px, py);
		double p = prod(px, py, vx, vy) / lp / LEN(vx, vy);

		cout << fixed << setprecision(8);
		if (eq(p, -1))
		{
			if (lp < D)
			{
				cout << lp << endl;
				continue;
			}

		}
		else if (eq(p, 1))
		{
			if (2 - lp < D)
			{
				cout << (2 - lp) << endl;
				continue;
			}
		}
		cout << "impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000
#define LL long long
#define E "\n"

int main(){
	
	int N,M;
	LL K;
	cin>>N>>M>>K;
	
	vector<LL> A(N),B(M);
	for(int i=0;i<N;i++){
		cin>>A[i];
		if(i!=0)A[i] += A[i-1];
	}
	
	for(int i=0;i<M;i++){
		cin>>B[i];
		if(i!=0)B[i] += B[i-1];
	}
	A.insert(A.begin(),0LL);
	B.insert(B.begin(),0LL);
	
	int ans = 0;
	
	for(int i=0;i<=N;i++){
		LL t = K-A[i];
		if(t<0)continue;
		int d = distance(B.begin(),upper_bound(B.begin(),B.end(),t));
		ans = max(ans,i+d-1);
	}
	
	cout<<ans<<E;
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; ++i) {
    cin >> L[i];
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = j + 1; k < N; ++k) {
        if ((L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) &&
            (L[i] < L[j] + L[k] && L[j] < L[k] + L[i] && L[k] < L[i] + L[j])) {
          ++ans;
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++)  cin >> a.at(i);

  int ans=0;
  for(int i=0;i<N;i++){
    ans+=a.at(i)-1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e17
using namespace std;
typedef pair<ll, ll> P;

double dp[3010][3010];

int main(void) {
	ll n;
	cin >> n;
	vector<double>p(n);
	for (ll i = 0;i < n;i++)cin >> p[i];
	dp[0][0] = 1.0;
	dp[1][0] = (double)1.0 - p[0];
	dp[1][1] = (double)p[0];
	for (ll i = 2;i <= n;i++) {
		for (ll j = 0;j <= i;j++) {
			if (j == 0)dp[i][j] = (double)dp[i - 1][j] * (1 - p[i - 1]);
			else {
				dp[i][j] = (double)dp[i - 1][j] * (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1];
			}
		}
	}
	double ans = 0;
	for (ll i = n;i >= 0;i--) {
		if (i > n - i)ans += (double)dp[n][i];
	}
	printf("%.10lf\n", ans);
	return 0;
}

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

int main(void) {
    int N, X,ans=0;

    while (1) {
      cin >> N >> X;
      if(N==0 && X==0)  break;

      for(int i=1; i<=N-2; i++){
        for(int j=i+1; j<=N-1; j++){
          for(int k=j+1; k<=N; k++){
            if(X==(i+j+k))
              ans++;
          }
        }
      }
      cout << ans << endl;
      ans = 0;
    }

    return 0;
}



Measured memory_bytes: 3096
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b,c,K = IL()

if K <= a:
  print(K)
elif a < K <= a+b:
  print(a)
else:
  print(a - (K - (a+b)))

Measured memory_bytes: 65100
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
ll prefix[N];
int main(void){
    IOS;
    int n, k;
    cin >> n >> k; n++;
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        prefix[i] = (prefix[i-1]+i)%mod;
    }
    for (int i = k; i <= n; ++i){
        ans = (ans+((prefix[n]-prefix[n-i]-prefix[i]+1)%mod+mod)%mod)%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5100