akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    int rx = root(x);         // xの根をrx
    int ry = root(y);         // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind tree(n);
  vector<int> fri(n);
  vector<int> blo(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    fri[a]++;
    fri[b]++;
    tree.unite(a, b);
  }
  rep(i, k) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    if (tree.root(c) == tree.root(d)) {
      blo[c]++;
      blo[d]++;
    }
  }
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    // cout << tree.root(i) << endl;
    t[tree.root(i)]++;
  }
  rep(i, n) { cout << t[tree.root(i)] - fri[i] - blo[i] - 1 << " "; }
  cout << endl;
}


Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int main(void){
 int H,W,i,j;
 cin >> H;
 cin >> W;

 while(H != 0 && W != 0){
     for(i = 0; i < H; i++){
         for(j = 0; j < W; j++){
             if(i == 0 || j == 0 || i == H-1 || j == W-1){
                 cout << "#";
             }
             else{
                 cout << ".";
             }
         }
         cout << endl;
     }
     cin >> H;
     cin >> W;
     cout << endl;
 }
}


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

typedef long long ll;

string s;
vector<int> v;
ll ans;

int main(){

	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='W'){
			v.push_back(i);
		}
	}
	for(int i=0;i<v.size();i++){
		ans+=v[i]-i;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1532
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

broken = [False] * (N + 1)
for ai in a:
  broken[ai] = True

memo = [0] * (N + 1)
memo[0] = 1

idx = 0
for pos in range(1, N + 1):
    if broken[pos]:
        memo[pos] = 0
    elif pos < 2:
        memo[pos] = (memo[0]) % (10 ** 9 + 7)
    else:
        memo[pos] = (memo[pos - 2] + memo[pos - 1]) % (10 ** 9 + 7)

# print("#", memo)
print(memo[-1])

Measured memory_bytes: 8592
/*
*******************
2018-11-04 Sun
*******************
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<31;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int LL;

int n,m;
int p[100005],y[100005];

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(NULL);
    cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	
    
    cin >> n >> m;
    vector<vector<pair<int,int>>> A(n+1);

    FOR(i,0,m){
        cin >> p[i] >> y[i];
        A[p[i]].pb(mp(y[i],i));
    }
    vector<pair<int,int>> ans(m);

    FORN(i,1,n){
        sort(A[i].begin(),A[i].end());
        FOR(j,0,A[i].size())
            ans[A[i][j].ss]=mp(i,j+1);
    }

    FOR(i,0,m)
        printf("%06d%06d\n",ans[i].ff,ans[i].ss);

    return 0;
}


Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {

	private static final char INCREASE = 'I';
	private static final char DECREASE = 'D';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			int max = 0, x = 0;
			for (char c : s) {
				switch (c) {
				case INCREASE:
					x++;
					max = Math.max(x, max);
					break;
				case DECREASE:
				default:
					x--;
					break;
				}
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 21844
import sys

def solve():
    input = sys.stdin.readline
    N, M, X = map(int, input().split())
    C = [[int(c) for c in input().split()] for _ in range(N)]
    minCost = 10 ** 20
    for i in range(2 ** N):
        cost = 0
        S = [0] * M
        d = i
        for j in range(N):
            if d % 2 == 1:
                cost += C[j][0]
                for k in range(M): S[k] += C[j][k + 1]
            d //= 2
        for s in S:
            if s < X: break
        else: minCost = min(minCost, cost)
    if minCost == 10 ** 20: print(-1)
    else: print(minCost)

    return  0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  cout << setprecision(10);
  string s;

  cin >> s;
  s += "0";

  PII cost = PII(0, 10000);
  for (int i = s.size() - 1; i >= 0; i--) {
    int vala = s[i] - '0';
    int valb = vala + 1;
    // if (valb == 10) valb = 0;
    int a = cost.first + vala;
    int b = min(cost.first + 10 - vala, cost.second + 10 - valb);
    // cout << a << " " << b << endl;
    if (vala < 9) {
      a = min((LL)a, cost.second + valb);
    }
    cost = PII(a, b);
  }
  cost.second++;
  cout << min(cost.first, cost.second) << endl;

  return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if ( (100*r+10*g+b)%4 == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;

}

Measured memory_bytes: 256
import math
import copy
from queue import Queue
import heapq

MOD = 1000000007

#n = int(input())
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
s = input()
#list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

num = len(s) - 1
kotae = 0

for i in range(2 ** num):
    op = [""] * num
    for j in range(num):
        if((i >> j) & 1):
            op[num - 1 - j] = "+"

    formula = ""
    for p_n, p_o in zip(s, op + [""]):
        formula += (p_n + p_o)

    kotae += eval(formula)

print(kotae)

Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin >> n >> m;
  vector<vector<int>> G(n);
  REP(i,m){
    int a,b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
  }
  
  int shortest = n+1;
  vector<int> res;
  REP(s,n){
    vector<int> dist(n, -1);
    vector<int> prev(n, -1);
    queue<int> que;
    que.push(s);
    dist[s] = 0;
    while(!que.empty()){
      auto v = que.front();
      que.pop();
      for(auto nv: G[v]){
        if(dist[nv]==-1){
          dist[nv] = dist[v] + 1;
          prev[nv] = v;
          que.push(nv);
        }
      }
    }
    REP(t,n){
      if(t==s || dist[t]==-1) continue;
      for(auto nt: G[t]){
        if(nt==s){
          vector<int> tmp({s});
          int cur = t;
          while(cur!=s){
            tmp.push_back(cur);
            cur = prev[cur];
          }
          if(shortest > tmp.size()){
            shortest = tmp.size();
            res = tmp;
          }
        }
      }
    }
  }
  
  if(shortest == n+1) cout << -1 << '\n';
  else{
    cout << res.size() << '\n';
    for(auto p: res) cout << p+1 << '\n';
  }
  return 0;
}


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

int main() {
  int n; cin >> n;
  int a[n];
  REP(i,n) cin >> a[i];
  sort(a, a+n);
  cout << a[n-1] - a[0] << endl;
  return 0;
}


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



int main(){

	int n,num,max,min;
	long long int sum;

	cin >> n;
	cin >> num;

	max = min = sum = num;


	for (int i = 0; i < n-1; i++){

		cin >> num;
		sum = sum+num;
		if (num >= max){
			max = num;
		}
		if (num <= min){
			min = num;
		}
	}
	cout << min << " " << max << " " << sum << endl;





	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  string a,b,c;
  cin>>a>>b>>c;
  char now='a';
  int x=0,y=0,z=0;
  while(1){
    if(now=='a'){
      if(x==a.size()){
        cout<<"A"<<endl;
        return 0;
      }
      now=a[x];
      x++;
    }else if(now=='b'){
      if(y==b.size()){
        cout<<"B"<<endl;
        return 0;
      }
      now=b[y];
      y++;
    }else{
      if(z==c.size()){
        cout<<"C"<<endl;
        return 0;
      }
      now=c[z];
      z++;
    }
  }


}


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

int main() {
  ll n; cin >> n;
  set<string> S;
    
  rep(i, n){
    string s; cin >> s;
    S.insert(s);
  }
  
  cout << S.size() << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int sum = 0;
  int p_max = 0;
  for( int i = 0; i < n; i++ ) {
    int p;
    cin >> p;
    p_max = max( p_max, p );
    sum += p;
  }
  cout << sum - p_max / 2 << endl;
  return 0;
}

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

#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int32_t main() {
	int x[5];
	for(int i = 0; i < 5; i++)
		cin >> x[i];
	for(int i = 0; i < 5; i++) {
		if(x[i] == 0) {
			cout << i + 1 << "\n";
			return 0;
		}
	}
}


Measured memory_bytes: 3628
#include<stdio.h>
 
long long maxim(long long a,long long b){if(a<b){return b;}return a;}
long long rou(long long a,long long b){
if(a%b){return (a/b)+1;}else{return a/b;}
}
 
int main(void){
long long n,a,b,h[131072],i,need;
long long max=10000000000,min=1,t;
scanf("%lld%lld%lld",&n,&a,&b);
for(i = 1;i <= n;i++){scanf("%lld",&h[i]);}
while(max >= min){
need = 0;
t = (max+min)/2;
for(i = 1;i <= n;i++){if(h[i]-(b*t)>0){need+=rou(h[i]-(b*t),a-b);}}
if(need <= t){max = t-1;}else{min = t+1;}
}
printf("%lld\n",min);
return 0;
}

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

int main(){
  int n;

  scanf("%d", &n);

  ll ans = 1;
  int cnt[1005];

  int i,j;

  for(i = 0;i <= 1000;i++) cnt[i] = 0;

  int a;

  for(i = 2;i <= n;i++){
    a = i;
    for(j = 2;j*j <= i;j++){
      while(a % j == 0){
        cnt[j]++;
        a /= j;
      }
    }
    if(a != 1) cnt[a]++;
  }

  for(i = 2;i <= n;i++) ans = ans*(cnt[i] + 1) % MODSIZE;

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,a[20],x[20][20],y[20][20],ans=0;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		rep(j,a[i])
		{
			cin>>x[i][j]>>y[i][j];
			x[i][j]--;
		}
	}
	rep(i,1<<n)
	{
		int res=__builtin_popcount(i);
		bool ok=true;
		rep(j,n)
		{
			if((i&(1<<j))==0) continue;
			rep(k,a[j])
			{
				if(((i>>x[j][k])&1)!=y[j][k])
				{
					ok=false;
					break;
				}
			}
			if(!ok) break;
		}
		if(ok) ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); //入力曲数
        String array[][] = new String[N][2];
        for(int i=0; i<N;i++){
            array[i][0] = sc.next(); //曲名
            array[i][1] = sc.next(); //再生時間
        }
        String X = sc.next(); //寝落ちしたときの曲
        int time = 0; //寝ていた時の再生時間
        boolean flag = false; //寝たらtrue

        for(int i=0; i<N; i++) {
            if(X.equals(array[i][0])) {
                flag = true;
                continue;
            }
            if(flag == true) {
                int n = Integer.parseInt(array[i][1]);
                time = time + n;
            }
        }
        System.out.println(time);
    }
}

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

using namespace std;
using Graph = vector<vector<int>>;
int main(){
int n,flag=1; cin >> n;
vector<long long> h(n);

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

for (int i = n-1; i >0; --i)
{
    if (h[i]<h[i-1]-1)
    {
       flag=0;
    }
    if (h[i]==h[i-1]-1)
    {
       h[i-1]--;
    }
}

if (flag)
{
    cout << "Yes";
}
else cout << "No";
return 0;
}




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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    int n; cin >> n;
    V<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    sort(ALL(v));
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(v[i] == v[j]) continue;
            for(int k = j + 1; k < n; k++){
                if(v[j] == v[k]) continue;
                if(v[i] + v[j] <= v[k] || v[i] + v[k] <= v[j] || v[j] + v[k] <= v[i]) continue;
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    int n, m;
    cin >> n >> m;
    unordered_map<ll, ll> mp;
    rep(i, n) {
        int k;
        cin >> k;
        ll a[k];
        rep(j, k) {
            cin >> a[j];
            mp[a[j]]++;
        }
    }
    ll ans = 0;
    each(s, mp) {
        if (s.second == n) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int ans=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();)
    {
         //printf("%d %c %c\n",i,s[i],s[i+1]);
        if((s[i]=='0'&&s[i+1]=='1')||(s[i]=='1'&&s[i+1]=='0'))
        {
            s.erase(i,2);
         //   cout<<i<<endl;
            i=max(i-1,0);
           // i--;
            ans++;
          //  cout<<s<<endl;
        }
        else
            i++;

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


Measured memory_bytes: 512
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 1000000009;
        for(int i = 0;i < n;i++){
            int a = sc.nextInt();
            int cnt = 0;
            while(a > 0 && a%2 == 0){
                a /= 2;
                cnt++;
            }
            if(ans > cnt)ans = cnt;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int a,z;
  rep(i,0,n){
    if(s[i]=='A'){
      a=i;break;
    }
  }
  for(int i=n-1;i>=0;i--){
   if(s[i]=='Z'){
    z=i;break; 
   }
  }
  cout<<z-a+1<<endl;
  
  
  
  
  
}

Measured memory_bytes: 3752
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  int x, i = 0;
  while (cin >> x, x) cout << "Case " << ++i << ": " << x << endl;
}

Measured memory_bytes: 3048
# https://atcoder.jp/contests/abc080/tasks/abc080_b

import itertools
import collections
import bisect

def main():
    N = int(input())
    s = sum(map(int, list(str(N))))
    print("Yes" if N % s == 0 else "No")

if __name__ == '__main__':
    main()


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

int main(){
    int N, L;
    cin >> N >> L;
    string S[N];
    string str;
    
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }
    sort(S, S + N);
    for(int i = 0; i < N; i++){
        str += S[i];
    }
    cout << str << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  vector<ll> a(n), b(n);
  REP(i, n)
    cin >> a[i];


  ll m = 0;
  for(int i = n; 1 <= i; i--){
    ll count = n / i;
    ll sum = a[i-1];

    REP(j, count-1){
      sum ^= b[(count-j)*i-1];
    }
  
    if(sum == 1)
      m++;
    b[i-1] = sum;
  }

  cout << m << endl;
  if(m == 0)
    return 0;
  else{
    REP(i, n){
      if(b[i] == 1)
        cout << i+1 << ' ';
    }
    cout << endl;
  }


}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string t="CODEFESTIVAL2016";
  string s;
  int ans=0;
  cin >> s;
  rep(i,s.size()) {
    if(s[i]!=t[i]) ans++;
  }
  pr(ans);

}

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


Measured memory_bytes: 764
n = int(input())
lst = list(map(int, input().split()))

pos = [1000, 0]

val1 = [lst[0]]

for i in range(1, n):
  if lst[i-1] != lst[i]:
    val1.append(lst[i])

val = []

n = len(val1)
val1.insert(0, 10000)
val1.append(0)

for i in range(1, n+1):
  if val1[i-1] < val1[i] > val1[i+1] or val1[i+1] > val1[i] < val1[i-1]:
    val.append(val1[i])
    

n = len(val)

if val == []:
  print(pos[0])
  exit()
  
for i in range(n):
  if i%2 == 0:
    pos[1] += pos[0]//val[i]
    pos[0] -= pos[1]*val[i]
  
  else:
    pos[0] += pos[1]*val[i]
    pos[1] = 0
    
print(pos[0])



Measured memory_bytes: 62032
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] chs = sc.next().toCharArray();
        boolean[] isOdds = new boolean[26];

        for(char ch: chs) {
            int index = ch - 'a';
            isOdds[index] = !isOdds[index];
        }

        boolean isNotBeautiful = false;

        for(boolean isOdd: isOdds) {
            isNotBeautiful |= isOdd;
        }

        if(!isNotBeautiful) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}

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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i=1; i<=n; i+=2) {
        int tmp = 0;
        for (int j=1; j<=i; ++j) {
            if (i%j == 0) tmp++;
        }
        if (tmp == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
    exit()

if H % 2 == 0 or W % 2 == 0:
    print(H * W // 2)
else:
    print(H * (W // 2) + H // 2 + 1)


Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
 
 
fn main() {
    
    let k = read::<isize>();
    let x = read::<isize>();
    
    for i in x-k+1..x+k {
        print!("{} ", i);
    }
    
    
}

Measured memory_bytes: 4352
#include<stdio.h>
#define MAX 500000

int n;

int Left(int i){
  return 2*i;
};
int Right(int i){
  return 2*i+1;
};

void MaxHeapify(int H[],int i){
  int l, r, largest;
  int tmp;
  
  l = Left(i);
  r = Right(i);

  if(l<=n && H[l]>H[i]){
    largest = l;
  }
  else largest = i;

  if(r<=n && H[r]>H[largest]){
    largest = r;
  }

  if(largest!=i){
    tmp = H[i];
    H[i] = H[largest];
    H[largest] = tmp;

    MaxHeapify(H, largest);
  }  
};
void BuildMaxHeap(int H[]){
  int i;
  for(i=n/2;i>=1;i--){
    MaxHeapify(H,i);
  }
};

int main(){
  int i;
  int H[MAX];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&H[i]);
  }
  
  BuildMaxHeap(H);

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

Measured memory_bytes: 2552
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define INT ll

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	/*.........................................kemkemG0................................................*/

	int N;
	cin >> N;
	VI A(N);
	REP(i,N){cin>>A[i]; A[i]--;}
	int sum=0;REP(i,N){int b; cin>>b; sum+=b;}
	VI C(N);
	REP(i,N-1)cin>>C[i];
	REP(i,N-1){
		if(A[i]+1==A[i+1])sum+=C[A[i]];
	}
	cout<<sum<<endl;











	return 0;
}




