akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

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

int main(){
  int D, A;
  double x = 0, y = 0, a = 90;
  while(scanf("%d,%d",&D,&A),D){
	double dx = D * cos(a*PI/180), dy = D * sin(a*PI/180);
	x += dx, y += dy;
	a -= A;
  }

  cout << (int)x << endl << (int)y << endl;

  return 0;
}

Measured memory_bytes: 1212
N, K, C = map(int, input().strip().split())
S = input().strip()

forward_schedule = [-1 if c == 'x' else 0 for c in S]
backward_schedule = [-1 if c == 'x' else 0 for c in S]
# forward
i_work = 1
for i in range(N):
  if forward_schedule[i] == -1: continue
  forward_schedule[i] = i_work
  for j in range(1, C+1):
    if i+j < N: forward_schedule[i+j] = -1
  i_work += 1

# backward
i_work = K
for i in range(N-1, -1, -1):
  if backward_schedule[i] == -1: continue
  backward_schedule[i] = i_work
  for j in range(1, C+1):
    if i-j >= 0: backward_schedule[i-j] = -1
  i_work -= 1

for i in range(N):
  if forward_schedule[i] == backward_schedule[i] and forward_schedule[i] > 0:
    print(i+1)

Measured memory_bytes: 57592
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::multimap;
using std::make_pair;
using std::sort;
using std::reverse;

//std::numeric_limits<uint32_t>::max()
//for (uint32_t i = 0; i < N; i++){
//vector<uint32_t> A(N);

