akhauriyash/Code-Regression huggingface dataset:
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int len[30];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int s;
  cin >> s;

  int sum = 0;
  auto check = [&](int m) -> bool {
    sum = 0;
    int i, l;
    for(i=1, l=1; i<=m; i*=10, ++l) {
      // [i, 10*i)
      int a = (10*i-1)/3 - (i-1)/3;
      int b = (10*i-1)/5 - (i-1)/5;
      int c = (10*i-1)/15 - (i-1)/15;
      a -= c, b -= c;
      sum += (a + b + 2*c) * 4 + (10*i-i-a-b-c) * l;
    }
    // (m, i) を引く
    if(m < i) {
      int a = (i-1)/3 - m/3;
      int b = (i-1)/5 - m/5;
      int c = (i-1)/15 - m/15;
      a -= c, b -= c;
      sum -= (a + b + 2*c) * 4 + (i-1-m-a-b-c) * (l-1);
    }
    return sum < s;
  };

  int lb = 0, ub = 1e18;
  while(ub-lb>1) {
    int mid = (lb+ub)/2;
    if(check(mid)) {
      lb = mid;
    } else {
      ub = mid;
    }
  }
  // lb+1 の s - sum番目からのFizzBuzz string
  check(lb);
  // cout << lb+1 << " " << s-sum << endl;

  int idx = lb+1;
  string ans = "";
  if(idx%15 == 0) {
    string tmp = "FizzBuzz";
    ans += tmp.substr(s-sum-1);
  } else if(idx%3==0) {
    string tmp = "Fizz";
    ans += tmp.substr(s-sum-1);
  } else if(idx%5==0) {
    string tmp = "Buzz";
    ans += tmp.substr(s-sum-1);
  } else {
    string tmp = to_string(idx);
    ans += tmp.substr(s-sum-1);
  }
  idx++;
  // cout << ans << endl;
  while(ans.size() < 20) {
    if(idx%15 == 0) {
      string tmp = "FizzBuzz";
      if(ans.size() + 8 <= 20) {
        ans += tmp;
      } else {
        ans += tmp.substr(0, 20-ans.size());
      }
    } else if(idx%3==0) {
      string tmp = "Fizz";
      if(ans.size() + 4 <= 20) {
        ans += tmp;
      } else {
        ans += tmp.substr(0, 20-ans.size());
      }
    } else if(idx%5==0) {
      string tmp = "Buzz";
      if(ans.size() + 4 <= 20) {
        ans += tmp;
      } else {
        ans += tmp.substr(0, 20-ans.size());
      }
    } else {
      string tmp = to_string(idx);
      if(ans.size() + tmp.size() <= 20) {
        ans += tmp;
      } else {
        ans += tmp.substr(0, 20-ans.size());
      }
    }
    idx++;
  }
  cout << ans.substr(0, 20) << endl;

  return 0;
}



Measured memory_bytes: 3308
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i + 1 < n; ++i) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }
  for (int i = 0; i + 2 < n; ++i) {
    if (s[i] == s[i + 2]) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  puts("-1 -1");
  return 0;
}

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