Measured memory_bytes: 3580
#include<stdio.h>

int main(void){
    int x, sum = 0, y;
    scanf("%d", &x);
    y = x;
    while(y >= 1){
        sum += y % 10;
        y /= 10;
    }
    if(x % sum == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
<?php
/*
    Problem URL : http://arc061.contest.atcoder.jp/tasks/arc061_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// fscanf(STDIN, "%d", $S);
$S = trim(fgets(STDIN));
$len = strlen($S);
$str = str_split($S);
$b = pow(2, $len-1);
for ($i = 0; $i < $b; $i++) {
	$strX = str_pad(decbin($i), $len, "0", STR_PAD_LEFT);
	// echo $strX . PHP_EOL;
	$x = str_split($strX);

	$arr = array();
	$cur = 0;
	for ($y = 0; $y < $len; $y++) {
		$arr[$cur] .= $str[$y];
		if ($x[$y+1] == '1') {
			$cur++;
		}
	}
	// var_dump($arr);
	// echo implode(" ", $arr) . PHP_EOL;
	$ans += array_sum($arr);
}

echo $ans . PHP_EOL;

Measured memory_bytes: 3704
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
//#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, m;
int a[100001], b[100001];
int s[100001];
int main() {
	cin >> n >> m;
	for (int i = 0; i <= n; i++)s[i] == 0;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		s[a[i]]++; s[b[i]]++;
	}
	for (int i = 0; i < n; i++) {
		if (s[i] & 1 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, k;
    cin >> n >> k;

    vector<vector<int64_t>> f(k + 1, vector<int64_t>(k + 1));
    for (auto _ : irange(0L, n)) {
        int64_t x, y;
        char c;
        cin >> x >> y >> c;

        assert(c == 'B' || c == 'W');

        if (c == 'W') {
            x += k;
        }

        if ((x / k + y / k) % 2 == 0) {
            ++f[x % k + 1][y % k + 1];
        } else {
            --f[x % k + 1][y % k + 1];
        }
    }

    for (auto x : irange(0L, k + 1)) {
        for (auto y : irange(0L, k)) {
            f[x][y + 1] += f[x][y];
        }
    }

    for (auto x : irange(0L, k)) {
        for (auto y : irange(0L, k + 1)) {
            f[x + 1][y] += f[x][y];
        }
    }

    auto nb = (n + f[k][k]) / 2;
    auto nw = (n - f[k][k]) / 2;

    int64_t ans = 0;
    for (auto x : irange(0L, k)) {
        for (auto y : irange(0L, k)) {
            int64_t t = f[k][k] - f[x][k] - f[k][y] + 2 * f[x][y];
            ans = max(ans, nw + t);
            ans = max(ans, nb - t);
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {
    int N;
    long long int H;
    cin >> N >> H;
    
    vector<long long int> A(N), B(N);
    for(int n=0; n<N; n++) {
        cin >> A[n] >> B[n];
    }
    
    sort(A.begin(), A.end(), greater<long long int>());
    sort(B.begin(), B.end());
    int idx=upper_bound(B.begin(), B.end(), A[0])-B.begin();
    int cur=N-1;
    long long int ans=0;
    while(cur>=idx && H>0) {
        H -= B[cur];
        cur--;
        ans++;
    }
    
    if(H>0) {
        ans += H/A[0];
        if(H%A[0]!=0) {
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
    
}

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

int main() {
  
  string S,T;
  cin >> S >> T;

  for(int i = 0;i < 26;i++) {
    string s = S+(char)(i+'a');
    if(s == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
int main(){
	int N,A[100001];
	ll lgc[100001],rgc[100001];
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	lgc[0]=A[0],rgc[N-1]=A[N-1];
	rep(i,N-1){
		lgc[i+1]=gcd(lgc[i],A[i+1]);
	}
	for(int i=N-1;i>0;i--){
		rgc[i-1]=gcd(rgc[i],A[i-1]);
	}
	ll ans=max(lgc[N-2],rgc[1]);
	for(int i=1;i<=N-2;i++){
		ans=max(ans,gcd(lgc[i-1],rgc[i+1]));
	}
	prin(ans);
	return 0;
}


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

int main() {
  char s[100000];

  scanf("%s", s);

  char a = s[0];
  int count = 0;
  for(int i=1;i<strlen(s);i++) {
    if(s[i] != a)
      count++;
    a = s[i];
  }

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

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [input() for i in range(n)]
alpha = "abcdefghijklmnopqrstuvwxyz"
len_alpha =len(alpha)
cnt_alpha = [[0]*len_alpha for i in range(n)]

for i in range(len_alpha):
  for j in range(n):
    cnt_alpha[j][i] = a[j].count(alpha[i])

#cnt_alphaの転置行列を取る(zip(*cnt_alpha))
cnt_alpha = list(zip(*cnt_alpha))

for i in range(len_alpha):
  print(alpha[i]*min(cnt_alpha[i]),end="")
print()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  int can_enter = a - b;
  cout << max( 0,c - can_enter ) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		HashMap<Long,Integer> map = new HashMap<>();
		while(n%2==0){
			map.put((long)2,map.getOrDefault((long)2,0)+1);
			//System.out.println(map.get((long)2));
			n=n/2;
		}
		for(long i=3;i<=Math.sqrt(n);i=i+2){
			while(n%i==0){
				n=n/i;
				map.put(i,map.getOrDefault(i,0)+1);
			}
		}
		if(n>2){
			map.put(n,map.getOrDefault(n,0)+1);
		}
		int ans =0;
		for(Map.Entry<Long,Integer> entry : map.entrySet() ){
			int y = entry.getValue();
			int u = (int)Math.sqrt(1+8*y);
			//System.out.println(u);
			u=(u-1)/2;
			//System.out.println(u);
			ans = ans+u;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35900
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 2e6 + 5;
const int mod = 1e9 + 7;
int k, ans, f[M], inv[M];
string s;

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

int modInv(int a)
{
	return power(a, mod - 2);
}

void precompute()
{
	f[0] = f[1] = 1;
	for(int i = 2; i < M; i++)
		f[i] = (f[i - 1] * i) % mod;
	inv[M - 1] = modInv(f[M - 1]);
	for(int i = M - 2; i >= 0; i--)
		inv[i] = (inv[i + 1] * (i + 1)) % mod;
}

int nCr(int n, int r)
{
	if(n < r)	return 0;
	int res = f[n];
	res = (res * inv[r]) % mod;
	res = (res * inv[n - r]) % mod;
	return res % mod;
}

int32_t main() 
{
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
    		freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	precompute();
	cin >> k >> s;
	int n = s.size();
	for(int i = 0; i <= k; i++)
	{
		int cur = nCr(n + k, n + i);
		cur = (cur * power(25, k - i)) % mod;
		ans = (ans + cur) % mod;
	}
	cout << ans << "\n";
    	return 0;
}


// https://www.youtube.com/watch?v=KhzznjSe0h0 - Approach

Measured memory_bytes: 35536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
    	int[] antena = new int[5];
    	int k;
    	String result="Yay!";
        try {
        	for (int i = 0; i<5;i++ ) antena[i] = sc.nextInt();
        	k = sc.nextInt();

        	for(int i = 0; i<4;i++) {
        		for (int j=i+1;j<5;j++) {
        			if (antena[j]-antena[i]>k) {
        				result = ":(";
        				break;
        			}
        		}
        	}
        	System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 22740
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,c1=0,c2=0,c3=0,c4=0,i;
  string s1 = "AC";
  string s2 = "WA";
  string s3 = "TLE";
  string s4 = "RE";
  string s;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>s;
    if (s=="AC")
    {
      c1++;
    }
    else if (s=="WA")
    {
      c2++;
    }
    else if (s=="TLE")
    {
      c3++;
    }
    else
    {
      c4++;
    }
  }
  cout<<s1<<" x "<<c1<<endl;
  cout<<s2<<" x "<<c2<<endl;
  cout<<s3<<" x "<<c3<<endl;
  cout<<s4<<" x "<<c4<<endl;
  return 0;
}

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
using Real = long double;
using Point = complex< Real >;
const Real EPS = 1e-12, PI = acos(-1.0L);

inline bool eq(Real a,Real b){ return fabs(b-a)<EPS;}
istream &operator>>(istream &is, Point &p) {
  Real a, b;
  is >> a >> b;
  p = Point(a, b);
  return is;
}
struct Circle{
    Point p;  //centre co-ordinate 
    Real r;     // radius of circle

    Circle()=default;
    Circle(Point p,Real r): p(p),r(r){}
};
using Points=vector<Point>;
using Circles=vector<Circle>;

int checker(Circle c1,Circle c2){
    if(c1.r<c2.r) swap(c1,c2);  //c1 is bigger circle finally
    Real d=abs(c1.p-c2.p);
    if(c1.r+c2.r<d) return 4;   // circles dont touch
    if(eq(c1.r+c2.r,d)) return 3;    // circles touch
    if(c1.r-c2.r<d) return 2;         // intersect at two points
    if(eq(c1.r-c2.r,d)) return 1;       //smaller is inside and touching bigger
    return 0;
}
bool intersect(Circle c1,Circle c2){
    int temp=checker(c1,c2);
    return 1<=temp&&temp<=3;
}
pair<Point,Point> crosspoint(const Circle &c1,const Circle &c2){
    Real d=abs(c1.p-c2.p);
    Real a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    Real t=atan2(c2.p.imag()-c1.p.imag(),c2.p.real()-c1.p.real());
    Point p1=c1.p+Point(cos(t+a)*c1.r,sin(t+a)*c1.r);
    Point p2=c1.p+Point(cos(t-a)*c1.r,sin(t-a)*c1.r);
    return {p1,p2};
}
int N,K;
Points P;
vector<int> c;
vector<long double> r;
Circles C;
void input(){
    cin>>N>>K;
    P.resize(N);
    c.resize(N);
    C.resize(N);
    r.resize(N);
    for(int i = 0; i < N; i++) {
        cin>>P[i]>>c[i];
    }
}

void solve(){
    long double ok=1e6;
    long double ng=0.0;
    F0R(timer,41){
        bool clear=false;
        long double mid=(ok+ng)/2.0;
        F0R(i,N){
            r[i]=mid/c[i];
            C[i]=Circle(P[i],r[i]);
        }
        Points Check;
        F0R(i,N){
            Check.push_back(P[i]);
            FOR(j,1,N){
                if(intersect(C[i],C[j])){
                    auto tmp=crosspoint(C[i],C[j]);
                    Check.push_back(tmp.first);
                    Check.push_back(tmp.second);
                }
            }
        }
        for(auto p:Check){
            int cnt=0;
            F0R(i,N){
                if(abs(P[i]-p)<=r[i]+EPS){
                    cnt++;
                }
            }
            if(cnt>=K){
                clear=true;
            }
        }
        if(clear){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout.precision(20);
    cout<<ok<<endl;
}

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


Measured memory_bytes: 556