int main(void)
{
    int64_t N, K, Q;
    cin >> N >> K >> Q;

    vector<uint32_t> A(Q);
    vector<int64_t> point(N, 0);

    for (uint32_t i = 0; i < Q; i++){
        cin >> A[i];
        A[i]--;
        point[A[i]]++;
    }

    //for (uint32_t j = 0; j < N; j++){
    //    cout << j << "," << point[j] << endl;
    //}

    for (uint32_t j = 0; j < N; j++){
        if (point[j] - Q + K <= 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int N, a, b, c, d;
	scanf("%d",&N);
	a = N % 10;
	b = N / 10 % 10;
	c = N / 100 % 10;
	d = N / 1000 % 10;
	if(a == b && b == c && c == d){
		printf("Yes\n");
	}
	else if(a == b && b == c)
	{
		printf("Yes\n");
	}
	else if(b == c  && c == d)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
		return 0;
}

Measured memory_bytes: 128
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

S = input()

if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 3444
'use strict';
(function(input){
  input=input.trim().split(/\n/).map(str=>str.split(/\s+/).map(x=>x-0));
  const N=input[0][0];
  const W=input[0][1];
  const V=100000;
  const dp=[];//dp[i][v]で最初のi個から任意に選んで価値をvにするときのweightの最小値
  for(let i=0;i<=N;i++){
    dp[i]=[];
    for(let v=0;v<=V;v++){
      dp[i][v]=Infinity;
    }
  }
  dp[0][0]=0;
  for(let i=1;i<=N;i++){
    let wi=input[i][0];
    let vi=input[i][1];
    for(let v=0;v<=V;v++){
      dp[i][v]=dp[i-1][v];
      if(v>=vi&&dp[i][v]>(dp[i-1][v-vi]+wi))
        dp[i][v]=dp[i-1][v-vi]+wi;
    }
  }
  var ans=V;
  while(dp[N][ans]>W)ans--;
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 121412
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N, Ans = 0;cin >> N;
vector<ll> V(N);

rep(i, 0, N)cin >> V[i];

rep(i, 0, N){
    rep(j, i + 1, N){
        rep(k, j + 1, N){
            
            if(V[i] + V[j] > V[k] && V[j] + V[k] > V[i] && V[k] + V[i] > V[j] && V[i] != V[j] && V[i] != V[k] && V[k] != V[j])Ans++;

        }
    }
}
cout << Ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    set<int> all_n = {1,2,3};
    set<int> input = {a,b};
    set<int> ans;
    set_difference(all_n.begin(), all_n.end(), input.begin(), input.end(), inserter(ans, ans.end()));

    for (auto itr = ans.begin(); itr!=ans.end();itr++)
    {
        cout << *itr << endl;
    }
}




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

int main() {
  int n;
  cin >> n;
  set<string> s;
  int cnt = 0;
  rep(i, n) {
    string S;
    cin >> S;
    if(s.count(S) == 0) {
      s.insert(S);
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
      

Measured memory_bytes: 19152
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <queue>
#include <map>
#include <tuple>
using namespace std;

long long N, D, X[1 << 18], C[1 << 18], L[1 << 18];

long long solve() {
	long long sc = 0;
	for (int i = 0; i < N; i++) { sc += C[i]; L[i] = sc - X[i]; }
	for (int i = 1; i < N; i++) L[i] = max(L[i], L[i - 1]);

	long long maxn = L[N - 1], I = 0;
	for (int i = N - 1; i >= 1; i--) {
		I += C[i];
		long long DD = I - (D - X[i]) * 2LL;
		maxn = max(maxn, DD + L[i - 1]);
	}
	return max(0LL, maxn);
}

int main() {
	cin >> N >> D;
	for (int i = 0; i < N; i++) cin >> X[i] >> C[i];

	long long B1 = solve();

	for (int i = 0; i < N; i++) { if (i < (N - 1 - i)) swap(X[i], X[N - 1 - i]); }
	for (int i = 0; i < N; i++) { if (i < (N - 1 - i)) swap(C[i], C[N - 1 - i]); }
	for (int i = 0; i < N; i++) X[i] = D - X[i];

	long long B2 = solve();
	cout << max(B1, B2) << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    ll n; cin >> n;
    ll x[n],y[n],h[n];
    ll ans_h = 0;
    rep(i,n) cin >> x[i] >> y[i] >> h[i];
    rep(i,101){
        rep(j,101){
            
            rep(k,n){
                ans_h = h[k] + abs(x[k] - i) + abs(y[k] - j);
                bool ok = true;
                if(ans_h <= 0) continue;
                rep(l,n){
                    if(h[l] != max((ll)0,ans_h - abs(x[l] - i) - abs(y[l] - j))) ok = false;
                }
                if(ok){
                    cout << i << ' ' << j << ' ' << ans_h;
                    return 0;
                }
            }
        }
    }
}

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

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

  char c = s[0];
  int ans = 0;
  for(int i = 1;i < s.size();i++){
    if(s[i] != c){
      ans++;
      c = s[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	int x = N % 10;
	int y = N / 10;
	if (x == 9 || y == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3600
n=int(input())
l=list(map(int,input().split()))
l.sort()
new=(l[0]+l[1])/2
if n>=3:
  for i in range(2,n):
    new=(new+l[i])/2
  print(new)
else:
  print((l[0]+l[1])/2)
    

Measured memory_bytes: 3060
aryQuestion = gets.split.map(&:to_i);
 
a = aryQuestion[0];
b = aryQuestion[1];
c = aryQuestion[2];
 
count = 0;
 
for num in a..b do

	modulo = c % num
	
	if modulo == 0 then
	
		count += 1;
		
	end
 
end
 
puts count.to_s;

Measured memory_bytes: 8684
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int h,w;
char g[1005][1005];
ll dp[1005][1005];

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>g[i][j];
		}
	}
	dp[1][1]=1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i==1&&j==1)continue;
			if(g[i][j]!='#'){
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				dp[i][j]%=((int)1e9+7);
			}
		}
	}
	cout<<dp[h][w]<<endl;

	return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N = 1e5+5;
vector<ll> G[N],down(N,1),pref[N],suff[N],up(N,1);
ll n,mod;

void add_self(ll &a, ll b){a+=b;if(a>=mod)a-=mod;}
void sub_self(ll &a, ll b){a-=b;if(a<0)a+=mod;}
void mul_self(ll &a, ll b){a*=b;a%=mod;}


void dfs(ll v, ll p)
{
	for( ll i:G[v])if(i!=p){dfs(i,v);mul_self(down[v],down[i]+1);}

	ll x=1;
	for(ll i:G[v]){if(i!=p)mul_self(x,down[i]+1);pref[v].pb(x);}
	x=1;
	forr(i,sz(G[v])){if(G[v][i]!=p)mul_self(x,down[G[v][i]]+1);suff[v].pb(x);}
	reverse(all(suff[v]));
}

void dfs2(ll v, ll p)
{
	forn(i,sz(G[v]))
	{
		if(G[v][i]==p)continue;
		ll x=1;
		if(i!=0)mul_self(x,pref[v][i-1]);
		if(i!=sz(G[v])-1)mul_self(x,suff[v][i+1]);
		mul_self(x,up[v]);
		up[G[v][i]]=x+1;
		dfs2(G[v][i],v);
	}
}

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

    cin>>n>>mod;forn(i,n-1){ll u,v;cin>>u>>v;u--,v--;G[u].pb(v);G[v].pb(u);}

    dfs(0,0);
	up[0]=1;
	dfs2(0,0);
	//forn(i,n)cout<<down[i]<<" ";cout<<endl;
	//forn(i,n)cout<<up[i]<<" ";cout<<endl;

	forn(i,n){mul_self(up[i],down[i]);cout<<up[i]<<endl;}
}


Measured memory_bytes: 26368
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll a[110],n;
int main(){
  cin>>n;
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  sort(a,a+n);
  sum-=a[n-1];
  cout<<(a[n-1]<sum?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2)
{
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
	return (a * (a + 1LL)) / 2;
}
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, -1, -1, 1, 1 };
int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1 };


const int N = 1e5 + 30;
const lli mod = 998244353;
const ld pi = acos(-1);
const int T = 238;
const ld e = 1e-6;

lli bp(lli a, lli b = mod - 2LL)
{
	lli ret = 1;
	while (b)
	{
		if (b & 1) ret *= a, ret %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return ret;
}
ostream& operator<<(ostream& c, pir a)
{
	c << a.fr << " " << a.sc;
	return c;
}




int a, b, k;
int main()
{
	fastio;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}


/*


  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/



Measured memory_bytes: 3664
import java.util.Scanner;

public class Main
{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String text = sc.next();

		String first = text.substring(0, 1);
		String end = text.substring(text.length()-1, text.length());
		System.out.println(first + (text.length() - 2) + end);
	}

}


Measured memory_bytes: 22228
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b + c or b == c + a or c == a + b){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main() {
    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1) / 2) + (m * (m - 1) / 2) << endl;
    r0
}


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

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

    long int i;
    long int count, n_whi, ans, cnt_whi;

    for(i = 0, n_whi = 0; i < s.length(); i++){
        if(s[i] == 'W'){
            n_whi++;
        }
    }

    count = 0;
    ans = 0;
    cnt_whi = 0;
    for(i = 0; cnt_whi != n_whi; i++){
        if(s[i] == 'B'){
            count++;
        }else {
            ans += i - cnt_whi;
            cnt_whi++;
            count = cnt_whi;
        }
    }

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

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int a[100000 + 1];
int s[100000 + 1];

int main() {

	int n, k;
	int i, j, l;
	int sum = 0, asus = 0;

	while (true) {

		memset(s, 0, sizeof(s));
		memset(a, 0, sizeof(a));

		cin >> n >> k;
		if (n == 0 && k == 0) return 0;

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

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

				sum += a[i + j];
			}
			asus = max(asus, sum);
			sum = 0;
		}

		cout << asus << endl;
	}
}


Measured memory_bytes: 3756
def main():
    n = int(input())
    data = list(map(int, input().split()))

    for k in data:
        if k == 0:
            return 0

    up = 1
    for i in range(n):
        up *= data[i]

    down = 0
    for j in range(n):
        down += up / data[j]

    return (up / down)

print(main())


Measured memory_bytes: 38256
#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define reg register
	#define Rint register int
	#define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
	#define FORit(templ,arr,i,a,b) for(register templ *i=(arr)+(a);i!=(arr)+(b)+1;++i)
	#define ROFit(templ,arr,i,a,b) for(register templ *i=(arr)+(a);i!=(arr)+(b)-1;--i)
	#define GO(x,p,e,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
	#define MEM(x,v) memset(x,v,sizeof(x))
	#define fir first
	#define sec second
	#define pq priority_queue
	#define PII pair<int,int>
	#define MP make_pair
	typedef long long LL;
	typedef double DB;
	inline int read(){
		int ans=0,f=1;char c=getchar();
		while(!isdigit(c)){ f^=(c=='-'); c=getchar(); }
		for(;isdigit(c);c=getchar()) ans=(ans<<1)+(ans<<3)+(c^48); return f?ans:-ans;
	}
	const int mod = 998244353 , N = 100010;
	inline void inc(int &x,const int &y){ x+=y; if(x>=mod) x-=mod; }
	inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res;}
	inline int gcd(int x,int y){ if(x<y) swap(x,y); return y?gcd(y,x%y):x; }
	#define FILE(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
}
using namespace my_std;

int n,m,x[N],pos[N],vis[N];
LL k , ans[N];
int stk[N] , top;

int main(){
	n = read();
	FOR(i,1,n) x[i] = read() , pos[i] = i;
	ROF(i,n,1) x[i] -= x[i - 1];
	m = read() , scanf("%lld",&k);
	Rint xx;
	FOR(i,1,m) xx = read() , swap(pos[xx] , pos[xx + 1]);
	FOR(i,1,n){
		if(!vis[i]){
			for(Rint j = i;!vis[j];j = pos[j]) vis[stk[top++] = j] = 1;
			FOR(j,0,top - 1) ans[stk[j]] = x[stk[(j + k) % top]];
			top = 0;
		}
	}
	FOR(i,1,n) ans[i] += ans[i - 1] , printf("%lld.0\n",ans[i]);
	return 0;
}


Measured memory_bytes: 3840
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int main() {
	int x;
	cin >> x;
	for (int i = 1; i <= 360; i++)
		if ((x * i) % 360 == 0) {
			cout << i << endl;
			return 0;
		}
	return 0;
}


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

int main(){
  int K,S;
  cin >> K >> S;
  int ans = 0;
  for(int x = 0; x <= K; x++){
    int sum = S - x ;
    if(sum <= 2*K && sum >=0){
    	ans += (sum + 1) - max(0, 2*(sum - K)); 
    }
  }
  
  cout << ans;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#define N 100000
int a[N],b[N],c[N];
using namespace std;
int main( void )
{
  int i,j,k,n,d=0,ret=0;
  cin >> n;
  for( i=0; i<n; i++ )
    cin >> a[i] >> b[i];
  sort( a, a+n );
  sort( b, b+n );
  for( i=2,j=0,k=0; i<=n+1; i++ ){
    while( a[j] == i ){ j++; d++; }
    while( b[k] == i-1 ){ k++; d--; }
    if( i -1 <= d ) ret = i-1;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1964
#include <iostream>
using namespace std;
int main(){
int H, W;
for (int i = 0; ; i++){
cin >> H >> W;
if (H==0 && W==0) break;
for (int h=0; h<H; h++){
for (int w=0; w<W; w++){
if (h==0 || h==H-1 || w==0 || w==W-1) cout << "#";
else cout << '.';
}
cout << endl;
}
cout << endl;
}
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    string Sa, Sb, Sc;
    cin >> Sa;
    cin >> Sb;
    cin >> Sc;

    int a = 0, b = 0, c = 0;
    char next = 'a';
    while(true){
        if(next == 'a'){
            next = Sa[a];
            a++;
        }else if(next == 'b'){
            next = Sb[b];
            b++;
        }else if(next == 'c'){
            next = Sc[c];
            c++;
        }

        if(a == Sa.length() + 1){
            cout << "A" << endl;
            break;
        }else if(b == Sb.length() + 1){
            cout << "B" << endl;
            break;
        }else if(c == Sc.length() + 1){
            cout << "C" << endl;
            break;
        }
    }

    return 0;
}

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

int h, w;
char s[MAXP][MAXP];
bool flag, vis[MAXP][MAXP];

int floodfill(register int x, register int y) {
        register int sum = 0;
        vis[x][y] = 1;
        (x >= 2 && s[x - 1][y] == '#' && !vis[x - 1][y]) && (sum += floodfill(x - 1, y));
        (y >= 2 && s[x][y - 1] == '#' && !vis[x][y - 1]) && (sum += floodfill(x, y - 1));
        (x <= h - 1 && s[x + 1][y] == '#' && !vis[x + 1][y]) && (sum += floodfill(x + 1, y));
        (y <= w - 1 && s[x][y + 1] == '#' && !vis[x][y + 1]) && (sum += floodfill(x, y + 1));
        return sum + 1;
}

int main() {
        scanf("%d%d", &h, &w);
        for (register int i = 1; i <= h; ++i)
                scanf("%s", s[i] + 1);
        for (register int i = 1; i <= h; ++i) 
                for (register int j = 1; j <= w; ++j) {
                        if (vis[i][j] || s[i][j] == '.')
                                continue;
                        if (floodfill(i, j) == 1) {
                                flag = 1;
                                break;
                        }
                }
        puts(flag ? "No" : "Yes");
        return 0;
}

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
    	fastio;
    	int n;
    	cin>>n;
    	if(n%1000==0)
    		cout<<0<<endl;
    	else
    	{
    		cout<<((n/1000)+1)*1000-n<<endl;
    	}
    }

Measured memory_bytes: 3648
#include<iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

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

    int ans = 0;
    for(int i = 0; i < n-2; i++){
        if(max(p[i], max(p[i+1], p[i+2])) != p[i+1] && min(p[i], min(p[i+1], p[i+2])) != p[i+1]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"5 7 9
" => r"win",

r"13 7 2
" => r"bust"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a1: i32,
        a2: i32,
        a3: i32
    }

    if a1 + a2 + a3 >= 22 {
        "bust".to_string()
    } else {
        "win".to_string()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int main()
{
  string str, addStr, binaryStr, a;
  long long score = 0, l;
  cin >> str;

  if (str.length() > 1)
  {
    for (int j = 0; j < (int)pow(2, str.length() - 1); j++)
    {
      binaryStr = "";
      l = j;
      for (int k = 0; k < str.length() - 1; k++)
      {
        if (l % 2)
        {
          binaryStr.append("1");
        }
        else
        {
          binaryStr.append("0");
        }
        l /= 2;
      }

      addStr = str[0];
      for (int k = 0; k < binaryStr.length(); k++)
      {
        if (binaryStr[k] == '1')
        {
          addStr += "+";
        }
        addStr += str[k + 1];
      }

      while(true)
      {
        int pos = addStr.find("+");
        if(pos == string::npos)
        {
          score += stoll(addStr);
          break;
        }
        else
        {
          score += stoll(addStr.substr(0, pos));
          addStr.erase(0, pos + 1);
        }
      }
    }
  }
  else
  {
    score = stoi(str);
  }

  cout << score;

  return 0;
}


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

#define ll long long

int main() {
	int n;
	scanf("%d", &n);
	
	int arr[n+5];
	
	for(int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	
	ll dp[n+5] = {};
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	
	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1] + abs(arr[i-1]-arr[i]), dp[i-2] + abs(arr[i-2]-arr[i]));
	}
	printf("%lld\n", dp[n-1]);
}

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

typedef vector<int> vec;
typedef vector<vec> mat;

int calc_rank(mat A) {
	const int n = A.size();
	const int m = A[0].size();

	int res = 0;
	int col = -1;

	for(int i = 0; i < n; ++i) {
		int pivot;
		for(;;) {
			if(++col == m) goto rank_end;
			pivot = -1;
			for(int j = i; j < n; ++j) {
				if(A[j][col]) {
					pivot = j;
					goto pivot_end;
				}
			}
		}

	pivot_end:;
		A[i].swap(A[pivot]);
		++res;

		for(int j = i + 1; j < n; ++j) {
			if(A[j][col]) {
				for(int k = col + 1; k < m; ++k) {
					A[j][k] ^= A[i][k];
				}
			}
		}
	}

rank_end:;
	return res;
}

int calc_rank(const mat &A, const vec &b) {
	const int n = A.size();
	const int m = A[0].size() + 1;
	mat B(n, vec(m));
	for(int i = 0; i < n; ++i) {
		copy(A[i].begin(), A[i].end(), B[i].begin());
		B[i][m - 1] = b[i];
	}
	return calc_rank(move(B));
}

int w, h, d;

inline bool solve(mat A, const vec &b) {
	return calc_rank(A, b) == calc_rank(move(A));
}

inline int get_index(int x, int y) {
	return x + y * w;
}

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

	while(cin >> w >> h >> d && h) {
		const int number_of_cell = w * h;
		vec right(number_of_cell);
		for(int y = 0; y < h; ++y) {
			for(int x = 0; x < w; ++x) {
				cin >> right[get_index(x, y)];
			}
		}

		mat left(number_of_cell, vec(number_of_cell, 0));
		for(int i = 0; i < number_of_cell; ++i) {
			left[i][i] = 1;
		}

		for(int y = 0; y < h; ++y) {
			for(int ty = max(0, y - d); ty <= min(h - 1, y + d); ++ty) {
				for(int sign = -1; sign <= 1; sign += 2) {
					const int dx = sign * (d - abs(y - ty));
					for(int x = 0; x < w; ++x) {
						const int tx = x + dx;
						if(tx < 0 || tx >= w) continue;
						left[get_index(x, y)][get_index(tx, ty)] = 1;
					}
				}
			}
		}

		cout << solve(move(left), right) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c;cin>>a>>b>>c;
    cout << a / 3 << ednl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		long num1 = 0;
		long num2 = 0;
		for (int i = 1; i <= N; i++) {
			if (K % 2 == 0) {
				if (i % K == 0) {
					num1++;
				} else if (i % K == K / 2) {
					num2++;
				}
				
			} else if (K % 2 != 0 && i % K == 0) {
					num2++;
			}
		}
		num1 = num1*num1*num1;
		num2 = num2*num2*num2;
		System.out.println(num1+num2);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    if (x>=10 || y>=10)
    printf("-1\n");
    else
    printf("%d\n",(x*y));
    return 0;
}

Measured memory_bytes: 3712
n=int(input())
A=list(map(int,input().split()))
ans1=0
ans2=0
A.sort(reverse=True)
flag = False
for i in range(n-1):
  if flag == True:
    flag = False
    continue
  if i < n-1 and A[i+1] == A[i]:
    flag = True
    if A[i] >= ans1:
      ans2 = ans1
      ans1 = A[i]
    elif A[i] > ans2:
      ans2 =A[i]
print(ans1*ans2)


Measured memory_bytes: 84764
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  vector<tuple<double,int,int>> ans;
  vector<int> watersum;
  for(int i = 0; i<=30; i++) {
    for(int j = 0; j<=30; j++) {
      if(i==0 && j==0) continue;
      int sum = 100*(a*i+b*j);
      if(sum<=f) watersum.push_back(sum);
    }
  }
  rep(i,watersum.size()) {
    int water = watersum[i];
    int sugarmax = min(water/100*e,f-water);
    bool dp[sugarmax+1];
    rep(j,sugarmax+1) dp[j] = false;
    dp[0] = true;
    for(int j = 1; j <= sugarmax; j++) {
      bool ok = false;
      if(j-c>=0) if(dp[j-c]) ok = true;
      if(j-d>=0) if(dp[j-d]) ok = true;
      if(ok) dp[j] = true;
    }
    int sugar;
    per(j,sugarmax+1) {
      if(dp[j]) {
        sugar = j;
        break;
      }
    }
    double con = sugar / (double)(water+sugar);
    tuple<double,int,int> p = make_tuple(con,(sugar+water),sugar);
    ans.push_back(p);
  }
  sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
  int x, y;
  tie(ignore,x,y) = ans[0];
  cout << x << " " << y << endl;
  return 0;
}

Measured memory_bytes: 256
float x[99],y[99],X,Y;
n,i;main(){
	for(gets(x);~scanf("%f %f",x+n,y+n);n++);
	if(!(n&1))for(X=(x[0]+x[n/2])/2,Y=(y[0]+y[n/2])/2,i=1;
		i<n/2&&fabsf((x[i]+x[n/2+i])/2-X)<1e-7&&fabsf((y[i]+y[n/2+i])/2-Y)<1e-7;
	i++);
	printf(i==n/2?"%f %f\n":"NA\n",X,Y);exit(0);
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define pi 3.1415926536
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
signed main()
{
    SPEED;
  	int a,b;
  	cin>>a>>b;
  	cout<<6-a-b;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m;
  cin >> n >> m;
  set<pll> st;
  vll a(m), b(m);
  rep(i, m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    st.emplace(a[i], b[i]);
    st.emplace(b[i], a[i]);
  }
  vi perm(n);
  iota(ALL(perm), 0);
  ll ans = 0;
  do{
    if(perm[0] != 0) continue;
    bool f = 1;
    rep(i, n-1){
      if(st.count(pll(perm[i], perm[i+1])) == 0){
        f = 0;
        break;
      }
    }
    if(f){
      ans++;
    }
  }while(next_permutation(ALL(perm)));
  print(ans);
}


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

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


int main()
{
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z), ab, abc;
	for(int i = 0; i < x; i++)cin >> a[i];
	for(int i = 0; i < y; i++)cin >> b[i];
	for(int i = 0; i < z; i++)cin >> c[i];

	for(int i = 0; i < x; i++) {
		for(int j = 0; j < y; j++) {
			ab.push_back(a[i] + b[j]);
		}
	}
	sort(ab.begin(), ab.end(), greater<ll>());
	ab.resize(k);
	for(int i = 0; i < k; i++) {
		for(int j = 0; j < z; j++) {
			abc.push_back(ab[i] + c[j]);
		} 
	}	
	sort(abc.begin(), abc.end(), greater<ll>());
	for(int i = 0; i < k; i++)cout << abc[i] << endl;

}

Measured memory_bytes: 43368
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k;
main() {
    file("threesum");
    ios;
    cin >> n >> k;
    int ans=0;
    while (n) ++ans, n/=k;
    cout<<ans;
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

void dfs (int tag, int node, vector<vector<int> > &adj, vector<int> &tags) {
	tags[node] = tag;
	for (int i : adj[node]) {
		if (tags[i] == 0) {
			dfs(tag, i, adj, tags);
		}
	}
}

int main () {
	int n, k, l;
	cin >> n >> k >> l;
	vector<int> p(k), q(k);
	vector<int> r(l), s(l);
	vector<vector<int> > road_adj(n), rail_adj(n);
	for (int i = 0; i < k; i ++) { cin >> p[i] >> q[i]; p[i]--; q[i]--;
		road_adj[p[i]].push_back(q[i]);
		road_adj[q[i]].push_back(p[i]);
	}
	for (int i = 0; i < l; i ++) { cin >> r[i] >> s[i]; r[i]--; s[i]--; 
		rail_adj[s[i]].push_back(r[i]);
		rail_adj[r[i]].push_back(s[i]);
		}
	vector<int> road_tag(n, 0), rail_tag(n, 0);
	int tag = 1;
	for (int i = 0; i < n; i ++) if (road_tag[i] == 0) { dfs(tag, i, road_adj, road_tag); tag ++; }
	tag = 1;
	for (int j = 0; j < n; j ++) if (rail_tag[j] == 0) { dfs(tag, j, rail_adj, rail_tag); tag ++; }
	vector<pair<int,int> > tags(n);
	for (int i = 0; i < n; i ++) tags[i] = {road_tag[i], rail_tag[i]};
//	for (int i = 0; i < n; i ++) cout << road_tag[i] << ' ' << rail_tag[i] << endl;
	map<pair<int,int>, int> count;
	for (int i = 0; i < n; i ++) count[tags[i]] ++;
	for (int i = 0; i < n; i ++) cout << count[tags[i]] << ' ';
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 30848
#include <iostream>

using namespace std;

int main() 
{
    int x,y,z,i,p ;
    cin>>x>>y>>z;
    p=0;//initialise
    for(i=x;i<=y;i++)
    if(z%i==0)
    p++;
    
   
   cout<< p <<endl;
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

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

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	std::vector<long long> A(N);
	ll sum = 0;
	for(int i = 0 ; i < N ; i++){
		scanf("%lld",&A[i]);
		sum += A[i];
	}

	sort(A.begin(), A.end(), greater<ll>());

	ll count = 0;
	for (ll i = 0; i < M; ++i)
	{
		if (A[i] < static_cast<double>(sum) / (4.0 * M))		continue;
		++count;
	}

	cout << (count < M ? "No" : "Yes") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int BubbleSort(int A[],int N){
  int i,j,count=0,tmp;
    for(i = 0 ; i < N-1 ; i++){
    for(j = N-1 ; j >= 1 ; j--){
      if(A[j] < A[j - 1]){
	tmp = A[j];
	A[j] = A[j - 1];
	A[j - 1] = tmp;
	count++;
      }
    }
  }
  return count;
}

int main(){
  int N,i,count;

  scanf("%d",&N);
  
  int A[N];

  for(i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
  }
  
  count = BubbleSort(A,N);

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

  return 0;
}


Measured memory_bytes: 2120
#include<stdio.h>
int main(void)
{
	int a[30],s,d,f,g[30],i;
	for(i=1;i<=30;i++){
		g[i]=1;
	}
	for(i=1;i<=28;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=28;i++){
		for(f=1;f<=30;f++){
			if(a[i]==f){
				g[f]=0;
			}
		}
	}
	for(i=1;i<=30;i++){
		if(g[i]==1){
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        double eps = Math.pow(10, -10);


        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());

        int[][] x = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                x[i][j] =  Integer.parseInt(sc.next());
            }
        }


        double dist = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) continue;

                dist = 0;

                for (int k = 0; k < d; k++){
                    dist += Math.pow((x[i][k] - x[j][k]), 2);
                }

                dist = Math.sqrt(dist);
                if ((dist - (int)dist) < eps) {
                    count++;
                }
            }
        }

        System.out.println(count/2);
    }
}

Measured memory_bytes: 22100
a, b = input(), input()
res = len(b)
for i in range(len(a) - len(b) + 1):
  aa = a[i:len(b)+i]
  cnt = 0
  for x, y in zip(aa, b):
    if x != y:
      cnt += 1
  res = min(res, cnt)
print(res)

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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second
#define nl '\n'

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << nl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << nl;
}

int n,nxt[26][200010], pre[26], dp[200010], ch[200010];
string ans = "";

int bt(int x) {
	if (dp[x] != -1) return dp[x];
	FOR(i,0,26) {
		if (nxt[i][x] == -1) {;
			ch[x] = i;
			return dp[x] = 1;
		}
	}
	int ans = 1e9 + 7;
	FOR(i,0,26) {
		int cur = (bt(nxt[i][x]));
		if (cur < ans) {
			ch[x] = i;
			ans = cur;
		}
	}
	return dp[x] = ans + 1;
}

void print(int x) {
	ans += ('a' + ch[x]);
	if (dp[x] == 1) return;
	int idx = -1, mi = 1e9 + 7;
	FOR(i,0,26) {
		if (dp[nxt[i][x]] > -1 && dp[nxt[i][x]] < mi) {
			mi = dp[nxt[i][x]];
			idx = nxt[i][x];
		}
	}
	print(idx);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("test.txt", "r", stdin);
	string s = "a", k;
	cin >> k;
	s += k;
	n = s.length();
	memset(dp,-1,sizeof dp);
	memset(pre,-1,sizeof pre);
	FOR(i,0,26) nxt[i][n - 1] = -1;
	DOW(i,n-1,0) {
		FOR(j,0,26) nxt[j][i] = pre[j];
		pre[s[i] - 'a'] = i;
	}
	bt(0);
	print(0);
	cout << ans;
}

Measured memory_bytes: 23060
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,q;
  cin>>n>>q;
  int c[n+2];
  memset(c,0,sizeof(c));
  int p=1;
  c[p]=2;
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    c[p-1]=1;
    c[p+1]=1;
    if(p==a) p=b;
    else if(p==b) p=a;
    swap(c[a],c[b]);
    c[p-1]=1;
    c[p+1]=1;
  }
  int ans=0;
  for(int i=1;i<=n;i++) ans+=c[i];
  cout<<ans-1<<endl;
  return 0;
}


Measured memory_bytes: 1024
n=gets.to_i
p1=gets.chomp.split(" ").map(&:to_i)

count=0
for i in 1..n-2
	if((p1[i-1]<p1[i] and p1[i]<p1[i+1]) or (p1[i-1]>p1[i] and p1[i]>p1[i+1]))
		count+=1
	end
end
p count

Measured memory_bytes: 1788
def Istraiangle(A,B,C):
    if (A==B)|(B==C)|(A==C):
        return False
    if A+B>C:
        if A+C>B:
            if B+C>A:
                return True
    return False
count=0
N=int(input())
L=list(map(int,input().split()))
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if Istraiangle(L[i],L[j],L[k]):
                count+=1
print(count)

Measured memory_bytes: 9204
#include <stdio.h>
#include <math.h>

int main(void)
{
	double a, b, c,s,l,h;

	scanf("%lf%lf%lf%lf", &a, &b, &c);

	s = a * b*sin(c*3.1415926535 / 180) / 2;
	l = a + b + sqrt(a*a + b * b - 2 * a*b*cos(c*3.1415926535 / 180));
	h = s / a * 2;
	printf("%lf\n%lf\n%lf\n", s,l,h);

	return 0;
}


Measured memory_bytes: 2104