akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, pt = 0, px = 0, py = 0;
    cin >> n;
    repi(i, n, 0)
    {
        int x, y, t;
        cin >> t >> x >> y;
        if (t - pt < abs(x - px) + abs(y - py))
        {
            cout << "No" << endl;
            return 0;
        }
        if((abs(x - px) + abs(y - py) - t + pt)&1){
            cout << "No" << endl;
            return 0;
        }
        pt = t;
        px = x;
        py = y;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,X = map(int, input().split())
a = []
for i in range(N):
    a.append(list(map(int,input().split())))

minCost = 12 * (10**5)
count = 0

for i in range(2**N):
    total = 0
    flag = 1
    B = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            total = total + a[j][0]
            for k in range(M):
                B[k] = B[k] + a[j][k + 1]
    for l in range(M):
        if B[l] < X:
            flag = 0
    if flag:
        minCost = min(minCost,total)
    count = count + flag

if count:
    print(minCost)
else:
    print("-1")


Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define int long long

const int maxn = 100010;
const int inf = 0x3f3f3f3f;

inline int read() {
    register int g = 1; register char ch;
    while(!isdigit(ch = getchar())) if(ch == '-') g = -1;
    register int x = ch ^ '0';
    while(isdigit(ch = getchar())) x = (((x << 2) + x) << 1) + (ch ^ '0');
    return x * g;
}

inline void print(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

int n, m;
struct city{
	int p, y, id;
	friend bool operator < (city a, city b) {
		if(a.p == b.p) return a.y < b.y;
		return a.p < b.p;
	}
} c[maxn];

inline bool cmp(city a, city b) {
	return a.id < b.id;
}

int flag1[maxn], flag2[maxn], now = 0;

signed main() {
	n = read(), m = read();
	for(int i = 1; i <= m; ++i) {
		c[i].p = read(), c[i].y = read(); 	
		c[i].id = i;
	}
	std::sort(c + 1, c + m + 1);
	for(int i = 1; i <= m; ++i) {
		flag1[c[i].id] = c[i].p;
		flag2[c[i].id] = ++now;
		if(c[i].p != c[i + 1].p) now = 0;
	}
	std::sort(c + 1, c + m + 1, cmp);
	for(int i = 1; i <= m; ++i) {
		int cnt1 = (log10(flag1[i])) + 1;
		int cnt2 = (log10(flag2[i])) + 1;
		if(cnt1 < 6) 
			for(int j = 1; j <= 6 - cnt1; ++j) printf("0");
		print(flag1[i]);
		if(cnt2 < 6)
			for(int j = 1; j <= 6 - cnt2; ++j) printf("0");
		print(flag2[i]);
		puts(""); 
	}
	return 0;	
}

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

int main(void){
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    
    for(int i=0; i<3; i++){
        char c = s[i][0] - 0x20;
        cout << c;
    
    }
    cout << endl;
    return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
string a;
int main()
{
	for(int i=0;i<3;i++)
	{
		cin>>a;
		cout<<a[0];
	}
	cout<<endl;
	return 0;

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}
#define ac cout<<"AC"<<nl
#define wa cout<<"WA"<<nl
#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  string s;
  cin>>s;
  int n=sz(s),c=0,C=0,a=0;
  if(s[0]=='A')
  {
    for(int i=1;i<n;i++)
    {
      if(s[i]=='C')
        c++;
    }
    if(c>1||c==0)
      wa;
    else
    {
      for(int i=2;i<n-1;i++)
      {
        if(s[i]=='C')
          C++;
      }
      if(C==1)
      {
        for(int i=1;i<n;i++)
        {
          if(s[i]!='C'&&s[i]>='a'&&s[i]<='z')
            a++;
        }
        if(2+a==n)
          ac;
        else
          wa;
      }
      else
        wa;
    }
  }
  else
    wa;
}

int main()
{
    su;
    ///tt
    f();
    return 0;
}


Measured memory_bytes: 3624
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Arrays;

public class Main{
   static Scanner sc = new Scanner(System.in);
   public static void main(String[] args){
      int N = sc.nextInt();
      if(N==0){
         System.out.println(N);
         return;
      }

      int[] array = new int[N];
      for(int i=0; i<N;i++){
         array[i] = sc.nextInt();
      }
      
      Arrays.sort(array);

      int result = 0;
      int count = 0;
      int old = 0;
      
      for(int i=0;i<N;i++){
         int target = array[i];
         if(target>N){
            result += N-i + count;
            count = 0;
            break;
         }
         
         if(old == target){
            count++;

         }else{
            if(old >count){
               result+= count;
            }else{
               result+= count-old;
            }
            old = target;
            count = 1;
         }

      }
      if(old < count){
         result += count-old;
      }
      if(old > count){
         result += count;
      }

      System.out.println(result);
   }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll MOD = 1000000007;
ll INF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll h, w;
  cin >> h >> w;
  ll sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  sx--; sy--; gx--; gy--;

  vstr str(h);
  REP(i,h) cin >> str[i];

  vvll seen(h,vll(w,0));
  vvll dist(h,vll(w,INF));

  deque<pll> deq;

  deq.push_back({sx, sy});
  dist[sx][sy] = 0;

  while(!deq.empty()){
    pll tmp = deq.front();
    deq.pop_front();
    ll x = tmp.first;
    ll y = tmp.second;
    if(seen[x][y] == 1) continue;
  
    for(ll i = -2; i <= 2; i++){
      for(ll j = -2; j <= 2; j++){
        ll nx = x + i;
        ll ny = y + j;

        if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if(i == 0 && j == 0) continue;

        if((i == 0 && j == -1) || (i == 0 && j == 1) || (i == 1 && j == 0) || (i == -1 && j == 0)){
          if(str[nx][ny] == '.'){
            dist[nx][ny] = dist[x][y];
            if(seen[nx][ny] == 0){
              deq.push_front({nx, ny});
            }
          }
        }
        else{
          if(str[nx][ny] == '.'){
            dist[nx][ny] = min(dist[nx][ny], dist[x][y] + 1);
            if(seen[nx][ny] == 0){
              deq.push_back({nx, ny});
            }
          }
        }
      }
    }

    seen[x][y] = 1;
  }

  cout << (dist[gx][gy] == INF ? -1 : dist[gx][gy]) << endl;





  return 0;
}



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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int inf = int (1e9) + int (1e5);
const ll infl = ll (2e18) + ll (1e10);
const ui M=1E9+7;
const double eps = 1e-9;

int main()
{
    std::ios_base::sync_with_stdio (false);
    int N;
    cin >> N;
    int n=1;
    while (n*2<=N) n *= 2;
    cout << n;


    return 0;
}


Measured memory_bytes: 256
//?????????????????°?????????????°????????????§??????????¨????????±???????
#include<stdio.h>

int main(void){
    int n;
    long a;
    int i;
    long min = 10000000;
    long max = -10000000;
    long sum = 0;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        scanf("%ld", &a);
        if(a > max) max = a;
        if(a < min) min = a;
        sum += a;    
    }
    
    
    printf("%ld %ld %ld", min, max, sum);
    putchar('\n');
    
    return 0;
}

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

int xorOp(bool arr1[], bool arr2[], int size) {
	int ret = 0;
	for(int i=0;i<size;i++){
		if(arr1[i] != arr2[i]) {
			ret ++;
		}
	}
	return ret;
}
int main() {
	string in;
	cin >>in;
	int length = in.size();
	bool cross1[length],cross2[length];
	bool tmp = true;
	for(int i=0;i<length;i++){
		cross1[i] = tmp;
		tmp = !tmp;
	}
	tmp = false;
	for(int i=0;i<length;i++){
		cross2[i] = tmp;
		tmp = !tmp;
	}
	bool strArr[length];
	for(int i=0;i<length;i++){
		if(in[i] == '0') {
			strArr[i] = false;
		} else {
			strArr[i] = true;
		}
	}
	int ans1, ans2;
	ans1 = xorOp(strArr, cross1,length);
	ans2 = xorOp(strArr, cross2, length);
	if(ans1 > ans2){
		cout <<ans2 <<endl;
	} else {
		cout <<ans1 <<endl;
	}
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>

using namespace std;

enum Face
{
	TOP = 0,
	FRONT = 1,
	RIGHT = 2,
	LEFT = 3,
	BACK = 4,
	BOTTOM = 5,
};

void roll(vector<int> &f, char d, int n)
{
	int tmp;
	for (int i = 0; i < n; i++)
	{
		switch (d)
		{
		case 'E':
			tmp = f[TOP];
			f[TOP] = f[LEFT];
			f[LEFT] = f[BOTTOM];
			f[BOTTOM] = f[RIGHT];
			f[RIGHT] = tmp;
			break;
		case 'N':
			tmp = f[TOP];
			f[TOP] = f[FRONT];
			f[FRONT] = f[BOTTOM];
			f[BOTTOM] = f[BACK];
			f[BACK] = tmp;
			break;
		case 'S':
			tmp = f[TOP];
			f[TOP] = f[BACK];
			f[BACK] = f[BOTTOM];
			f[BOTTOM] = f[FRONT];
			f[FRONT] = tmp;
			break;
		case 'W':
			tmp = f[TOP];
			f[TOP] = f[RIGHT];
			f[RIGHT] = f[BOTTOM];
			f[BOTTOM] = f[LEFT];
			f[LEFT] = tmp;
			break;
		default:
			break;
		}
	}
}

int main()
{
	vector<int> f(6);
	int q;
	int top_init, front_init;
	int top, front;
	for (int i = 0; i < 6; i++)
	{
		cin >> f[i];
		if (i == TOP)
		{
			top_init = f[i];
		}
		else if (i == FRONT)
		{
			front_init = f[i];
		}
	}
	cin >> q;
	vector<int> res(q);
	for (int i = 0; i < q; i++)
	{
		cin >> top >> front;
		if (top != f[TOP])
		{
			if (top == f[FRONT])
			{
				roll(f, 'N', 1);
			}
			else if (top == f[RIGHT])
			{
				roll(f, 'W', 1);
			}
			else if (top == f[LEFT])
			{
				roll(f, 'E', 1);
			}
			else if (top == f[BACK])
			{
				roll(f, 'S', 1);
			}
			else if (top == f[BOTTOM])
			{
				roll(f, 'N', 2);
			}
		}
		if (front == f[FRONT])
		{
			res[i] = f[RIGHT];
		}
		else if (front == f[RIGHT])
		{
			roll(f, 'W', 1);
			roll(f, 'S', 1);
			roll(f, 'E', 1);
			res[i] = f[RIGHT];
		}
		else if (front == f[LEFT])
		{
			roll(f, 'E', 1);
			roll(f, 'S', 1);
			roll(f, 'W', 1);
			res[i] = f[RIGHT];
		}
		else if (front == f[BACK])
		{
			roll(f, 'W', 1);
			roll(f, 'S', 2);
			roll(f, 'E', 1);
			res[i] = f[RIGHT];
		}
	}
	for (int i = 0; i < q; i++)
	{
		cout << res[i] << endl;
	}
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n, i, tmp1, tmp2, ans=0;
    cin >> n;
    ll a[n], b[n], c[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    for(i=0; i<n; i++)
        cin >> b[i];
    for(i=0; i<n; i++)
        cin >> c[i];
    
    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);
    
    for(i=0; i<n; i++) {
        tmp1=lower_bound(a, a+n, b[i])-a;
        tmp2=n-(upper_bound(c, c+n, b[i])-c);
        ans += tmp1*tmp2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    string s;cin>>s;
    int cnt = 0;
    rep(i,3)if(s[i] == 'o')cnt++;
    cout<<700+100*cnt;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    char s[20];
    int count;
    int out=0;
    char ss[20]="CODEFESTIVAL2016";
    scanf("%s",s);
    for(count=0;s[count]!='\0';count++){
        if(s[count]!=ss[count]){out++;}

    }
    printf("%d",out);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long n,k;
long long a[200005];
long long f[200005];

bool cmp(long long x,long long y)
{
	return x > y;
}

int check(long long x)
{
	long long cnt=0;
	for(int i=1;i<=n;++i)
		if(a[i] * f[i] > x)
		   cnt+=a[i]-x/f[i];
	return cnt <= k;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i)
	    scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i)
	    scanf("%lld",&f[i]);
	sort(a+1,a+1+n);
	sort(f+1,f+1+n,cmp);
	long long l=0,r=1e18;
	while(l<r)
	{
		long long mid=(l+r)/2;
		if(check(mid))
		    r=mid;
		else  l=mid+1;
		//cout<<l<<" "<<r<<endl;
	}
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 6964
'use strict';

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var strlist = input.trim().split(' ');
//var strlist = 'Thank you for your mail and your lectures'.split(' ');
var strhash = {};
var maxlen = 0;
var lststr = '';
for (var i in strlist) {
	if (strlist[i] in strhash) {
		strhash[strlist[i]] += 1;
	} else {
		strhash[strlist[i]] = 1;
	}
	if (strlist[i].length > maxlen) {
		lststr = strlist[i];
		maxlen = strlist[i].length;
	}
}
var most = 0;
var mststr = '';
for (var property in strhash) {
	if (strhash[property] > most) {
		mststr = property;
		most = strhash[property];
	}
}
console.log(mststr + ' ' + lststr);

Measured memory_bytes: 15544
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int N,K;
vi PP;

int invmap[114514];
map<int,int> mm;
vi datas;
int main(){
	string str;
	cin>>str;
	bool flag=true;
	rep(i,str.size()){
		if(i%2==0&&str[i]=='L')flag=false;
		if(i%2==1&&str[i]=='R')flag=false;
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}




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

typedef long long LL;

const int N = 1e5+7, RT = 300;
int a[N];
LL sum[N][RT];

LL query(int l, int r, int d) {
    assert((r-l)%d==0);
    if (d < RT) {
        if (l<=d)    return sum[r][d];
        return sum[r][d] - sum[l-d][d];
    }

    LL ans = 0;
    for (int i=l; i<=r; i+=d)   ans += a[i];
    return ans;
}

vector<int> divs[N];
int cnt[N];

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

    for (int i=1; i<N; i++)
        for (int j=i; j<N; j+=i)
            divs[j].push_back(i);

    int n;
    cin>>n;
    n--;

    for (int i=0; i<=n; i++)    cin>>a[i];
    for (int i=1; i<RT && i<=n; i++) {
        for (int j=1; j<=n; j++) {
            sum[j][i] = a[j];
            if (j>=i)  sum[j][i] += sum[j-i][i];
        }
    }

    LL ans = 0;
    for (int a=1; a<n; a++) {
        for (int d: divs[n-a]) {
            if (d >= a) break;
            int k = (n-a)/d;
            if (a%d==0 && k*d>=a)   continue;
            LL x = query(a, n, d) ;
            LL y = query(d, k*d, d);
            LL cur =  x + y;
            ans = max(ans, cur);
//            cout<<a<<" "<<a-d<<" = "<<cur<<" "<<x<<" "<<y<<endl;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 245504
#include<stdio.h>
#include<string.h>
#define min(a,b) (a<b?a:b)

int main(void){
  char s[100001];
  scanf("%s",s);
  int i,len=strlen(s),r=0,b=0;
  for(i=0;i<len;i++)
    (s[i]-'1')?b++:r++;

  printf("%d",2*min(r,b));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define pque priority_queue<long long int >
#define pquem priority_queue<long long int ,vector<long long int>,greater<long long int> >
#define setbits(x) __builtin_popcountll(x)
#define mod 1000000007
#define inf 1e18 
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int ab[1000001];
void sieve()
{
	ab[1]=1;
	for(int i=2;i<1000001;i++)
	ab[i]=i;
	for(int i=4;i<1000001;i+=2)
	ab[i]=2;
    for(int i=3;i*i<1000001;i++)
    {
        if(ab[i]==i)
        {
            for(int j=i*i;j<1000001;j+=i)
            {
            	if(ab[j]==j)
                ab[j]=i;
            }
        }
    }
}
ll power(ll a,ll b)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
		ans*=a;
		b/=2;
		a*=a;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k,a,b,f=0;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			f=1;
			break;
		}
	}
	if(f==1)
	cout<<"OK"<<endl;
	else
	cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;
public class Main{
	static long[] size;
	static long[] patty;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long x = sc.nextLong();
		size=new long[n+1];
		patty=new long[n+1];
		size[0]=patty[0]=1;
		for(int i = 1; i<=n; i++){
			size[i]=size[i-1]*2+3;
			patty[i]=patty[i-1]*2+1;
		}
		System.out.println(dfs(n,x));
	}
	static long dfs(int lay,long number){
		if(lay==0){
			return 1;
		}
		if(number==1){
			return 0;
		}
		if(number<=size[lay]/2){
			return dfs(lay-1,number-1);
		}else if(number==(size[lay]/2+1)){
			return patty[lay-1]+1;
		}else{
			return patty[lay-1]+1+dfs(lay-1,number-size[lay-1]-2);
		}
	}
}

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

int main(void)
{
    string s; cin >> s;
    bool flag = true;
    int n = s.length();
    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] != s[n - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
        if (s[i] != s[n / 2 - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
        if (s[i + n / 2 + 1] != s[n - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
    int k, s, ans = 0;
    cin >> k >> s;
    for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
            int z = s - x - y;
            if (0 <= z && z <= k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


struct union_find {
    vector<int> parent;
    vector<int> size;
    int components = 0;

    union_find(int n = 0) {
        if (n > 0)
            init(n);
    }

    void init(int n) {
        parent.resize(n + 1);
        size.assign(n + 1, 1);
        components = n;
        for (int i = 0; i <= n; ++i) 
            parent[i] = i;
    }

    int find(int v) {
        return v == parent[v] ? v : parent[v] = find(parent[v]);
    }

    bool unite(int u, int v) {
        u = find(u);
        v = find(v);
        if (u == v)
            return false;
        if (size[u] < size[v]) 
            swap(u, v);
        parent[v] = u;
        size[u] += size[v];
        --components;
        return true;
    }
};


int main(){
    FIN;
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> ab(m);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        ab[i] = pair<int,int>(a,b);
    }

    ll ans = 0;

    for(int i=0;i<m;i++){
        union_find UF(n);
        for(int j=0;j<m;j++){
            if(i == j) continue;
            UF.unite(ab[j].first,ab[j].second);
        }
        
        int par_0 = UF.find(0);
        for(int j=1;j<n;j++){
            int par_j = UF.find(j);
            if(par_0 != par_j){
                ans++;
                break;
            }
        }
    }

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


Measured memory_bytes: 3668
#include<stdio.h>
int main(void){
    char A[255],B[255],C[255];
    int count,a,b,c;

    scanf("%s %s %s",A,B,C);

    for(count=0;A[count]!='\0';count++){
        a=count;
    }
    for(count=0;B[count]!='\0';count++){
        b=count;
    }
    
    if(A[a]==B[0] && B[b]==C[0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, m int
	var t string
	fmt.Scan(&n)
	s := make(map[string]int)
	ans := -100
	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		s[t]++
	}
	fmt.Scan(&m)
	for i := 0; i < m; i++ {
		fmt.Scan(&t)
		s[t]--
	}
	for _, v := range s {
		if v > ans {
			ans = v
		}
	}
	if ans < 0 {
		ans = 0
	}
	fmt.Println(ans)
}


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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin >> d.at(i);
  }
  int ans=0;
  for(int j=0;j<n-1;j++){
    for(int k=j+1;k<n;k++){
      ans+=d.at(j)*d.at(k);
    }
  }
  cout << ans << endl;
}

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

int main(void)
{
    long long int N;

    cin >> N;

    long long int ans = 0;
    for(long long int i = 1; i < N; ++i)
    {
        ans += (N-1)/i;
    }


    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

int main() {
	LL n;
	cin >> n;
	int cnt = 0;
	while(n > 0){
		n /= 2;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    int dpl[n + 1], dpr[n + 1];
    dpl[0] = 0;
    dpr[0] = 0;
    int last = -10000000;
    for (int i = 1; i <= n; ++i) {
        if (s[i - 1] == 'x') dpl[i] = dpl[i - 1];
        else if (last + c < i) {
            last = i;
            dpl[i] = dpl[i - 1] + 1;
        }
        else dpl[i] = dpl[i - 1];
    }
    last = -10000000;
    for (int i = 1; i <= n; ++i) {
        if (s[n - i] == 'x') dpr[i] = dpr[i - 1];
        else if (last + c < i) {
            last = i;
            dpr[i] = dpr[i - 1] + 1;
        }
        else dpr[i] = dpr[i - 1];
    }
    //for (int i = 0; i <= n; ++i) cout << dpr[i] << " ";
    for (int i = 0; i < n; ++i) {
        int left = i;
        int right = n - i - 1;
        if (s[i] == 'o' && dpl[left] + dpr[right] + 1 == k) cout << i + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5012
// Date: 2020-01-27

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}
LL inv(LL x, LL mod) { return qpow(x, mod-2, mod); }

LL fac[N], Inv[N];

LL C(int n, int m) {
    if(m == 0 || n == m) return 1;
    LL ans = fac[n] * Inv[m] % mod * Inv[n-m] % mod;
    return ans;
}

void add(LL& x, LL y) {
    x = (x + y + mod) % mod;
}

int main() {
    fac[0] = 1;
    rep(i, 1, N-1) fac[i] = fac[i-1] * i % mod, Inv[i] = inv(fac[i], mod);
    int k, n;
    scanf("%d%d", &k, &n);
    rep(i, 2, 2*k) {
        LL ans = 0;
        int num = i / 2;
        if(i > k+1) num -= (i-1-k);
        rep(j, 0, num) {
            if(2*j > n) break;
            LL val = C(num, j) * C(n-2*j+k-1, k-1) % mod;
            if(j & 1) add(ans, -val);
            else add(ans, val);
        }
        printf("%lld\n", ans);
    }

    return 0;
}

Measured memory_bytes: 1792
import math
def resolve():
    K = int(input())
    D = []
    ans = 0
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            D.append(math.gcd(b, c))

    for d in D:
        for a in range(1, K+1):
            ans += math.gcd(a, d)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9296
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define int ll int 
#define ll long long
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
using namespace std::chrono;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int n,k;
	cin>>n>>k;
	vi v(k);
	in(k)
		cin>>v[i];
	int sum=accumulate(all(v),0);
	sum=n-sum>=0?n-sum:-1;
	cout<<sum<<endl;
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "h" "h.cpp" -fsanitize=address
// -fsanitize=undefined -D_GLIBCXX_DEBUG -g

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

using namespace std;

struct UFNode
{
	UFNode *parent;
	long rank, pos;
	UFNode() :parent(nullptr), rank(0), pos(0) {}
	UFNode &Find() {
		if (parent == nullptr)
			return *this;
		//return *(parent = &parent->Find());
		auto t = &parent->Find();
		pos += parent->pos;
		return *(parent = t);
	}
	long Union(UFNode &n, long d) {
		auto &r = Find(), &nr = n.Find();
		if (&r == &nr)
			return pos + d == n.pos;
		if (r.rank < nr.rank) r.parent = &nr, r.pos = n.pos - pos - d;
		else nr.parent = &r, r.rank += r.rank == nr.rank, nr.pos = pos - n.pos + d;
		return -1;
	}
} u[111111];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		long l, r, d;
		scanf("%ld%ld%ld", &l, &r, &d);
		if (!u[l].Union(u[r], d)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

ll solve(ll W, ll H) {
    ll mi = min(W, H);
    for (ll i = 1; i < W; i++) {
        ll wi = W - i;
        ll C1 = i * H;
        ll C2 = wi*(H/2);
        ll C3 = wi*((H/2) + (H%2 == 1));
        ll C4 = wi / 2 * H;
        ll C5 = (wi - wi / 2) * H;
        ll sma = max({C1,C2,C3});
        ll smi = min({C1,C2,C3});
        ll sma2 = max({C1,C4,C5});
        ll smi2 = min({C1,C4,C5});
        smi = min(sma - smi, sma2 - smi2);
        mi = min(mi, smi);
    }
    return mi;
}
int main() {
    ll H, W; cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << min(solve(W, H), solve(H, W)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    int t;
    t=1;
    while(t--)
    {
    	ll n,k;
    	cin>>n>>k;
    	vector<ll> arr(n+1);
    	for(ll i=1;i<=n;i++)
    	{
    		cin>>arr[i];
		}
	
		for(ll i=k+1;i<=n;i++)
		{
		
			if(arr[i-k]<arr[i])
			{
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
		}
	}
}

Measured memory_bytes: 4756
#include <iostream>
#include <vector>

using namespace std;

int maxCandles(vector<vector<int>> candles)
{
    vector<vector<int>> dp(2, vector<int>(candles[0].size(), 0));
    int n = candles[0].size();

    dp[0][0] = candles[1][n - 1];
    dp[1][0] = 0;

    for (int i = 1; i < n; i++)
    {
        dp[1][i] = dp[1][i - 1] + candles[1][n - i];
        dp[0][i] = max(candles[0][n - i] + dp[0][i - 1], candles[1][n - i - 1] + dp[1][i]);
    }

    return dp[0][n - 1] + candles[0][0];
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<vector<int>> candles (2 , vector<int> (n,0));
    for(int i = 0; i < n; i++)
        cin >> candles[0][i];
    for(int i = 0; i < n; i++)
        cin >> candles[1][i];
    cout << maxCandles(candles) << endl;
    return 0;
}


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

int main(){
  
    int n,m;
    int i;
    int a[12000];
    int sum = 0;

	scanf("%d %d", &n, &m);
  
    for(i=0; i<m; i++){
    	scanf("%d", &a[i]);
    }
 	
    for(i=0; i<m; i++){
    	sum += a[i];
    }
  
    if((n - sum) >= 0){
    	printf("%d", n-sum);
    }else{
    	printf("-1");
    }
  
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

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

    int MAXV = A[N-1];
    vector<int> sumi(MAXV+1, 0);
    int now = 0;
    int cnt = 0;

    rep(i, N){
        if (sumi[A[i]] != 1) {
            // cnt++;
            now = A[i];
            sumi[now] = 1;

            while(now + A[i] <= MAXV){
                now += A[i];
                sumi[now] = 1;
            }
            // cout << sumi[21] << sumi[24] << endl;

            if (i < N-1){
                if (A[i] != A[i+1]){
                    // cout << A[i] << endl;
                    cnt++;
                }
            }else{
                // cout << A[i] << endl;
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 7920
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if not arr:
        arr.append([n, 1])
    return arr


def solve():
    N, M = map(int, rl().split())
    MOD = 10 ** 9 + 7
    
    if M == 1:
        print(1)
        return
    
    facts = factorization(M)
    com = Combination(10 ** 5 + 500, MOD)
    
    ans = 1
    for _, exp in facts:
        ans = ans * com.ncr(exp + N - 1, exp) % MOD
    print(ans)


if __name__ == '__main__':
    solve()


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

class Edge {
public:
    LL u;
    LL v;
    LL w;

    Edge() {
        u = 0;
        v = 0;
        w = 0;
    }

    Edge(LL u, LL v, LL w) {
        this->u = u;
        this->v = v;
        this->w = w;
    }
};

struct Node {
    LL x;
    vector<LL> neighbors;
};

int main() {
    LL N, Q;
    cin >> N >> Q;

    vector<Edge> edges;
    edges.resize(N - 1);

    REP(i, N - 1) {
        LL a, b;
        cin >> a >> b;
        edges[i].u = a;
        edges[i].v = b;
        edges[i].w = 1;
    }

    vector<pair<LL, LL>> qs;
    qs.resize(Q);

    REP(i, Q) {
        LL p, x;
        cin >> p >> x;
        qs[i] = make_pair(p, x);
    }

    vector<Node> nodes;
    nodes.resize(N + 1);
    FOR(i, 1, N + 1) {
        nodes[i].x = 0;
    }
    for(auto e : edges) {
        nodes[e.u].neighbors.push_back(e.v);
    }

    for(auto q : qs) {
        nodes[q.first].x += q.second;
    }

    queue<pair<LL, LL>> kyu;
    for(auto neighbor : nodes[1].neighbors) {
        kyu.push(make_pair(1, neighbor));
    }

    for(;!kyu.empty();) {
        LL f, t;
        f = kyu.front().first;
        t = kyu.front().second;
        kyu.pop();
        nodes[t].x += nodes[f].x;
        for(auto neighbor : nodes[t].neighbors) {
            kyu.push(make_pair(t, neighbor));
        }
    }

    FOR(i, 1, N + 1) {
        cout << nodes[i].x;
        if(i != N) {
            cout << " ";
        }else{
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 22656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

long long int MOD = 1000000007;

int N, K, a[100005], b[100005];

vector<int> Adj[100005];

int used_num[100005];

int used[100005];

long long int ans;

void CALC(int k , int num) {

	used[k] = 1;
	
	if (K - num <= 0) { ans = 0; }
	ans *= K - num;
	ans %= MOD;

	int tmp;

	if (num > 0) { tmp = 1; }
	else { tmp = 0; }

	for (auto y : Adj[k]) {

		if (used[y] == 0) { tmp++;  CALC(y, tmp); }
	}


}

int main(void) {

	cin >> N >> K;

	for (int i = 1; i <= N - 1; i++) {
		cin >> a[i] >> b[i];
		Adj[a[i]].push_back(b[i]);
		Adj[b[i]].push_back(a[i]);
	}

	 ans = 1;

	CALC(1,0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, K;
    ll count=0;
    cin>>N>>K;
    while(true){
        if(N==0) break;
        N/=K;
        count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product
input_int_list = list(map(int, input()))

for operator_comb in product(range(2), repeat = len(input_int_list)-1):
    sum_value = input_int_list[0]
    formula_str = str(input_int_list[0])
    for i, operator in enumerate(operator_comb):
        if operator == 0:
            sum_value += input_int_list[i+1]
            formula_str += '+' + str(input_int_list[i+1])
        else:
            sum_value -= input_int_list[i+1] 
            formula_str += '-' + str(input_int_list[i+1])
    if sum_value == 7:
        print(formula_str + '=7')
        break

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = 1;
		while(k*(k-1)/2<n) {
			k++;
		}
		if(k*(k-1)/2==n) {
			System.out.println("Yes");
			List<List<Integer>> s = new ArrayList<>();
			for(int i=0;i<k;i++) {
				List<Integer> list = new ArrayList<>();
				s.add(list);
			}
			int num = 1;
			int listCounter1 = 0;
			int listCounter2 = 1;
			while(num<=n) {
				s.get(listCounter1).add(num);
				s.get(listCounter2).add(num);
				listCounter2++;
				if(listCounter2==k) {
					listCounter1++;
					listCounter2 = listCounter1 + 1;
				}
				num++;
			}
			
			System.out.println(k);
			for(int i=0;i<k;i++) {
				System.out.print(k-1);
				List<Integer> list = s.get(i);
				for(int j=0;j<k-1;j++) {
					System.out.print(" "+list.get(j));
				}
				System.out.println();
			}
		}else {
			System.out.println("No");
		}
		in.close();
	}

}


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

int main() {
    int len, a[3];
    string s;
    cin >> s;
    len = s.length();
    fill(a, a+3, 0);
    for(int i=0;i<len;i++){
        a[s[i] - 'a']++;
    }
    sort(a, a+3);
    if(a[2] - a[0] < 2){
        puts("YES");
    }else{
        puts("NO");
    }
	return 0;
}

Measured memory_bytes: 512
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;

  int ans = 0;
  if (a > b)
  {
    ans += a;
    a--;
  } else {
    ans += b;
    b--;
  }

  if (a > b)
  {
    ans += a;
    a--;
  } else {
    ans += b;
    b--;
  }

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


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

int main()
{
    int n;
    cin>>n;int ans=0;
    for(int i=1;i<=n;i++){
        int temp;
        cin>>temp;
        if(i%2!=0&&temp%2!=0)ans++;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 100000000000000;
typedef pair<int, int> P;
bool judge(int X) {
	if (X <= 0) return 0;
	return 1;
}
int main() {
	int n, k, q;
	cin >> n >> k >> q;
	int i;
	int Q[110000];
	for (i = 1; i <= q; i++) {
		cin >> Q[i];
	}
	int S[110000];
	for (i = 1; i <= n; i++) {
		S[i] = k - q;
	}
	for (i = 1; i <= q; i++) {
		S[Q[i]]++;
	}
	for (i = 1; i <= n; i++) {
		if (judge(S[i])) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" <<  endl;
		}
	}
	return(0);
}

Measured memory_bytes: 1408
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define mkpr make_pair
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define whole(x) (x).begin(),(x).end()
#define revwhole(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define init0(x) memset(x,0,sizeof(x));

using namespace std; 
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> gharKaSet;
 
const int maxlimit=2e5+2;
const ll inf=1e18;
//TTBDC

int main()
{
  fatafat
  int n,k,L,R;
  cin>>n>>k;
  int childreq;
  // for(int i=0;i<n;i++){
  //   cin>>childreq;
  //   for(int used=k;used>=0;used--){
  //     for(int ketli=1;ketli<=min(childreq,k-used);ketli++){
  //       dp[used+ketli] = (dp[used+ketli]+dp[used])%MOD;
  //     }
  //   }
  // }

  // (used+1) thi (used + min(chilreq,k-usedd)) ne add karvanu and aa bau vaar thai shake
  // so ene khali pref sum mukine pachi chhele add karvanu

  vector<ll> dp(k+1);
  dp[0]=1;
  ll prefsum=0;
  for(int i=0;i<n;i++){
    cin>>childreq;
    vector<ll> fakedp(k+1);
    for(int cused=k;cused>=0;cused--){
      L = cused + 1;
      R = cused + min(childreq,k-cused);
      if(L<=R){
        fakedp[L] = (fakedp[L] + dp[cused])%MOD;
        if(R+1<=k)fakedp[R+1] = (fakedp[R+1] - dp[cused] + MOD)%MOD;
      }
    }
    prefsum = 0;
    for(int j=0;j<=k;j++){
      prefsum = (prefsum + fakedp[j])%MOD;
      dp[j] = (dp[j] + prefsum)%MOD;
    }
  }
  cout<<dp[k];
  return 0;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {

    string s;
    int w;
    cin >> s >> w;
    rep(i, s.size()) {
        if (i % w == 0) cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[list(map(int,input().split())) for _ in range(m)]

tmax=sum(t)

for i in range(m):
    print(tmax+p[i][1]-t[p[i][0]-1])


Measured memory_bytes: 3060
import math
import itertools

N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

kumi = [x for x in range(N)]

def kyori(x1,y1,x2,y2):
    return math.sqrt((y2 - y1)**2 + (x2 - x1)**2)
sum_kyori = 0.0
for i in itertools.permutations(kumi):
    for j in range(N-1):
        sum_kyori += kyori(x[i[j]],y[i[j]],x[i[j+1]],y[i[j+1]])
print( sum_kyori/math.factorial(N))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
const int MAXN=1e5+5;
int A[MAXN];
int n;
bool find(int x){
	if(x<A[0]||x>A[n-1])return false;
	int low=0;
	int high=n-1;
	while(high>low){
		//cout<<high<<" "<<low<<endl;
		int mid=(high+low)/2;
		if(A[mid]==x)return true;
		else if(A[mid]>x){
			high=mid;
		}
		else if(A[mid]<x){
			low=mid+1;
		}
	}
	if(A[low]!=x)return false;
	else return true;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>A[i];
	int q,x;
	int res=0;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>x;
		//cout<<"?"<<endl;
		if(find(x)){
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=1000005,maxm=306;
const double pi=acos(-1.0);
const ll mod=1000000007;
const double eps=1e-8;


ll a,b;
double bb;

int main()
{
	int i,j;
	scanf("%lld %lf",&a,&bb);
	b=bb*100+eps;
	printf("%lld\n",a*b/100);
    return 0;
}


Measured memory_bytes: 3828