int main() {
  cin >> n;
//  cout << n <<endl;
  int answer = 0;
  answer = n /2;
  if (n % 2){
    cout << answer + 1 <<endl;
  }
  else{
  cout << answer <<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N,t;
  t=0;
  scanf("%d", &N);
  if (N % 10 == 7)
    t=1;
  if (N/10%10 == 7)
    t=1;
  if (N/100%10 == 7)
    t=1;
  if(t == 1)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 1736
import math

def divisors(n):
    div = [n]
    for i in xrange(2,int(math.sqrt(n))+1):
        if n%i == 0:
            div.append(i)
            div.append(n/i)
    return div

n = int(raw_input())
ndiv = set(divisors(n))
mdiv = set(divisors(n-1))
count = 0
for x in ndiv:
    for k in xrange(1,41):
        if x**k > n:
            break
        if (n%x**k)==0 and (n/x**k)%x == 1:
            count += 1
            #print x
            break
count += len(mdiv)
if n==2:
    count = 1
print count

Measured memory_bytes: 3460
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[300];
int memo[300][300];
int dp[303];
bool check(int i, int j) {
  if (abs(w[i] - w[j]) <= 1) return true;
  return false;
}
int canRemove(int x, int y) { // 1 : can / 0 : no
  if (memo[x][y] >= 0) return memo[x][y];
  if (y == x + 1) {
    if (check(x, y)) return memo[x][y] = 1;
    return memo[x][y] = 0;
  }
  for (int i = x + 1; i < y; i += 2) {
    if (canRemove(x, i) && canRemove(i + 1, y)) return memo[x][y] = 1;
  }
  for (int i = x + 3; i < y; i += 2) {
    if (check(x, i) && canRemove(x + 1, i - 1) && canRemove(i + 1, y)) return memo[x][y] = 1;
  }
  if (check(x, y) && canRemove(x + 1, y - 1)) return memo[x][y] = 1;
  return memo[x][y] = 0;
}

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i < n; i++) scanf("%d", &w[i]);
    for (int i = 0; i < n ; i++)
      for (int j = 0; j < n; j++) memo[i][j] = -1;
    for (int i = 0; i <= n; i++) dp[i] = 0;
    for (int i = 0; i < n; i++) {
      if (i > 0) dp[i] = max(dp[i], dp[i - 1]);
      for (int j = i + 1; j < n; j += 2) {
        if (canRemove(i, j)) dp[j + 1] = max(dp[j + 1], dp[i] + j - i + 1);
      }
    }
    /*
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j ++) {
        printf("%d ", memo[i][j]);
      }
      printf("\n");
    }
    */
    int ans = 0;
    for (int i = 0; i <= n; i++) ans = max(ans, dp[i]);
    printf("%d\n", ans);
  }
}



Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define sPRINT(str) printf(#str "\n")
#define yOUT sPRINT(Yes)
#define nOUT sPRINT(No)
#define YOUT sPRINT(YES)
#define NOUT sPRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
 
using namespace std;

int main(void)
{   
    int n, k, sum=0, inp;
    cin >> n >> k;
    REP(i, n){
        cin >> inp;
        sum += min(2*inp,2*(k-inp));
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
N = int(input())
result = {}
for i in range(1, N + 1):
    result[i] = 0
    tmp = i
    while True:
        if tmp % 2 == 0:
            tmp = tmp / 2
            result[i] += 1
        else:
            break
print(sorted(result.items(), key=lambda x: -x[1])[0][0])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      int a,b;
      cin >> a >> b;
      if(a>=13)cout << b;
      else if(a>=6 && a<=12)cout << b/2;
      else cout << 0;
      return 0;
}


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

int main() {
  long long N;
  cin >> N;
  vector<long long> B(N - 1);
  
  for (int i = 0; i < N - 1; i++) {
    cin >> B.at(i);
  }

  long long Asum = B.at(0);
  for (int i = 1; i < N - 1; i++) {
    Asum += min(B.at(i - 1), B.at(i));
  }
  Asum += B.at(N - 2);
  
  cout << Asum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 1000000007;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i)
  {
    cin >> b[i];
  }
  vector<int> pre1(n);
  pre1[0] = a[0];
  for (int i = 1; i < n; ++i)
  {
    pre1[i] = pre1[i - 1] + a[i];
  }
  int ans;
  int it = lower_bound(pre1.begin(), pre1.end(), k) - pre1.begin();
  if (pre1[it] == k)
    it++;
  ans = it;
  int temp = 0;
  int val = 0;
  for (int i = 0; i < m; ++i)
  {
    val += b[i];
    temp++;
    k -= b[i];
    if (k >= 0)
    {
      int it1 = lower_bound(pre1.begin(), pre1.end(), k) - pre1.begin();
      if (pre1[it1] == k)
        it1++;
      ans = max(ans, temp + it1);
    }
    else
      break;
  }
  cout << ans;
}


Measured memory_bytes: 7952
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <math.h>

using namespace std;

int main() {
	string t; cin >> t;
	int dp[200001][2] = {};
	switch (t[0]) {
	case 'D':
	case '?':
		dp[0][0] = 1;
		break;
	}

	for (int i = 1; i < t.length(); i++) {
		switch (t[i]) {
		case 'P':
			dp[i][1] = max(dp[i-1][0], dp[i - 1][1]);
			break;
		case 'D':
			dp[i][0] = max(dp[i - 1][1] + 2, dp[i - 1][0] + 1);
			break;
		case '?':
			dp[i][0] = max(dp[i - 1][1] + 2, dp[i - 1][0] + 1);
			dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]);
			break;
		}
	}
	for (int i = 0; i < t.length(); i++) {
		switch (t[i]) {
		case 'P':
			cout << 'P';
			break;
		case 'D':
			cout << 'D';
			break;
		case '?':
			if (dp[i][0] > dp[i][1])cout << 'D';
			else cout << 'P';
			break;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		int a[n];
		int s=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			s+=a[i];
		}
		int c=s/(4*m);
		sort(a,a+n,greater<int>());
		for(int i=0;i<m;i++){
			if(a[i]*4*m<s){
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
/*
	Author: Ritik Patel
*/
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
// #define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
// #pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#include <bits/stdc++.h>
using namespace std;
 
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
//find_by_order()->returns an iterator to the k-th largest element(0-based indexing)
//order_of_key()->Number of items that are strictly smaller than our item
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define int long long int
// #define ll long long int
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
// #define ld long double
// const ld PI  = 3.141592;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&


void solve(){
    int N; cin >> N;
    int ways = 0;
    int a[N];
    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < N; ++i){
        for(int j = i + 1; j < N; ++j){
            for(int k = j + 1; k < N; ++k){
                set<int> s;
                s.insert(a[i]), s.insert(a[j]), s.insert(a[k]);
                if(sz(s) != 3){
                    continue;
                }
                auto it = s.begin();
                ++it;
                if(*s.rbegin() < *s.begin() + *it ){
                    ++ways;
                }
            }
        }
    }
    cout << ways << '\n';
}

int32_t main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout); 
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int T = 1; 
    // cin >> T;
    for(int i = 1; i <= T; ++i){
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}
 
/*
Sample inp
*/

Measured memory_bytes: 3640
///*.......................Shadman Sakib Utshob............................*///

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define Boost           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define pb              push_back
#define seecontent(v) cout << (#v) << " is "; for(auto x : v) { cout << x << " ";} cout << "\n\n";
#define inf             1e10
#define mp              make_pair
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define ll              long long
#define pii             pair<ll,ll >
#define MOD             1000000007
#define fileout         freopen("output.txt","w",stdout)
#define mem(x,i)        memset(x,i,sizeof x)
#define Ones(x)         __builtin_popcount(x);
#define PI              acos(-1.0)
#define ff              first
#define ss              second
#define T               int t;cin>>t;while(t--)
#define ok              cout<<"ok"<<endl;
#define all(x)          (x).begin(),(x).end()
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nln	            cout<<endl;
#define maxn 300005

int dx[]={-1,0,1,0}; //up,right,down,left
int dy[]={0,1,0,-1};

int main()
{
    Boost;
    string s;
    ll n,i,j;
    cin>>n;
    int a[n+10],b[n+10];
    int c=0;
    rep1(i,n)
    {
        cin>>a[i]>>b[i];
    }
    for(i=2;i<=n-1;i++)
    {
        if((a[i]==b[i])and(a[i-1]==b[i-1])and(a[i+1]==b[i+1]))
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;

    return 0;

}


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

int main(){
    ll n;
    cin>>n;
    V x(3,0);
    V aa(n);
    rep(i,n)cin>>aa[i];
    ll ans=1;
    ll mod=1e9+7;
    rep(i,n){
        ll a=aa[i];
        sort(x.rbegin(),x.rend());
        if(a==x[0]){
            if(x[0]==x[1]){
                if(x[0]==x[2]){
                    ans*=3;
                }else{
                    ans*=2;
                }
            }
            x[0]++;
        }else if(a==x[1]){
            if(x[1]==x[2]){
                ans*=2;
            }
            x[1]++;
        }else if(a==x[2]){
            x[2]++;
        }else{
            cout<<0<<endl;
            return 0;
        }
        ans=(ans+mod)%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int n;
  scanf("%d",&n);
  /*
  int matubi=n%10;
  int sento=n;
  while(sento/10 > 0){
  sento/=10;}*/

  int map[9][9];
  for(int i=0;i<9;i++){
    for(int j=0;j<9;j++){
      map[i][j]=0;}}
  int matubi;
  int sento;

  for(int i=1;i<=n;i++){
    matubi=i%10;
    if(matubi==0){
      continue;}
    sento=i;
    while(sento/10 > 0){
      sento/=10;}
    map[sento-1][matubi-1]++;}

  int count=0;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      count+=map[i-1][j-1]*map[j-1][i-1];}}

  printf("%d\n",count);

  return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n;
    cin >> n;
    ll a[5] = {};
    for (ll i = 0; i < n; i++) {
        string s;
        cin >> s;
        if(s[0] == 'M') {
            a[0]++;
        }
         if(s[0] == 'A') {
            a[1]++;
        }
         if(s[0] == 'R') {
            a[2]++;
        }
         if(s[0] == 'C') {
            a[3]++;
        }
         if(s[0] == 'H') {
            a[4]++;
        }
    }
    ll ans = 0;
    for (ll i = 0; i < 5; i++) {
        for (ll j = i + 1; j < 5; j++) {
            for (ll k = j + 1; k < 5; k++) {
                ans += (a[i] * a[j] * a[k]);
            }
        }
    }

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


Measured memory_bytes: 3624
s=input()
n=len(s)
mod=[0]*(n+1)
s=s[::-1]
for i in range(n):
	mod[i+1]=(mod[i]+pow(10,i,2019)*int(s[i])%2019)%2019
mod.sort()
cnt=1
ans=0
for i in range(n):
	if mod[i]==mod[i+1]:
		cnt+=1
	else:
		ans+=cnt*(cnt-1)//2
		cnt=1
ans+=cnt*(cnt-1)//2
print(ans)



Measured memory_bytes: 17208
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Integer[] l = new Integer[n];
        for (int i = 0; i < n; i++) {
            l[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        Arrays.sort(l, Collections.reverseOrder());
        int result = 0;
        for (int i = 0; i < k; i++) {
            result += l[i];
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 23892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

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

    double r;
    cin >> r;

    cout << setprecision(20)  << r* 2. * 3.14159265358979323846<< endl;

    return 0;
}


Measured memory_bytes: 3804
import sys
sys.setrecursionlimit(10**9)
n=int(input())
g=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,sys.stdin.readline().split())
  g[a-1].append([b-1,i])
  g[b-1].append([a-1,i])
print(max(len(v) for v in g))
l=[0]*(n-1)
def dfs(v,p=-1,c=-1):
  k=1
  for u,e in g[v]:
    if u==p: continue
    if k==c: k+=1
    l[e]=k
    dfs(u,v,k)
    k+=1
dfs(0)
for c in l: print(c)


Measured memory_bytes: 89264
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct UnionFind {
    vector<int> id;
    vector<vector<int> > groups;
    int gn; //number of groups
    UnionFind(int n){
        id = vector<int>(n);
        groups = vector<vector<int> >(n);
        gn = n;
        for(int i=0;i<n;++i){
            id[i]=i;
            groups[i]={i};
        }
    }
    void unite(int a, int b) {
        if(same(a,b)) return;
        gn--;
        int x = id[a];
        int y = id[b];
        if(groups[x].size()<groups[y].size()) swap(x,y);
        for(int j : groups[y]){
            id[j] = x;
            groups[x].push_back(j);
        }
        groups[y].clear();        
    }
    bool same(int a, int b) { return id[a] == id[b]; }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    UnionFind uf(h*w);
    vector<vector<bool> > field(h,vector<bool>(w,0));
    REP(i,h){
        string s;
        cin >> s;
        REP(j,w){
            field[i][j] = (s[j]=='#');
        }
    }
    auto id = [&](int i, int j){ return i*w+j;};
    REP(i,h){
        REP(j,w){
            if(i>0&&field[i-1][j]!=field[i][j]) uf.unite(id(i-1,j),id(i,j));
            if(j>0&&field[i][j-1]!=field[i][j]) uf.unite(id(i,j),id(i,j-1));
        }
    } 
    ll ans = 0;
    for(auto v:uf.groups){
        ll black=0;
        ll white=0;
        for(int d:v){
            if(field[d/w][d%w]==true) black++;
            else white++;
        }
        ans += black*white;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

static const int MAX = 5000;
static const ll MIN = -2e18;
vector<pair<int, int>> nx;
ll n, k;
vector<bool> visited(MAX, false);
vector<vector<ll>> scores;

void search(int u){
    if(visited[nx[u].first]) return;
    visited[nx[u].first] = true;
    scores.back().push_back(nx[u].second);
    search(nx[u].first);
}

void search_init(int s){
    if(visited[s]) return;
    scores.emplace_back();
    search(s);
}

int main(){
    cin >> n >> k;
    nx.resize(n);
    vector<int> p(n), c(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> c[i];
    for(int i = 0; i < n; i++){
        nx[i] = make_pair(p[i]-1, c[i]);
    }
    for(int i = 0; i < n; i++){
        search_init(i);
    }
    ll ans = MIN;
    for(auto s : scores){
        int num = s.size();
        ll sum = 0;
        for(int i = 0; i < num; i++) sum += s[i];
        vector<ll> t(2*num+1);
        for(int i = 0; i < 2*num; i++) t[i+1] = s[i % num];
        for(int i = 0; i < 2*num; i++) t[i+1] += t[i];
        for(int j = 1; j <= num; j++){
            ll maxv = MIN;
            for(int i = 0; i + j <= 2*num; i++){
                if(maxv < (t[i+j] - t[i])) maxv = t[i+j] - t[i];
            }
            if(j > k) continue;
            if(sum <= 0){
                ans = max(ans, maxv);
            } else {
                ans = max(ans, sum * ((k - j) / num) + maxv);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[100], d;

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	sort(a, a+n);
	d = a[n-1] - a[0];
	cout << d << ln;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define M 100000007
using namespace std;
char c;
int a1[30];
int a2[30];
int n=0;

int main()
{
    for (int i=0; i<26; ++i)
        a1[i]=a2[i]=1;
    while (true)
    {
        scanf("%c",&c);
        if (c=='\n') break;
        a1[c-'a']*=(++n);
        if (a1[c-'a']>10000000) a1[c-'a']%=M;
    }
    for (int i=1; i<=n; ++i)
    {
        scanf("%c",&c);
        a2[c-'a']*=(i);
        if (a2[c-'a']>10000000) a2[c-'a']%=M;
    }
    sort(a1,a1+26);
    sort(a2,a2+26);
    bool flag=1;
    for (int i=0; i<='z'-'a'; ++i)
        if (a1[i]!=a2[i])
            flag=0;
    if (flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n, q = map(int, input().split())
node = [0] * n
to = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    to[b-1].append(a-1)
    to[a-1].append(b-1)
for _ in range(q):
    p, x = map(int, input().split())
    node[p-1]+=x

def dfs(i, source, count=0):
    node[i]+=count
    for next_node in to[i]:
        if next_node == source: continue 
        dfs(next_node, i, node[i])
dfs(0, -1, 0)

print(' '.join(list(map(str, node))))

Measured memory_bytes: 269716
#include <stdio.h>
#include <assert.h>

static struct {
        int weight;
        int value;
} items[100];
static int item_count, knapsack_capacity;

static long maxvalsum[128][100000 + 1];

static long knapsack (int const i, int const cap)
{
        long maxval, t = 0;
        
        assert(i >= 0 && i <= item_count);
        assert(cap >= 0 && cap <= knapsack_capacity);
        
        if (i == item_count)
                return 0;
        if (maxvalsum[i][cap] >= 0)
                return maxvalsum[i][cap];
        
        if (cap >= items[i].weight)
                t = knapsack(i + 1, cap - items[i].weight) + items[i].value;
        maxval = knapsack(i + 1, cap);
        if (t > maxval)
                maxval = t;
        
        return maxvalsum[i][cap] = maxval;
}

int main (void)
{
        int i, j;
        
        scanf("%d%d", &item_count, &knapsack_capacity);
        for (i = 0; i < item_count; ++i)
                scanf("%d%d", &items[i].weight, &items[i].value);
        for (i = 0; i < item_count; ++i)
                for (j = 0; j <= knapsack_capacity; ++j)
                        maxvalsum[i][j] = -1;
        printf("%ld\n", knapsack(0, knapsack_capacity));
        return 0;
}


Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define int long long
#define inf 1e9
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,a,b;
int ans1,ans2;
vector<int>vec[100005];
int whi[100005];
int fed[100005],sud[100005];
void bfs(){
	queue<int>quefe,quesu;
	quefe.push(0),quesu.push(n-1);
	fill(fed,fed+n,inf);
	fed[0]=0;
	while(quefe.size()){
		int fe=quefe.front();quefe.pop();
		rep(i,vec[fe].size()){
			if(fed[vec[fe][i]]==inf){
			   fed[vec[fe][i]]=fed[fe]+1;
			   quefe.push(vec[fe][i]);
		    }
		}
	}
	fill(sud,sud+n,inf);
	sud[n-1]=0;
	while(quesu.size()){
		int su=quesu.front();quesu.pop();
		rep(i,vec[su].size()){
			if(sud[vec[su][i]]==inf){
				sud[vec[su][i]]=sud[su]+1;
		        quesu.push(vec[su][i]);
			}
		}
	}
	rep(i,n){
		if(fed[i]<=sud[i])ans1++;
		else ans2++;
	}
	if(ans1>ans2)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
}
signed main(){
	cin>>n;
	rep(i,n-1){
		cin>>a>>b;
		vec[a-1].push_back(b-1);
		vec[b-1].push_back(a-1);
	}
	whi[0]=1,whi[n-1]=-1;
	bfs();
}



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

int fun(int N){
  int count = 0;
  int m = int(sqrt(N))+1;
  for(int i=1; i<=m; i++){
    for(int j=1; j<=i; j++){
      for(int k=1; k<=j; k++){
        int A = i+j+k;
        if(A*A-i*j-j*k-k*i == N){
          int t=0;
          if(i==j){
            t += 1;
          }
          if(i==k){
            t += 1;
          }
          if(j==k){
            t += 1;
          }
          if(t == 0){
            count += 6;
          }else if(t == 1){
            count += 3;
          }else{
            count += 1;
          }
        }
      }
    }
  }
  return count;
}
  
 
int main() {
  int N;
  cin >> N;
  for(int i=1; i<=N; i++){
    cout << fun(i) << endl;
  }
}

Measured memory_bytes: 3540
#include <iostream>

using namespace std;

bool solve() {
    int N;
    cin >> N;
    while(N--) {
        int p, q;
        cin >> p >> q;
        const int len = p*p + q*q;
        int cnt = 0;
        for(int m = -200; m <= 200; ++m) {
            if(m*m > len) continue;
            for(int n = -200; n <= 200; ++n) {
                const int len2 = m*m + n*n;
                if(len2 == 0) continue;
                if(len % len2 != 0) continue;
                if((m*p+n*q) % len2 == 0 && (m*q-n*p) % len2 == 0) {
                    ++cnt;
                }
            }
        }
end:
        cout << (cnt==8 ? "P" : "C") << endl;
    }
    return false;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    int N; cin >> N;
    vector<int> P(N);
    vector<int> IP(N);
    REP(i,N) {
        cin >> P[i]; P[i] --;
        IP[P[i]] = i;
    }
    multiset<int> S;
    S.insert(-1);
    S.insert(-1);
    S.insert(N);
    S.insert(N);
    ll ans = 0;
    for(int i=N-1; i>=0; --i) {
        auto it = S.lower_bound(IP[i]);
        int r1 = *it;
        it++;
        int r2 = *it;
        it--;it--;
        int l1 = *it;
        it--;
        int l2 = *it;
        //cout << l2 << " " << l1 << " " << IP[i] << " " << r1 << " " << r2 << endl;
        ll tmp = 0;
        tmp += (ll)(r1-IP[i]) * (l1-l2); 
        tmp += (ll)(r2-r1) * (IP[i]-l1);
        ans += tmp * (i+1);
        S.insert(IP[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;
map<int, int> ct;
map<int, int> ct2;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define AFOR(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, m, l;
int a, b, c;
string s[MN];
string str;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

/*
int N;
cin >> N;
vi vect(N);
FOR(i,N) cin >> vec.at(i);*/
//sort(vec.begin(),vec.end());
//vvi data(N,vi(4));


/*	int bfs(int x, int y,vvi &A,vvi flag) {
		queue<pii> que;
		que.push(pii(x, y));
		while (que.size()) {
			pii p = que.front(); que.pop();
			AFOR(i, 4) {
				int nx = p.first + dx[i]; int ny = p.second + dy[i];
				if (0 <= nx && nx < N && 0 <= ny && ny < N) {
					if (A.at(p.first).at(p.second) + flag.at(p.first).at(p.second) < A.at(nx).at(ny)) {
						A.at(nx).at(ny) = A.at(p.first).at(p.second) + flag.at(p.first).at(p.second);
						que.push(pii(nx, ny));
					}
				}
			}
		}
		return 0;
	}
	*/
	/*int gcd(int p, int q){
		while(q != 0){
		int r = p % q;
		p = q;
		q = r;
		}
	return p;
	}*/
ll N;
ll K;
ll A[200100];
ll L[200100];
ll ans = 0;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N ;
	AFOR(i, N) {
		cin >> A[i];
		L[i] = 0;
	}
	AFOR(i, N) {
		L[A[i]-1]++;
	}
	AFOR(i, N) {
		ans += L[i] * (L[i] - 1) / 2;
		}
	AFOR(i,N){
		cout << ans-L[A[i]-1]+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 6528
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const ll N = 2e7, MOD =  998244353;

void solve() {
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector <int> b(n);
    for (int i = 0; i < min(k, 100); ++i) {
        for (int j = 0; j < n; ++j) {
            int l, r;
            l = max(0, j - a[j]);
            r = 1 + j + a[j];
            if (r < n) {
                b[r]--;
            }
            // cout << l << " " << r << "\n";
            b[l]++;
        }
        for (int i = 0; i < n; ++i) {
            b[i] += (i == 0 ? 0 : b[i - 1]);
        }
        for (int i = 0; i < n; ++i) {
            a[i] = b[i];
            b[i] = 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i] << " ";
    }
}
int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                   

Measured memory_bytes: 4780
def print_1(array):
    for i in range(len(array)):
        if i == len(array) - 1:
            print(array[i])
        else:
            print(array[i], end=" ")

N = int(input())
A = [int(n) for n in input().split()]
print_1(A)
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print_1(A)

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g( n );
	for( int i = 0; i < m; i++ ) {
		int s, t;
		cin >> s >> t;
		g[s].push_back( t );
		g[t].push_back( s );
	}
	vector<int> color( n );
	int col = 0;
	for( int i = 0; i < n; i++ ) {
		if( color[i] > 0 ) continue;
		col++;
		color[i] = col;
		queue<int> que;
		que.push( i );
		while( !que.empty() ) {
			int u = que.front();
			que.pop();
			for( auto v : g[u] ) {
				if( color[v] > 0 ) continue;
				que.push( v );
				color[v] = col;
			}
		}
	}

	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		int s, t;
		cin >> s >> t;
		string ans = "no";
		if( color[s] == color[t] ) ans = "yes";
		cout << ans << endl;
	}
}



Measured memory_bytes: 8696
#include<iostream>
#include<cstdio>
int p[400008];
int a[400008];
using namespace std;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++)
		s[i]=='o'?p[i+1]=0:p[i+1]=1;
	p[n+1]=p[1];
	for(int i=0;i<8;i++)
	{
		a[0]=i&1;
		a[1]=(i>>1)&1;
		a[2]=(i>>2)&1;
		for(int j=2;j<=n+1;j++)
		{
			a[j+1]=a[j-2]^p[j];
		}
		if(a[0]^a[n]^a[1]^a[n+1] || a[1]^a[n+1]^a[2]^a[n+2])continue;
		for(int j=1;j<=n;j++)
			cout<<(a[j]^a[j-1]?"W":"S");
		return 0;
	}
	cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;


int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    int a, b, c; cin>>a>>b>>c;
    if(c>=a && c<=b)cout<<"Yes";
    else cout<<"No";
	return 0;

}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int x, y, z;
    int temp;
    std::cin >> x >> y >> z;
    
    if (x > y) {
        temp = x;
        x = y;
        y = temp;
    }
    
    if (y > z) {
        temp = y;
        y = z;
        z = temp;
    }
    
    if (x > y) {
        temp = x;
        x = y;
        y = temp;
    }
    
    std::cout << x << " " << y << " " << z << std::endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(int, N);
	in_v(string, S, N);
	map<char, ll> mt;
	for(char i='a'; i<='z'; ++i)
		mt[i] = INF;
	loop(i, N){
		map<char, ll> t;
		for(char c : S[i])
			++t[c];
		for(char i='a'; i<='z'; ++i)
			mt[i] = min(mt[i], t[i]);
	}
	for(char i='a'; i<='z'; ++i)
		loop(p, mt[i])
			cout << (char)i;
	cout << endl;
}



Measured memory_bytes: 256
nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);
h = input().split(" ");
for i in range(n) :
	h[i] = int(h[i]);

#h.sort(reverse=True);

ans = 0;
for i in range(n) :
	if h[i] >= k :
		ans += 1;

print(ans);

Measured memory_bytes: 9988
"use strict";
var INPUT = require('fs').readFileSync('/dev/stdin', 'utf-8');
var _a = INPUT.split(' ').map(Number), A = _a[0], B = _a[1], K = _a[2];
var a = Math.max(0, A - K);
var b = K > A ? Math.max(0, B - (K - A)) : B;
console.log(a + " " + b);


Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;

const int mx = 205;

int n, a[mx], dp[mx];
int fun(int idx){
    if(idx >= n) return 0;

    int &ans = dp[idx];
    if(~ans) return ans;

    ans = 0;
    ans = min(a[idx], a[idx+1]) + fun(idx+2);
    ans = max(ans, fun(idx+1));
    return ans;
}

void solve(){
    cin >> n; n+=n;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    sort(a+1, a+n+1);

//    for(int i=1; i<=n; i++)
//        cout << a[i] << " ";
//    cout << "\n";

    memset(dp, -1, sizeof dp);
    cout << fun(1) << "\n";
}

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

    int tc=1; ///cin >> tc;
    while(tc--) solve();
    return 0;
}



Measured memory_bytes: 3600
N = int(input())
L = list(map(int,input().split()))
ans = 0

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            I = L[i]
            J = L[j]
            K = L[k]
            if max(I,J,K)*2 < I + J + K and I != J and J != K and K != I:
                ans += 1

print(ans)

Measured memory_bytes: 9164
N = gets.to_i
A = gets.split.map(&:to_i).sort
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i).sort

result = 0

B.each do |b|
  a_index = A.bsearch_index { |a| a >= b }
  c_index = C.bsearch_index { |c| b < c }
  a_count = a_index.nil? ? A.size : a_index
  next if c_index.nil?
  c_count = C[c_index..-1].size
  result += a_count * c_count
end

p result

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

using namespace std;

int main(){
  string s;
  cin >> s;
  bool ans = false;
  for(int i=0; i<s.size()-1; i++){
    if( s[i] == s[i+1] ){
      ans = true;
      break;
    }
  }
  if( ans ) cout << "Bad";
  else cout << "Good";
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func maxScanTokenSize(size int) {
	buf := make([]byte, 0, size)
	sc.Buffer(buf, size)
}

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

func nextBytes() []byte {
	sc.Scan()
	return sc.Bytes()
}

func nextInt() int {
	s := nextString()
	i, _ := strconv.Atoi(s)
	return i
}

func scanTwoInts() (int, int) {
	var a, b int
	fmt.Scan(&a, &b)
	return a, b
}

func scanThreeInts() (int, int, int) {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	return a, b, c
}

func main() {
	// maxScanTokenSize(100000)
	// sc.Split(bufio.ScanWords)

	D := nextInt()
	ans := "Christmas"
	for i := 0; i < 25-D; i++ {
		ans += " Eve"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, K, *A = map(int, read().split())

    ans = INF
    for bit in range(1 << N):
        if (not (bit & 1)) or bin(bit).count('1') != K:
            continue

        total = 0
        max_height = A[0]
        for i, a in enumerate(A[1:], 1):
            if a <= max_height:
                if bit & (1 << i):
                    total += max_height - a + 1
                    max_height += 1
            else:
                max_height = a

        if ans > total:
            ans = total

    print(ans)

    return


if __name__ == '__main__':
    main()


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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c,max(a*d,max(b*c,b*d)));
    cout << ans << endl;
}


Measured memory_bytes: 3620
import numpy as np

N, X = list(map(int, input().split(" ")))

a = 1
p = 1
a_list = [1]
p_list = [1]
for i in range(N+1):
    a = 2 * a + 3
    p = 2 * p + 1
    a_list.append(a)
    p_list.append(p)


def f(N, X):
    ai_1 = a_list[N-1]
    if N == 1:
        if 1 <= X and X <= 4:
            out = X - 1
        else: 
            assert X == 5
            out = 3
    elif X == 1:
        out = 0
    elif 2 <= X and X <= 1+ai_1:
        out = f(N-1, X-1)
    elif X == 2 + ai_1:
        out = p_list[N-1] + 1
    elif 3 + ai_1 <= X and X <= 2 + 2*ai_1:
        out = p_list[N-1] + 1 + f(N-1, X - 2 - a_list[N-1])
    else:
        assert X == 3+ 2*ai_1
        out = p_list[N]
    return out


print(f(N, X))

Measured memory_bytes: 14548
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int sum = a+b+c,count = 0;
    while(sum % 3 != 0 || sum / 3 < max({a,b,c})) {
        sum += 2;
        count++;
    }
    cout << count;
    return 0;
}



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

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

using namespace std;

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=m.inverse(); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	mint inverse()const{
		int a=x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

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

	mint cnt,choose=1;
	for(int i=n;i>n/2;i--){
		cnt+=choose*pow(mint(2),n-i);
		choose*=mint(i)/(n-i+1);
	}
	cout<<pow(mint(3),n)-cnt*2<<'\n';

	return 0;
}


Measured memory_bytes: 256