akhauriyash/Code-Regression huggingface dataset:
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t c = 0;

    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;

        for (;;) {
            if (t % 2 == 0) {
                t = t/2;
                c++;
            }
            else {
                break;
            }
        }
    }

    std::cout << c << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char c[h][w];
rep(i,h) rep(j,w) {cin>>c[i][j];}
  
  long long count=0; //条件を満たすパターンをカウント
  rep(mi,1<<h)rep(mj,1<<w){//1<<3(=3桁シフト1000) repの場合000~111(1000-1)を表す
  int black=0;
    rep(i,h)rep(j,w){
      if((mi>>i)&1){continue;}//mi(行)のi桁目が1⇒その行は全部消滅
       if((mj>>j)&1){continue;}//mj(列)のj桁目が1⇒その列は全部消滅
      if(c[i][j]=='#'){black++;}//行も列も消えてないマスが黒⇒blackをカウント
    }
    if(black==k){//条件を満たす場合
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll h;
  cin>>h;
  ll htmp=h;
  int n = 0;
  while(htmp!=0) {
    htmp/=2;
    n++;
  }
  //  cout<<n<<endl;
  ll ans=1;
  repeat(i,1,n) {
    //    cout << "ans="<<ans<<endl;
    ans+=(1LL<<i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){   
// Your code here!   
int n,x,i,j,k,c;   
c=0;   
while(1){    
   scanf("%d %d",&n,&x);    
   if(n == 0 && x == 0)break;   
    for(i =1;i <n+1;i++){ 
          for(j=1;j < n+1;j++){  
             for(k=1;k<n+1;k++){
                   if(j !=k && i != j&& i != k&& i+j+k==x){
                    c=c+1;
                   }
               }
           }
       }
       printf("%d\n",c/6);
   c = 0;
   }
       
return 0;
}


Measured memory_bytes: 2076
#encoding:utf-8 No.0522 2014.12.11
while gets
  joi = 0
  ioi = 0
  i = 0

  while i < $_.length - 2
    joi += 1 if $_[i,3] == "JOI"
    ioi += 1 if $_[i,3] == "IOI"
    i += 1
  end

  puts joi,ioi
end

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

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

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

   int N;
   cin>>N;
   vector<int>s(N);
   for(int i=0;i<N;i++)cin>>s[i];
   sort(s.begin(),s.end());
   int MAX = 0;

   bool flg = true;
   for(int i=0;i<N;i++){
      if(s[i]%10!=0)flg=false;
   }
   if(flg){
      cout<<0<<endl;
      return 0;
   }

   for(int i=0;i<N;i++)MAX+=s[i];

   int miss=0;
   if(MAX%10==0){
      for(int i=N-1;i>=0;i--){
         if(s[i]%10!=0)miss = s[i];
      }
   }

   cout<<MAX-miss<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int b = 8;
int n;
int v[1 << 18];
int w[1 << 18];
vector<pair<int, int>> z[1 << 18];
vector<pair<int, long long>> z2[1 << 18];
vector<pair<int, long long>> z3[1 << 18];
long long ans[100000];

void dfs(int x, int d, long long sv, int sw) {
    int i;
    
    for (i = 0; i < z[x - 1].size(); i++) {
        int l = z[x - 1][i].first;
        int p = z[x - 1][i].second;
        
        if (sw <= l) ans[p] = max(ans[p], sv);
        if (sw + w[x - 1] <= l) ans[p] = max(ans[p], sv + v[x - 1]);
    }
    
    if (d == b) {
        z2[x - 1].push_back(make_pair(sw, sv));
        z2[x - 1].push_back(make_pair(sw + w[x - 1], sv + v[x - 1]));
        return;
    }
    
    if (x * 2 <= n) {
        dfs(x * 2, d + 1, sv, sw);
        
        if (sw + w[x - 1] <= 100000) dfs(x * 2, d + 1, sv + v[x - 1], sw + w[x - 1]);
    }
    
    if (x * 2 + 1 <= n) {
        dfs(x * 2 + 1, d + 1, sv, sw);
        
        if (sw + w[x - 1] <= 100000) dfs(x * 2 + 1, d + 1, sv + v[x - 1], sw + w[x - 1]);
    }
}

void dfs2(int x, long long sv, int sw, int p) {
    if (x >= (1 << b) && x < (1 << (b + 1))) {
        pair<int, long long> pp = make_pair(sw, 1e18);
        int q = upper_bound(z3[x - 1].begin(), z3[x - 1].end(), pp) - z3[x - 1].begin() - 1;
        ans[p] = max(ans[p], sv + z3[x - 1][q].second);
        return;
    }
    
    dfs2(x / 2, sv, sw, p);
    if (sw >= w[x - 1]) dfs2(x / 2, sv + v[x - 1], sw - w[x - 1], p);
}

int main() {
    int q, i, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d %d", &v[i], &w[i]);
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        z[x - 1].push_back(make_pair(y, i));
    }
    
    dfs(1, 0, 0, 0);
    
    for (i = (1 << b); i < (1 << (b + 1)); i++) {
        sort(z2[i - 1].begin(), z2[i - 1].end());
        
        for (j = 0; j < z2[i - 1].size(); j++) {
            if (z3[i - 1].size() > 0 && z3[i - 1].back().second >= z2[i - 1][j].second) continue;
            z3[i - 1].push_back(z2[i - 1][j]);
        }
    }
    
    for (i = (1 << (b + 1)); i <= n; i++) {
        for (j = 0; j < z[i - 1].size(); j++) {
            dfs2(i, 0, z[i - 1][j].first, z[i - 1][j].second);
        }
    }
    
    for (i = 0; i < q; i++) printf("%lld\n", ans[i]);
    
    return 0;
}


Measured memory_bytes: 31608
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

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

#include <iostream>
#include <vector>
using namespace std;

struct WeightedUnionFind {
  vector<int> par;
  vector<int> rank;
  vector<int> size;
  vector<int> diff_weight;
  
  WeightedUnionFind(int N) : par(N), rank(N), size(N), diff_weight(N) {
    for (int i = 0; i < N; i++) {
      par[i]  = i;
      rank[i] = 0;
      size[i] = 1;
      diff_weight[i] = 0;
    }
  }

  int find(int x) {
    if (par[x] == x) return x;
    else {
      int r = find(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }
  
  bool unite(int x, int y, int w) {
    w += weight(x); w -= weight(y); 
    x = find(x); y = find(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w;    
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x; 
    diff_weight[y] = w; 
    return true;
  }

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

  int weight(int x) {
    find(x);
    return diff_weight[x];
  }

  int diff(int x, int y) {
    if (find(x) != find(y)) return -1;
    return weight(y) - weight(x);
  }
  
  int get_size(int x) {
    int rx = find(x);
    return size[rx];
  }
  
};


int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  int L, R, D;

  cin >> N >> M;

  WeightedUnionFind wuf = WeightedUnionFind(N);
  for (int i = 0; i < M; i++) {
    cin >> L >> R >> D;
    L--; R--;

    if (!wuf.same(L, R)) wuf.unite(L, R, D);
    else {
      int d = wuf.diff(L, R);
      if (d != D) {
	cout << "No" << endl;
	return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1920
import java.util.*;
        public class Main {
        	public static void main(String[] args){
        		Scanner sc = new Scanner(System.in);
        		long a = sc.nextLong();
        		long b = sc.nextLong();
        		long k = sc.nextLong();
              if(a+b<=k){
                a=0;b=0;}
              else if(a<=k){
                b=a+b-k;a=0;}
              else{a=a-k;}
        		System.out.println(a+ " " +b);
        	}
        }

Measured memory_bytes: 23252
#include <stdio.h>

void sosu(int n,int *a){
    int i,j;
    for(i=0;i<=n;i++) a[i]=1;
    a[0]=a[1]=0;
    for(i=2;i<=n;i++){
        if(a[i]==1){
            for(j=2;i*j<=n;j++) a[i*j]=0;
        }
    }
}

int main(void){
    int n;
    int a[50001];
    sosu(50000,a);
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        int i,count=0;
        for(i=2;i<=n/2;i++){
            if(a[i]==1&&a[n-i]==1) count++;
        }
        printf("%d\n",count);
    }
    return 0;
}


Measured memory_bytes: 2044
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if (n == 1 && a != b) {
		cout << 0 << endl;
		return 0;
	}
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	cout << (b - a) * (n - 2) + 1 << endl;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)


int prob(int n, int* arr, int index,int dp[][19])
{
	//cout << "entering for n = " << n << endl;
	if(dp[n][index] >= 0)return dp[n][index];
	if(n<6)return n;
	else
	{
		int ans = 10000000;
		REP(i,0,index)
		{
			if(n-arr[i] >= 0)
			{
				int temp = prob(n-arr[i],arr,i+1,dp);
				ans = min(ans,1+temp);
			}
		}
		dp[n][index] = ans;
		return ans;
	}
}



int main()
{
	int n;
	cin >> n;
	int arr[18];
	int dp[100001][19];
	REP(i,0,100001)
	{
		REP(j,0,19)dp[i][j] = -1;
	}

	REP(i,0,9)
	{
		arr[i] = pow(6,i+1);
		arr[i+9] = pow(9,i+1);
	}
	sort(arr,arr+18);



	//array constructed
	int ans = prob(n,arr,18,dp);
	cout << ans;
}


Measured memory_bytes: 8960
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
bingo = [[0 for _ in range(3)] for _ in range(3)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                bingo[j][k] = True
if (bingo[0][0] and bingo[1][0] and bingo[2][0]) or (bingo[0][1] and bingo[1][1] and bingo[2][1]) or (bingo[0][2] and bingo[1][2] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[0][1] and bingo[0][2]) or (bingo[1][0] and bingo[1][1] and bingo[1][2]) or (bingo[2][0] and bingo[2][1] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[1][1] and bingo[2][2]) or (bingo[0][2] and bingo[1][1] and bingo[2][0]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << max(0,b+c-a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

	s += s;
	s += s;
	//cout << s << endl;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == t[0]){
			for(int j = 0; j < t.size(); j++){
				if(i+j > s.size() || s[i+j] != t[j]) break;

				if(j == t.size()-1){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	char a;
	cin >> a;
	if (a >= 'A'&&a <= 'Z') {
		ps(A);
	}
	else {
		ps(a);
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll for long long

int main() {
    int K;
    string S;
    cin >> K >> S;

    if (S.length() > K) {
        rep(i, K) {
            cout << S.at(i);
        }
        cout << "...";
        cout << endl;
    } else {
        cout << S << endl;
    }
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,k;
  cin >> n >> k;
  int ans = k;
  rep(i,0,n-1) ans *= k-1;
  cout << ans << endl;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int S,R=0;
	for(int i=0;i<10;i++){
		cin>>S;
		R+=S;
	}




	cout<<R<<endl;


	return 0;
}

Measured memory_bytes: 3080
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,z,w,m,v,i,p;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>z>>p;
  std::vector<ll> v(n);
  rep(i,n) cin>>v[i];
  if(n==1) cout<<abs(v[n-1]-p)<<endl;
  else cout<<max(abs(v[n-1]-v[n-2]),abs(v[n-1]-p))<<endl;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main()
{
        ll A, B, C, D, E, N;
        cin >> N >> A >> B >> C >> D >> E;
        ll res = min({A, B, C, D, E});
  ll ans;
if(res==1){        ans = (ll)(N/res) + 4;
} else{
        ans = (ll)(N/res) + 5;}

        cout << ans << endl;

        return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,k,ans=0;

vector<int> G[maxn];

int dep[maxn],fa[maxn];

void dfs(int u){
	dep[u]=1;
	for(auto v:G[u]){
		fa[v]=u;
		dfs(v);
		dep[u]=max(dep[u],dep[v]+1);
	}
	if(u>1&&dep[u]==k&&fa[u]>1)dep[u]=0,ans++;
}

void Work(){
	dfs(1);
	iout(ans);
}

void Init(){
	read(n,k);
	REP(i,1,n){
		int x;read(x);
		if(i>1)G[x].PB(i);else ans+=x!=1;
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 11136
#include<iostream>

using namespace std;

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

	//ペンキの種類を計算
	if (a == b && b == c) {
		cout << "1" << endl;
	}
	else if (a == b && b != c) {
		cout << "2" << endl;
	}
	else if (a == c && c != b) {
		cout << "2" << endl;
	}
	else if (b==c && c!=a) {
		cout << "2" << endl;
	}
	else {
		cout << "3" << endl;
	}

}

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,L,T = MI()
q,r = T//L,T % L
A = []
a = 0  # 開始時点で、(時計回りの蟻の数)-(半時計まわりの蟻)
for i in range(N):
    x,w = MI()
    if w == 1:
        a += 1
        for j in range(-1,2):
            A.append(x+r+j*L)
    else:
        a -= 1
        for j in range(-1,2):
            A.append(x-r+j*L)
A.sort()
ANS = [A[i] % L for i in range(N,2*N)]
for i in range(N):
    print(ANS[(i+q*a) % N])


Measured memory_bytes: 92388
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+5;
int dp[MAX][3],a[MAX],b[MAX],c[MAX];
int n,k;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)   {

        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
        {
            dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
            dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
            dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];



        }

   //     for(int i=0;i<n;i++)    cout<<dp[i]<<" ";

        cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ichi;
  ichi=max({a,b,c});
  int nokori=a+b+c-ichi;
  for(int i=1;i<=k;i++){
    ichi*=2;
  }
  cout<<nokori+ichi<<endl;
}

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

int main(){

  int N,K,tmp,ans;
  int A[200000],cnt_A[200000];
  //set<int> set_A;

  cin >> N >> K;
  for(int i = 0; i < 200000; i++){
    A[i] = 0;
    cnt_A[i] = 0;
  }
  for(int i = 0; i<N; i++){
    cin >> A[i];
  }

  for(int i = 0; i < N; i++){
    cnt_A[A[i]]++;

    //cnt_A.push_back(count(A.begin(),A.end(),i));
  }
  sort(cnt_A,cnt_A+200000,greater<int>());

  //cout << cnt_A.size() << endl;
  //cout << cnt_A[cnt_A.size()] << endl;

  tmp = 0;
  for(int i = 0;i < K;i++){
    tmp += cnt_A[i];
  }
  ans = N-tmp;

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


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

int main(){
  int n; cin >> n;
  int ichi=n%10;
  if (ichi == 3){
    cout << "bon" << endl;
  }
  else if (ichi == 0 || ichi == 1 || ichi == 6 || ichi == 8){
    cout << "pon" << endl;
  }
  else {cout << "hon" << endl;}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  rep(i,n){
    cout << s[i] << t[i];
  }
  cout << "" << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
n = int(input())
tbl = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for n in range(n):
    b, f, r, v = map(int, input().split())
    tbl[b-1][f-1][r-1]+=v

for s, k in enumerate(tbl):
    for j in k:
        for i in j:
            print(f' {i}', end='')
        print()
    if s == len(tbl)-1:
        continue
    print('####################')


Measured memory_bytes: 5636
N, K = map(int, input().split())
ai = list(map(int, input().split()))
for i in range(N):
    ai[i] -= 1
    
import math
dv = []
dv.append(ai)
for k in range(1, int(math.log2(K)) + 1):
    l = [0] * N
    dv.append(l)
    for n in range(N):
        dv[k][n] = dv[k - 1][dv[k - 1][n]]
        
#a = []
now = 0
for i in range(int(math.log2(K)) + 1):
    if K >> i & 1:
        #a.append(i)
        now = dv[i][now]
print(now + 1)

Measured memory_bytes: 173552
A,B,C,X,Y=map(int, raw_input().split())

val1=A*X+B*Y

if X>=Y:
	val2=(C*2)*Y+A*(X-Y)
elif Y>X:
	val2=(C*2)*X+B*(Y-X)

val3=(C*2)*max(X,Y)

print min(val1,val2,val3)




Measured memory_bytes: 2568
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef long long ll;

int n, m;
ll res;

int main()
{
	scanf("%d %d", &n, &m);
	res = ll(n - m) * 100 + ll(m) * 1900;
	while (m--) res *= 2ll;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <ctime>
#include <set>
using namespace std;

#define fs first
#define sc second
#define pb push_back
#define mp make_pair 
typedef pair<int, int> pii;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;

const int N = 1e5 + 10;
const int mo = 1e9 + 7;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mo)
		if(b & 1) ans = (ll) ans * a % mo;
	return ans;
}

int main() {
	int n; scanf("%d", &n); bool ok = 1;
	while(n --) {
		int x; scanf("%d", &x);
		if(x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
			ok = 0;
		}
	}
	puts(ok ? "APPROVED" : "DENIED");
	return 0;
} 

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	llint n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	llint tmp = min({ a,b,c,d,e });
	cout << 4 + (n + tmp - 1) / tmp << endl;
	return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	int dp[n];
	dp[0] = h[0] - 1;
	bool ans = true;
	for(int i = 0; i < n - 1; i++) {
		if(dp[i] < h[i + 1]) {
			dp[i + 1] = h[i + 1] - 1;
		}else if(dp[i] == h[i + 1]) {
			dp[i + 1] = h[i + 1];
		}else if(dp[i] > h[i + 1]) {
			ans =false;
		}
	}
	if(ans) {
		printf("%s\n", "Yes");
	}else {
		printf("%s\n", "No");
	}
}

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));

int cnt[10000005];

void divisor()
{
    for(int i=1;i<=10000005;i++)cnt[i]=1;
    for(int i=2;i<=10000000;i++){
        for(int j=i;j<=10000000;j+=i)
            cnt[j]++;
    }
}

int main()
{
    divisor();
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
        ans+=(i*cnt[i]);
    cout<<ans<<endl;
}



Measured memory_bytes: 42676
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int n, d, tot=0;


	cin >> n >> d;

	long double dist, aux1, aux2, x, y;
	for(long int i=0; i<n; i++){
		cin >> x;
		cin >> y;

		aux1 = x*x;
		aux2 = y*y;

		if(aux1<0){
			aux1*=-1;
		}
		if(aux2<0){
			aux2*=-1;
		}

		dist = sqrt(aux1+aux2);
		if(dist<=d){
			tot++;
		}
	}

	cout << tot << endl;

	return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e18
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const ll MOD = 1e9 + 7;
const int MAX = 1e6+ 6;
vector<int>edg[MAX];
ll dp[MAX][2];

void dfs(int node, int p) {
    
    dp[node][0] = dp[node][1] = 1;
    
    int cnt = 0;
    for(auto x: edg[node]) {
        if( p == x) continue;
        cnt++;
    }
    if(cnt == 0) return ;
    
    
    for(auto x : edg[node]) {
        if(x == p) continue;
        dfs(x, node);
        dp[node][1] = (dp[node][1] * dp[x][0])%MOD;
        dp[node][0] = (dp[node][0] * (dp[x][0] + dp[x][1]) %MOD) %MOD;
    }
}


int main()
{
    fastRead;
    int n;
    cin>>n;
    for(int i =1 ;i < n ; i++ ) {
        int u, v;
        cin>>u>>v;
        edg[u].push_back(v);
        edg[v].push_back(u);
    }
    
    dfs(1, -1);
    cout<<(dp[1][0] + dp[1][1])%MOD<<'\n';
    
}

Measured memory_bytes: 38608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001;
const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n, W;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> W;
  vll w(n), v(n);
  rep(i, 0, n) cin >> w[i] >> v[i];
  ll bottom = *min_element(ALL(w));
  vll item[4];
  rep(i, 0, n) {
    item[w[i] - bottom].pb(v[i]);
  }
  rep(i, 0, 4) {
    sort(ALL(item[i]), greater<int>());
    item[i].insert(item[i].begin(), 0);
    rep(j, 0, item[i].size()) 
      item[i][j+1] += item[i][j];
  }
  ll ans = 0;
  rep(a, 0, item[0].size()) {
    rep(b, 0, item[1].size()) {
      rep(c, 0, item[2].size()) {
        rep(d, 0, item[3].size()) {
          ll weight = 0, val = 0;
          weight += a * bottom;
          val += item[0][a];
          weight += b * (bottom + 1);
          val += item[1][b];
          weight += c * (bottom + 2);
          val += item[2][c];
          weight += d * (bottom + 3);
          val += item[3][d];
          if (weight <= W) ans = max(ans, val);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
'''input
31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0
'''

n = int(input())
arr = list(map(int, input().split()))
arr.sort()
ans = 1
for i in arr:
	ans = ans*i 
	# print(ans, i)
	if(ans > 1e18):
		print(-1)
		exit()


print(ans)

Measured memory_bytes: 21556
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	set<int> s,t;
	int i,n,m,a,b;
	cin>>n>>m;
	rep(i,m){
		cin>>a>>b;
		if(a>b)swap(a,b);
		if(a==1) s.insert(b);
		if(b==n) t.insert(a);
	}
	bool ch=false;
	
	set<int>::iterator it;
	for(it=t.begin();it!=t.end();it++){
		if(s.find(*it)!=s.end()){
			ch=true;
			break;
		}
	}
	
	if(ch)cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	
//////////////////////////////////////////////////////
return 0;}











Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();
        sc.close();

        StringBuilder sb = new StringBuilder();
        for(char c: s) {
            if(Character.isUpperCase(c)) {
                sb.append(Character.toLowerCase(c));
            } else {
                sb.append(Character.toUpperCase(c));
            }
        }
        System.out.println(sb);
    }
}



Measured memory_bytes: 26084
#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int main() {
    int N, *L;
    scanf("%d",&N);
    L = (int *)malloc(sizeof(int)*N);

    int i,j,k, triangles=0;
    for (i=0; i<N; i++)  scanf("%d", L+i);

    qsort(L, N, sizeof(int), cmp);

    for (i=0; i<N-2; i++) {
        k = i+2;
        for (j=i+1; j<N-1; j++) {
            while (k<N && L[k] < L[i]+L[j])  k++;
            triangles += (k - j - 1);
        }
    }

    printf("%d", triangles);
    free(L);
    return 0;
}

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

int keta_of(int n) {
    if (n < 10) {
        return 1;
    } else if (n < 100) {
        return 2;
    } else if (n < 1000) {
        return 3;
    } else if (n < 10000) {
        return 4;
    } else if (n < 100000) {
        return 5;
    } else if (n < 1000000) {
        return 6;
    } else {
        return 7;
    }
}


int counts(int k) {
    if (k == 1) {
        return 9;
    } else if (k == 3) {
        return 999 - 100 + 1;
    } else if (k == 5) {
        return 99999 - 10000 + 1;
    } else {
        return -1000000;
    }
}
int my_pow(int k) {
    int n = 1;
    for (int i = 0; i < k; ++i) {
        n *= 10;
    }
    return n;
}

int main() {
    int N;
    cin >> N;
    int K = keta_of(N);
    int ans = 0;
    for (int k = 1; k < K; k += 2) {
        ans += counts(k);
    }
    if (K % 2 == 1) {
        ans += N - my_pow(K - 1) + 1;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		Integer a = Integer.parseInt(sc.next());
		Integer b = Integer.parseInt(sc.next());

		List<String> list = new ArrayList<>();
		StringBuilder sb =  new StringBuilder();
		for(int i=0;i<b; i++) {
			sb.append(a.toString());
		}
		list.add(sb.toString());
		StringBuilder sb2 =  new StringBuilder();
		for(int i=0;i<a; i++) {
			sb2.append(b.toString());
		}
		list.add(sb2.toString());
		Collections.sort(list);
		System.out.println(list.get(0));

	}
}


Measured memory_bytes: 21076
import math

def alldiv(x):
    div = [[1,x]]
    for i in range(2,math.floor(math.sqrt(x))+1):
        if x % i == 0:
            div.append([i, x//i])
    return div


def digit(N):
    d = 0
    while(N > 0):
        N //= 10
        d += 1
    return d


N = int(input())
div = alldiv(N)
#print(div)
F = [max(digit(i[0]),digit(i[1])) for i in div]
print(min(F))



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

int main() {
    int N,i,j,c=0;
    double s=0;
    cin >> N;
    vector<pair<double,double>> p(N);

    for(i=0; i<N; i++)
        cin >> p.at(i).first >> p.at(i).second;

    for(i=0; i<N; i++)
        for(j=i; j<N; j++)
            s += sqrt( pow((p.at(i).first-p.at(j).first), 2) + pow((p.at(i).second-p.at(j).second), 2) );
    c = (N-1)*N/2;
    
    cout << setprecision(20) << s * ((double)(N-1)/c)<< endl;
}

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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)

const int N = 100005;
vector<vector<int>> g;
int n, m, dp[N], ans;
bool solved[N];

int dfs(int u)
{
    if (solved[u])
    {
        return dp[u];
    }
    
    for (auto v : g[u])
    {
        dp[u] = max(dp[u], 1 + dfs(v));
    }
    solved[u] = 1;
    return dp[u];
}

int main()
{
    FaSt
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
    }
    
    for (int i = 0; i < n; i++)
    {
        ans = max(ans, dfs(i));
    }
    
    cout << ans;
}


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

using namespace std;
using ll = long long;
using ld = long double;

int a[100][100];

ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    cout.precision(20); cout << fixed;
    int n;
    cin >> n;
    vector<ll> dp(1 << n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    dp[0] = 1;
    for (int mask = 1; mask < (1 << n); mask++) {
        for (int j = 0; j < n; j++) {
            if (((mask >> j) & 1) && a[__builtin_popcount(mask) - 1][j]) {
                dp[mask] = (dp[mask] + dp[mask - (1 << j)]) % mod;
            }
        }
    }
    cout << dp[(1 << n) - 1];
}


Measured memory_bytes: 16640
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    string X;
    cin >> X;
    
    int s = 0,res = 0;
    
    for(int i = 0; i < X.size(); i++){
        if(X[i] == 'S'){
            s++;
        }else{
            if(s > 0){
                s--;
            }else{
                res++;
            }
        }
    }
    
    cout << res + s << endl;
}


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

int main(void) {
	long long int a[3]; cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0) {
		cout << "0" << endl;
	}
	else { cout << a[0] * a[1] << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
int main()
{
    std::string s;
    std::cin >> s;

    int ans = 753;
    for (int i = 0; i < s.length()-2; i++) {
        std::string ss = s.substr(i, 3);
        int y = std::stoi(ss);
        ans = std::min(ans, std::abs(y-753));
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, p := intScanner(), intScanner()
	fmt.Println((a*3 + p) / 2)
}


Measured memory_bytes: 1772
<?php
 // Your code here!
    # 整数の入力
    fscanf(STDIN, "%d", $i);
    $j = floor(sqrt($i));
    if ($i % $j == 0) {
        $k = $i / $j;
        echo ($k + $j - 2);
    } else {
        for ($j; $j--;) {
            if ($i % $j == 0) {
                $k = $i / $j;
                break;
            };
        };
        echo ($k + $j - 2);
    };
  ?>

Measured memory_bytes: 3700
#!/usr/bin/python

import sys

VOWEL = ["a", "e", "i", "o", "u"]

def main(argv):
    for line in sys.stdin:
        line = line.strip("\n")
        if line in VOWEL:
            print "vowel"
        else:
            print "consonant"

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
import sys
num = list(raw_input())
p  = num[0]
c = 1
for i in xrange(1, len(num)):
    if p == num[i]:
        c += 1
        if c == 3:
            print "Yes"
            sys.exit()
    else:
        p = num[i]
        c = 1
print "No"


Measured memory_bytes: 2568