akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n,m,deg[100005],visit[100005],maxn=INT_MIN;
vector <int> ke[100005];
void dfs(int u)
{
    visit[u]=1;
    for ( int i=0;i<ke[u].size();i++ )
    {
        int t=ke[u][i];
        if ( !visit[t] )
            dfs(t);
        deg[u]=max(deg[u],deg[t]+1);
    }
    if ( ke[u].empty() ) deg[u]=0;
}
int main()
{
    cin >> n >> m;
    for ( int i=1;i<=m;i++ )
    {
        int u,v;
        cin >> u >> v;
        ke[u].push_back(v);
    }
    for ( int i=1;i<=n;i++ )
        if ( !visit[i] ) dfs(i);
    for ( int i=1;i<=n;i++ )
        maxn=max(maxn,deg[i]);
    cout << maxn;
}

Measured memory_bytes: 8576
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr(mod) -- START --
class ComMod():
  def __init__(self,n,mod):
    self.n=n
    self.mod=mod
    self.fact=[0]*(n+1)
    self.ifact=[0]*(n+1)
    self.fact[0]=1  
    for i in range(1,n+1):
      self.fact[i]=self.fact[i-1]*i
      self.fact[i]%=self.mod
    self.ifact[n]=pow(self.fact[n],self.mod-2,self.mod)
    for i in range(n,0,-1):
      self.ifact[i-1]=self.ifact[i]*i
      self.ifact[i-1]%=self.mod
  def com(self,n,k):
    if n<0 or k<0 or n<k:
      return 0
    return self.fact[n]*(self.ifact[k]*self.ifact[n-k]%self.mod)%self.mod
# nCr(mod) --- END ---

# nCr -- START --
def nCr(n,r):
  if n<r:
    return 0
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
# nCr --- END ---

def main():
  n=I()
  ans=0
  for i in range(1,n//3+1):
    k=n-3*i
    # com=ComMod(k,mod)
    # _ans=com.com(k+i-1,i)
    # _ans%=mod
    # ans+=_ans
    # ans%=mod
    _ans=nCr(i+k-1,k)
    _ans%=mod
    # print(_ans)
    ans+=_ans
    ans%=mod
  
  return ans%mod

# main()
print(main())


Measured memory_bytes: 10692
#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);
  string s;
  cin >> s;
  char bef = s[0];
  int res = 0;
  repz(i, 1, SIZE(s)) {
    if (bef == s[i]) {
      res++;
      if (s[i] == '1')
        s[i] = '0';
      else
        s[i] = '1';
    }
    bef = s[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 512
while n = gets.to_i
  break if n == 0
  table = {}
  n.times do
    sh, sm, ss, th, tm, ts = gets.split(/\s|:/).map(&:to_i)
    p = sh * 3600 + sm * 60 + ss
    q = th * 3600 + tm * 60 + ts
    if table[p].nil? then table[p] = 1
    else table[p] += 1; end
    if table[q].nil? then table[q] = -1
    else table[q] -= 1; end
  end
  table = table.sort.transpose[1]
  (1...table.size).each{ |i| table[i] += table[i-1]}
  p table.max
end

Measured memory_bytes: 12608
N,M=map(int, input().split())
S=list(map(int, input().split()))
T=list(map(int, input().split()))

mod = 10**9+7

#dp[i][j]:=Sのi字目とTのj字目までの共通部分列の数
dp=[[1 for i in range(M)] for j in range(N)]
for i in range(N):
  for j in range(M):
    if i==0:
      if j==0:
        if S[i]==T[j]:
          dp[i][j] = dp[i][j]+1
      elif S[i]==T[j]:
        dp[i][j] = (dp[i][j-1]+1)%mod
      else:
        dp[i][j] = dp[i][j-1]
    elif j==0:
      if S[i]==T[j]:
        dp[i][j] = (dp[i-1][j]+1)%mod
      else:
        dp[i][j] = dp[i-1][j]
    else:
      if S[i]!=T[j]:
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1])%mod
      else:
        dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod
print(dp[N-1][M-1]%mod)

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#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 MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  int n, ret = 0;
  while(cin >> n) {
    ret = 0;
    REP(i1, 10) REP(i2, 10) REP(i3, 10) REP(i4, 10) {
      if(i1 + i2 + i3 + i4 == n) ++ret;
    }
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 3092
using System;
class c
{
    static void Main()
    {
        {
            int n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (i + 1 == a[a[i] - 1]) ans++;
            }
            Console.WriteLine(ans / 2);
        }
    }
}

Measured memory_bytes: 18912
#include <stdio.h>
#include <math.h>
#include <string.h>



int main()
{
	int a, i, j,  k = 0;
	scanf("%d", &a);
	for ( i = 1; i < 10; i++)
	{
			for ( j = 1; j < 10; j++)
			{
				if (i * j == a)
				{
					k = 1;
				}
				
			}
	}
	if (k == 1)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpll vector<pair<ll,ll>>
#define INF 0x3f3f3f3f
#define mp make_pair

int main() {
    ll n;
    in(n);
    string s;
    cin>>s;
    if(s.size()%2==1) {
        cout<<"No"<<endl;
        return 0;
    }
    for(ll i=0,j=n/2;i<n/2;i++,j++) if(s[i]!=s[j]) {
        cout<<"No"<<endl;return 0;
    } 
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 256
parseInt()=map(x->parse(Int,x),split(readline()))
const N,Q=parseInt()
const G=[Tuple{Int,Int,Int}[] for _=1:N]
const depth=zeros(Int,N)
const parent=[zeros(Int,N) for _=1:17]
const tour=Pair{Int,Int}[]
const L=zeros(Int,N)
const edge=[Int[] for _=1:N-1]
const edgesum=[Int[0] for _=1:N-1]
const edgecnt=[Int[0] for _=1:N-1]
const cumsum=Int[0]
function bsearch(A,x)
	L=0
	R=length(A)+1
	while R-L>1
		M=div(L+R,2)
		if A[M]>=x
			R=M
		else
			L=M
		end
	end
	R
end
function dfs(u,p,de)
	depth[u]=de
	parent[1][u]=p
	L[u]=length(tour)+1
	for (v,c,d)=G[u]
		if v!=p
			push!(tour,c=>d)
			dfs(v,u,de+1)
			push!(tour,c=>-d)
		end
	end
end
function lca(u,v)
	if depth[u]>depth[v]
		u,v=v,u
	end
	for k=1:17
		if ((depth[v]-depth[u])>>(k-1))%2==1
			v=parent[k][v]
		end
	end
	if u==v
		return u
	end
	for k=17:-1:1
		if parent[k][u]!=parent[k][v]
			u=parent[k][u]
			v=parent[k][v]
		end
	end
	parent[1][u]
end
function get(l,r,c)
	lid=bsearch(edge[c],l)
	rid=bsearch(edge[c],r)
	edgecnt[c][rid]-edgecnt[c][lid],edgesum[c][rid]-edgesum[c][lid]
end
function calc(u,v,x,y)
	flag=false
	if L[u]>L[v]
		u,v=v,u
		flag=true
	end
	ret=cumsum[L[v]]-cumsum[L[u]]
	cnt,sum=get(L[u],L[v],x)
	ret-=sum
	ret+=cnt*y
	if flag
		ret=-ret
	end
	ret
end
function main()
	for _=2:N
		a,b,c,d=parseInt()
		push!(G[a],(b,c,d))
		push!(G[b],(a,c,d))
	end
	dfs(1,0,0)
	now=0
	for i=1:length(tour)
		c,d=tour[i]
		push!(edge[c],i)
		push!(edgesum[c],edgesum[c][end]+d)
		push!(edgecnt[c],edgecnt[c][end]+(d>0?1:-1))
		push!(cumsum,now+=d)
	end
	for k=2:17
		for i=1:N
			if parent[k-1][i]>0
				parent[k][i]=parent[k-1][parent[k-1][i]]
			else
				parent[k][i]=0
			end
		end
	end
	for _=1:Q
		x,y,u,v=parseInt()
		pa=lca(u,v)
		println(calc(pa,u,x,y)+calc(pa,v,x,y))
	end
end
main()

Measured memory_bytes: 230444
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include<functional>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 30005
#define maxn 100005
typedef pair<int,int> PII;
typedef long long LL;

int n,m;
int a[511];
int main(){
    //freopen("in.txt","r",stdin);
    int i,j;
    while(scanf("%d",&n)!=EOF){
            n<<=1;
        for(int i=1;i<=n;++i)scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    LL ans=0;
    for(int i=1;i<n;i+=2)ans+=a[i];
    printf("%lld\n",ans);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

int n;
string s;
set<string> items;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> s;
        items.insert(s);
    }
    cout << items.size() << "\n";
    return 0;
}

Measured memory_bytes: 19276
S=input()
s1=S[0:2]
s2=S[2:4]
li=["01","02","03","04","05","06","07","08","09","10","11","12"]

if s1 not in li:
    a=False
else:
    a=True
if s2 not in li:
    b=False
else:
    b=True

if a==b==True:
    print("AMBIGUOUS")
elif a==b==False:
    print("NA")
elif a==True:
    print("MMYY")
else:
    print("YYMM")


Measured memory_bytes: 9072
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    char a[10], b[10], c[10];
    cin >> a >> b >> c;
    if (a[strlen(a) - 1] == b[0] && b[strlen(b) - 1] == c[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    string s;
    string p;
    cin>>s>>p;
    char tmp[300];
    for(int i=1;i<=2;i++){
        for(int j=0;j<s.size();j++){
            if(i==2){
                tmp[j+s.size()]=s[j];
            }
            else{
                tmp[j]=s[j];
            }
        }
    }
    bool judge=false;
    for(int i=0;i<s.size()+s.size();i++){
        if(p[0]==tmp[i]){
            //cout<<p[0]<<":"<<tmp[i]<<endl;
            judge=true;
            for(int j=0;j<p.size();j++){
                //cout<<p[j]<<":"<<tmp[j+i]<<endl;
                if(p[j]!=tmp[i+j]){
                    judge=false;
                    break;
                }
            }
        }
        if(judge){
            break;
        }
    }
    if(judge){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    //cout<<judge<<endl;
    return 0;
}



Measured memory_bytes: 3220
N = int(input())
Arr = []
tmp = []
for i in range(N):
    tmp = list(map(str, input().split()))
    tmp.append(i+1)
    tmp[1] = int(tmp[1])
    Arr.append(tmp)

Arr.sort(key=lambda x: x[1], reverse=True)
Arr.sort(key=lambda x: x[0])

for i in range(N):
    print(Arr[i][2])

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;    
    
    vector<vector<P>> G(n);  // 辺の重みがすべて0以上のグラフ
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, 1));
    }

    ll sv, gv;
    cin >> sv >> gv;
    sv--;  gv--;

    // 拡張ダイクストラ法。計算量はO((V+E)*log(V))
    vvl dist(n, vl(3, INF));  // dist[v][x] : 頂点svから頂点vへの3で割った余りがxとなる最短距離
    dist[sv][0] = 0;
    priority_queue<pair<ll, P>, vector<pair<ll, P>>, greater<pair<ll, P>>> prQ;
    prQ.push(make_pair(dist[sv][0], make_pair(sv, 0)));  // (頂点vまでの余りがxのときの距離, (いまいる頂点v, 余りx))
    while(!prQ.empty()) {
        auto p1 = prQ.top();
        prQ.pop();
        ll v = p1.second.first;
        ll x = p1.second.second;
        if(dist[v][x] < p1.first) {
            continue;
        }
        for(auto p2 : G[v]) {
            ll u = p2.first;
            ll cost = p2.second;
            ll nx = (x + cost)%3;
            if(dist[u][nx] > dist[v][x] + cost) {
                dist[u][nx] = dist[v][x] + cost;
                prQ.push(make_pair(dist[u][nx], make_pair(u, nx)));
            }
        }
    }
    
    if(dist[gv][0] == INF) {
        out(-1);
    }
    else {
        out(dist[gv][0]/3);
    }

    re0;
}

Measured memory_bytes: 11136
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

const long long MAX = 1e17;
using namespace std;

struct Edge {
	int to;
	int cost;
};

vector<vector<Edge>> tateedge, yokoedge;
vector<long long> tate, yoko;
vector<bool> tated, yokod;




bool saiki(int now, long long num, bool istate, pair<long long, long long> &minpair) {
	if (istate) {
		if (tated[now]) {
			if (tate[now] != num) {
				return false;
			}
			return true;
		}
		tated[now] = true, tate[now] = num;
		minpair.first = min(minpair.first, num);
		for (auto &t : tateedge[now]) {
			if (!saiki(t.to, t.cost - num, false, minpair))
				return false;
		}
		return true;
	}
	else {
		if (yokod[now]) {
			if (yoko[now] != num) {
				return false;
			}
			return true;
		}
		yokod[now] = true, yoko[now] = num;
		minpair.second = min(minpair.second, num);
		for (auto &t : yokoedge[now]) {
			if (!saiki(t.to, t.cost - num, true, minpair))
				return false;
		}
		return true;

	}
}


int main() {
	int R, C;
	cin >> R >> C;
	int N;
	cin >> N;
	vector<int> r(N), c(N), a(N);
	for (int i = 0; i < N; i++) {
		cin >> r[i] >> c[i] >> a[i];
		r[i]--, c[i]--;
	}

	tateedge.resize(R);
	yokoedge.resize(C);
	tate.resize(R);
	yoko.resize(C);
	tated.resize(R, false);
	yokod.resize(C, false);


	for (int i = 0; i < N; i++) {
		tateedge[r[i]].push_back({ c[i], a[i] });
		yokoedge[c[i]].push_back({ r[i], a[i] });
	}
	bool res = true;
	for (int i = 0; i < R; i++) {
		pair<long long, long long> minp{ MAX,MAX };
		if (tated[i] || tateedge[i].empty())
			continue;
		if (!saiki(i, -100, true, minp)) {
			res = false;
			break;
		}
		if (minp.first + minp.second < 0) {
			res = false;
			break;
		}
	}
	cout << (res ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s =="SUN") cout<<"7"<<endl;
  if(s =="MON") cout<<"6"<<endl;
  if(s =="TUE") cout<<"5"<<endl;
  if(s =="WED") cout<<"4"<<endl;
  if(s =="THU") cout<<"3"<<endl;
  if(s =="FRI") cout<<"2"<<endl;
  if(s =="SAT") cout<<"1"<<endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut n: i32,
        m: i32,
        days: [i32; m],
    }
    for i in days {
        n -= i;
    }

    if n >= 0 {
        println!("{}", n);
    } else {

        println!("-1");
    }
}


Measured memory_bytes: 2192
#include<bits/stdc++.h>
#define ld long double
#define ll long long
#define st first
#define nd second
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
using namespace std;
const ll mod = 998244353;
const int MAXN = 301;
int n, k;
string s;
ll dp[MAXN][MAXN], f[MAXN];
ll inv(ll x, ll p=mod-2) {
	if(p==0) return 1;
	ll y = inv(x, p/2);
	y = y * y % mod;
	if(p%2==0) {
		return y;
	}
	return y*x%mod;
}
ll C(int N, int K) {
	if(K > N) return 1;
	return f[N] * inv(f[K] * f[N-K] % mod) % mod;
}
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s>>k;
	n = s.size();
	f[0] = 1;
	for(int i=1; i<=n; ++i) {
		f[i] = f[i-1] * (ll)i % mod;
	}
	k = min(k, n);
	vi block;
	if(s[0] == '0') block.push_back(1);
	else {
		block.pb(0);
		block.pb(1);
	}
	for(int i=1; i<n; ++i) {
		if(s[i] != s[i-1]) {
			block.pb(0);
		}
		block.back()++;
	}
	dp[0][0] = 1;
	for(int i=(int)block.size()-1; i>=0; --i) {
		int cnt = block[i];
		if(cnt==0) continue;
		vector<vector<ll>> prefj(k+1, vector<ll>(k+1));
		for(int x=0; x<=k; ++x) {
			prefj[x][0] = dp[x][0];
			for(int j=1; j<=k; ++j) {
				prefj[x][j] = (prefj[x][j-1] + dp[x][j]) % mod;
			}
		}
		if(i%2==0) {
			for(int c = 1; c < cnt; ++c) {
				for(int j=k; j>=0; --j) {
					vector<ll> pref(k+1);
					pref[0] = dp[0][j];
					for(int x=1; x<=j; ++x) {
						pref[x] = (pref[x-1] + dp[x][j])%mod;
					}
					for(int x=j; x>=0; --x) {
						dp[x][j] += ((x==0)?0:pref[x-1]);
						dp[x][j] %= mod;	
					}
				}
			}
		}
		
		if(i%2==1) {
			for(int j=k; j>=0; --j) {
				vector<ll> pref(k+1);
				pref[0] = dp[0][j];
				for(int x=1; x<=j; ++x) {
					pref[x] = (pref[x-1] + dp[x][j]) % mod;
				}
				for(int x=j; x>=0; --x) {
					if((int)block.size() - i > 2) {
						dp[x][j] += ((x==0)?0:pref[x-1]);
						dp[x][j] %= mod;
					}
					if(j != 0) {
						dp[x][j] += (prefj[x][j-1] - ((max(0, j-cnt)==0)?0:prefj[x][j-cnt-1]) + mod) % mod;
						dp[x][j] %= mod;
					}
				}
			}
		}
	}
	ll ans = 0;
	for(int i=0; i<=k; ++i) {
		ans += dp[i][i];
		ans %= mod;
		for(int j=0; j<i; ++j) {
			if(block[0] > 0) {
				ans += dp[j][i];
				ans %= mod;
			}
		}
	}
	cout<<ans;
}


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

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

Measured memory_bytes: 3652
#include <stdio.h>
#define max(x,y) ((x>y)?x:y)

typedef struct {
	int parent;
	int left;
	int right;
} node_t;

node_t node[100];
int n;

void printTree();
int getSibling(int);
int getDegree(int);
int getDepth(int);
int getHeight(int);

int main() {
	int i;
	int ID, left, right;
	scanf("%d", &n);
	for (i = 0; i < n; i++) node[i].left = node[i].right = node[i].parent = -1;
	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &ID, &left, &right);
		node[ID].left = left;
		node[ID].right = right;

		if (left != -1) node[left].parent = ID;
		if (right != -1) node[right].parent = ID;
	}
	printTree();
}

void printTree() {
	int i;
	for (i = 0; i < n; i++) {
		printf("node %d: parent = %d, ", i, node[i].parent);
		printf("sibling = %d, ", getSibling(i));
		printf("degree = %d, ", getDegree(i));
		printf("depth = %d, ", getDepth(i));
		printf("height = %d, ", getHeight(i));
		
		if (node[i].parent == -1) printf("root");
		else if (node[i].left == -1 && node[i].right == -1) printf("leaf");
		else printf("internal node");
		printf("\n");
	}
}

int getSibling(int ID) {
	if (node[ID].parent != -1 && node[node[ID].parent].right != ID) return node[node[ID].parent].right;
	if (node[ID].parent != -1 && node[node[ID].parent].left != ID) return node[node[ID].parent].left;
	return -1;
}

int getDegree(int ID) {
	int count = 0;
	if (node[ID].right != -1) count++;
	if (node[ID].left != -1) count++;
	return count;
}

int getDepth(int ID) {
	int depth = 0;
	while (node[ID].parent != -1) {
		depth++;
		ID = node[ID].parent;
	}
	return depth;
}

int getHeight(int ID) {
	if (ID == -1) return -1; 
	return 1 + max(getHeight(node[ID].left), getHeight(node[ID].right));
}



Measured memory_bytes: 2112
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  if((abs(a-b)<=d and abs(c-b)<=d) or abs(a-c) <= d)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
	long long int n, k;
	long double x=0;
	string str, str2;
	cin >> n >> k ;
	for (int i = 1; i <= n; i++) {
		int tmp = 0,imemo=i;
		long double ppp = 1.0;
		while (imemo < k) {
			tmp++;
			imemo *= 2;
			ppp *= 0.5L;
		}
		x += ppp * (1.0L / n);
	}
	cout <<x;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner sc  = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        int sum = 1;
        
        if(a!=1){
        
        for(int i = 0 ; i < a ;i++){
            
            if(i==0)sum *= b;
            if(i!=1)sum *= b-1;
            
        }
        }
        else {
            sum = b;
        }


        System.out.print( sum );
        System.out.println();
	}
}

Measured memory_bytes: 9672
#include <stdio.h>
int main(){
	char a[1001],b[1001];
	gets(a);
	gets(b);
	int len1=strlen(a),len2=strlen(b),max=0,num=0;
	for(int i=0;i<=len1-len2;i++){
		num=0;
		for(int j=0;j<len2;j++){
			if(a[i+j]==b[j])num++;
		}
		if(num>max)max=num;
	}
	printf("%d",len2-max);
	return 0;
}


Measured memory_bytes: 1640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){

  


  int n,d,x,at,out;
  vector<int> a;

  cin >> n >> d >> x;
  for(int i =0; i< n;i++)
    {
      cin >> at;
    a.push_back(at);
    }
  int warareru = d - 1;
  vector<int> kotae;
  int tmp;
  for(int w : a)
    {
      tmp = warareru / w;
      kotae.push_back(tmp);
    }
  int sum = accumulate(kotae.begin(), kotae.end(), 0);
  int kutta = n + sum;
  // for(int h:a)
  //   cout << h<<endl;
  out = kutta + x;
  cout<<out<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    int sum=0;
    rep(i,m){
        sum += v[i];
    }
    cout << sum;
    
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long int ans = 1e15, a, b;
  for(int i = 0; i < N; ++i){
    cin >> a >> b;
    ans = min(ans, a+b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
a, b = map(int, input().split())
c = []
for i in range(a):
    d, e = map(int, input().split())
    c.append([d, e])
c.sort()
g = 0
for i in range(a):
    f = min(b, c[i][1])
    b -= f
    g += f * c[i][0]
    if b == 0:
        break
print(g)


Measured memory_bytes: 20064
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
 	int n;
  	cin >> n;
  	vector <int> a(n);
  
  	for(int & x: a)
      	cin >> x;
  	
 	int ans = 0;
  
  	for(int i = 1; i + 1 < n; ++i)
    {
     	 if(a[i] < a[i - 1] && a[i] > a[i + 1])
          	++ans;
   		if(a[i] > a[i - 1] && a[i] < a[i + 1])
          	++ans;
    }
  
  	cout << ans << '\n';
  	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
const ll inf = 1000000007;
int main() {
  ll n,k,s; cin >>n>>k>>s;
  vector<ll> ans(n);
  if(s>2){
  rep(i,k)ans[i]=s;
  rep2(i,k,n) ans[i]=s-1;
  rep(i,n-1)cout <<ans[i]<<" ";
  cout <<ans[n-1]<<endl;
  }else{
  rep(i,k)ans[i]=s;
  rep2(i,k,n) ans[i]=s+1;
  rep(i,n-1)cout <<ans[i]<<" ";
  cout <<ans[n-1]<<endl;
  }   
}

Measured memory_bytes: 2048
// D - Redistribution
#include <bits/stdc++.h>
using namespace std;

int main(){
	int S; cin>>S;
	int MOD = 1e9 + 7;
	vector<int64_t> C(S+1, 0);
	C[0] = 1;
	for(int n=3; n<=S; ++n) C[n] = (C[n-1] + C[n-3]) % MOD;
	cout<< C[S] <<endl;
}


Measured memory_bytes: 3616
#include<iostream>

using namespace std;

int i, N, K, x, y, check[1000];

int main(){

	cin >> N >> K;
	for(i=0;i<K;i++){
		cin >> x >> y;
		if(x>N/2){x=N-x+1;}
		if(y>N/2){y=N-y+1;}
		if(x>y){x=y;}

		check[i]=(x-1)%3+1;
	}

	for(i=0;i<K;i++){
		cout << check[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1168
dp, n = [0, 0, 0], int(input())
for i in range(n):
  a, b, c = map(int, input().split ())
  dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[1], dp[0]) + c]
print(max(dp))

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

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    vector<int> vec(3);
    vec[0] = abs(a1 - a2);
    vec[1] = abs(a1 - a3);
    vec[2] = abs(a2 - a3);
    sort(vec.begin(), vec.end());
    cout << vec[0] + vec[1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	if(a+b>c+d)cout<<"Left"<<endl;
	else if(a+b<c+d)cout<<"Right"<<endl;
	else cout<<"Balanced"<<endl;
}

	


Measured memory_bytes: 256
using System;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split();
            int[] a = new int[n];
           
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
            }

            int cnt = 0;
            int m=0;

            while ((a[m] % 2) == 0) { 
                a[m] /= 2;
                m++;
                if (m == n )
                {
                    cnt++;
                    m = 0;
                   
                }
                
                
            }


            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	int n;
	double x1, y1, x2, y2, x3, y3;
	double xp, yp, r;
	
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
		
		xp = (((x2*x2+y2*y2)-(x3*x3+y3*y3))*(y2-y1)-((x1*x1+y1*y1)-(x2*x2+y2*y2))*(y3-y2)) / (2*((x2-x1)*(y3-y2)-(x3-x2)*(y2-y1)));
		yp = (((y2*y2+x2*x2)-(y3*y3+x3*x3))*(x2-x1)-((y1*y1+x1*x1)-(y2*y2+x2*x2))*(x3-x2)) / (2*((y2-y1)*(x3-x2)-(y3-y2)*(x2-x1)));
		r = sqrt((x1-xp)*(x1-xp) + (y1-yp)*(y1-yp));
		
		printf("%.3lf %.3lf %.3lf\n", xp, yp, r);
	}
	
	return 0;
}

Measured memory_bytes: 1092
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+6;
int k,n;
void solve(){
	cin>>n>>k; 
	int st = 1;
	for(int i=1;i<=n;i++){
		if(st*2<st+k)st*=2;
		else st+=k;
	}
	cout<<st<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c,d,e;
int main(){
  scanf("%d%d%d",&a,&b,&c);
  d=max(max(a,b),c);
  e=min(min(a,b),c);
  printf("%d\n",d-e);
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli L[2001] = {};

int main(void) {
	lli N;
	cin >> N;

	lli answer = 0;

	for (int i = 0; i < N; i++)
		cin >> L[i];

	sort(L, L + N);

	for (int i = 0; i < N; i++) {
		for (int k = i + 1; k < N; k++) {
			lli a = L[i];
			lli b = L[k];

			lli tmp = lower_bound(L + k + 1, L + N, a + b) - (L + k + 1);

			//max(a-b,b-a) < c < a + b
			//どこまでかという範囲を考えるのが苦手なので
			// A < B < C　だったら upper , lowerで範囲を取れることを覚えたい

			answer += tmp;
		}
	}

	COUT(answer);

	return 0;
}

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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	deque<char> deq;
	for(char c : s) deq.push_back(c);

	int q;
	cin >> q;

	int cng = 0;
	while(q--){
		int t;
		cin >> t;

		if(t == 1){
			cng = 1 - cng;
		}else{
			int f;
			char c;
			cin >> f >> c;

			if((f + cng) % 2 == 1){
				deq.push_front(c);
			}else{
				deq.push_back(c);
			}
		}
	}

	string ans;
	for(char c : deq) ans.push_back(c);
	if(cng == 1) reverse(ans.begin(), ans.end());
	cout << ans << endl;
}


Measured memory_bytes: 1368
#include <stdio.h>
#include <stdlib.h>
#define STACK_MAX  101               /* スタックサイズ */
#define STACK_OK   0x8000           /* スタック成功を表すデータ */
#define STACK_FULL STACK_OK + 1     /* スタックサイズを超えたときのデータ */
#define STACK_END  STACK_OK + 2     /* スタックの終わりを表すデータ */
/* 関数のプロトタイプ宣言 */
int     push(int);          /* スタックにデータを積む関数 */
int     pop(void);          /* スタックからデータを取り出す関数 */
/* グローバル変数 */
int     stack[STACK_MAX];   /* スタック領域 [0] - [19] */
int     stack_pointer = 0;  /* スタックポインタ */

int main(void)
{  int x=0,y=0,n,flag=0,bai,total;
  int i=0,j;
  char data;
  while((scanf("%c",&data)!=EOF)){
      
	  if(data=='+'){
				push(pop()+pop());
	  }
	  else if(data=='-'){
			
				y = pop();
				x = pop();
				push(x-y);
	  }
	  else if(data=='*'){
				x = pop();
				y = pop();
				push(x*y);
	  }
	  else if(data==' '){
	    bai=1;
	    total=0;
	    if(flag>=2){
	      for(j=1;j<=flag;j++){
		
		total+=pop()*bai;
		  bai*=10;
	      }
	      push(total);
	    }
	    flag=0;
	  }
	  else if(data=='\n'){
	    break;
	  }
	  else {
	    n=data-'0';
	    push(n);
	    flag++;
	  }
	}
  printf("%d\n",pop());
    
	return 0;
}
int push(int d)
{
  //printf("check %d\n",d);
  if(stack_pointer >= STACK_MAX)  /* スタックポインタが最大 */
        return(STACK_FULL);         /* STACK_FULLを返す */
    stack[stack_pointer] = d;       /* スタックにデータ格納 */
    ++stack_pointer;                /* スタックポインタに1加算 */
    return(STACK_OK);               /* STACK_OKを返す */
}
int pop(void)
{
    if(stack_pointer == 0)          /* スタックポインタが0 */
        return(STACK_END);          /* STACK_ENDを返す */
    --stack_pointer;                /* スタックポインタから1減算 */
    return(stack[stack_pointer]);   /* スタックのデータを返す */
}




Measured memory_bytes: 2144
#include <stdio.h>
#include <algorithm>
using namespace std;

int N; long long A[200200];

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<=N;i++) scanf ("%lld",&A[i]), A[i] += A[i-1];

	long long ans = 1e18;

	for (int i=2;i<=N-2;i++){
		int p = lower_bound(A+1,A+N+1,A[i]/2) - A;
		int q = lower_bound(A+1,A+N+1,(A[i]+A[N])/2) - A;
		for (int a=-1;a<=0;a++) for (int b=-1;b<=0;b++){
			int x = p + a, y = q + b;
			if (x < 1 || x > i || y <= i || y > N) continue;
			long long mx = max({A[x],A[i]-A[x],A[y]-A[i],A[N]-A[y]});
			long long mn = min({A[x],A[i]-A[x],A[y]-A[i],A[N]-A[y]});
			ans = min(ans,mx-mn);
		}
	}
	printf ("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
 
public class Main{
	
	static int gcd(int a, int b){
		if(a<b){
			int temp= a;
			a=b;
			b=temp;
		}
		if(b==0) return a;
		return gcd(a%b,b);
	}
	
	
	public static void main(String []args){
	    Scanner sc= new Scanner(System.in);
	    
		int n=sc.nextInt();
		int[] A = new int [n];
		int[] L = new int [n];
		int[] R = new int [n];
		
		for(int i=0;i<n; i++){
		    A[i]=sc.nextInt();
		}
		
		L[0]=0;
		R[0]=0;
		
		for (int i=1; i<n; i++){
		    L[i]=gcd(L[i-1],A[i-1]);
		    R[i]=gcd(R[i-1],A[n-i]);
		}
		
		int gcd=0;
		
		for (int i=0; i<n; i++){
		    int temp=gcd(L[i], R[n-i-1]);
		    
		    if(gcd<temp){
		        gcd=temp;
		    }
		    
		}
		System.out.println(gcd);
		
    }
}


Measured memory_bytes: 50032
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MOD = 1000000007;


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

    int ans = 0;
    rep(i,N){
        if((i+1)%2 == 1 && a[i]%2 == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
using ll = long long;

int main(){
	int N;
	ll T,t[200010]={},answer=0;
	
	cin >> N >>T;
	for(int i=0;i<N;i++){
		cin >> t[i] ;
	}
	
	for(int i=0;i<N-1;i++){
		if(t[i+1]-t[i]<T){
			answer+=t[i+1]-t[i];
		}else{
			answer+=T;
		}
	}
	
	answer+=T;
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 1792
N,M = map(int,input().split())
A = [0]*M
ans = 0
for i in range(N):
  k = list(map(int,input().split()))
  for j in range(1,len(k)):
    A[k[j]-1] += 1
for i in range(len(A)):
  if A[i] == N:
    ans += 1
print(ans)

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

int main() {
	int n, i, y;
	int a[200000] = { 0 };

	cin >> n;

	for (i = 0; i < n - 1; i++) {
		cin >> y;
		a[y - 1]++;
	}
	for (i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n,b[N];

int main() {
   scanf("%d" , &n);
   for (int i = 1 ; i < n ; i++) {
      scanf("%d" , &b[i]);
   }
   int sol = 0;
   for (int i = n ; i >= 1 ; i--) {
      if (i >= 2 && i <= n - 1) {
         sol += min(b[i - 1] , b[i]);
      } else if (i == n) {
         sol += b[i - 1];
      } else {
         sol += b[1];
      }
   }
   printf("%d\n" , sol);
}


Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC\n";
    else
        cout<<"ABC\n";
	printclock;
	return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    long long m=10000000000;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n+1-k;i++)
    {
        long long y=(a[i+k-1]-a[i]);
        if(y<m)
        {
            m=y;
        }
    }
    cout<<m<<endl;
}


Measured memory_bytes: 640
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            char out = c;
            if (c >= 'a' && c <= 'z') {
                out = (char) (c - ('a' - 'A'));
            } else if (c >= 'A' && c <= 'Z') {
                out = (char) (c + ('a' - 'A'));
            }
            System.out.print(out);
        }
        System.out.println();
    }
}


Measured memory_bytes: 25092
#include <stdio.h>
#include <string.h>

int main()
{
  int n,i,j,k;
  int A[100],B[3000];

memset(B,0,sizeof(B));
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,A + i);
  }

  B[0] = 1;
  for(i = 0 ; i < n ; i++)
    {
      for(j = 2000 ; j >= 0 ; j--)
	{
	  if(B[j] && j + A[i] <= 2000)
	    {
	      B[j + A[i]] = 1;
	    }
	}
    }
  
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,&k);
    if(B[k])
      {
	puts("yes");
      }
    else
      {
	puts("no");
      }
  }

  return 0;

}



Measured memory_bytes: 2144
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();

        long ans = 0;
        long now = 100;
        while (true) {
            ans++;
            now *= 1.01;
            if (now >= x) {
                System.out.println(ans);
                return;
            }
        }
    }
}

Measured memory_bytes: 35740
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n,w;
	while(cin>>n>>w,n||w){
		vector<double> v(12,0);
		int M=0;
		rep(i,n){
			int t;
			cin>>t;
			M=max(M,t/w);
			v[t/w]+=1;
		}
		double ans=0.01;
		double ma=v[0];
		rep(i,12){
			ma=max(ma,v[i]);
		}
		rep(i,M+1){
			ans+=(v[i]/ma)*(M-i)/M;
		}
		printf("%.10lf\n",ans);
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)x
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 3e3 + 5;

int n, half;
double prob[N];
double dp[N][N];
bool vis[N][N];

double f(int idx, int tail) {
    if(idx > n) return tail < half ? 1 : 0;
    double &sol = dp[idx][tail];
    if(vis[idx][tail]) return sol;
    vis[idx][tail] = true;
    sol = f(idx + 1, tail) * prob[idx] + f(idx + 1, tail + 1) * (1 - prob[idx]);
    return sol;
}

void solve() {
    cin >> n;
    half = n / 2 + (n & 1 ? 1 : 0);
    for(int i = 1; i <= n; i++) {
        cin >> prob[i];
    }
    cout << fixed << setprecision(10) << f(1, 0) << "\n";
}

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

    solve();
    
}

Measured memory_bytes: 58960
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Info{
    int number;
    int A;
    
    Info(int inputted_name, int inputted_age)
    {
        number = inputted_name;
        A = inputted_age;
    }
    bool operator<(const Info &another) const
    {
        return A < another.A;
    }
};

int main(void){
    // Your code here!
    int N;
    int h;
    cin >> N ;

    std::vector<Info> info;
    
    for (int i = 0; i < N; i++){
        cin >> h;
        info.push_back(Info(i + 1, h));
    }
    
    std::sort(info.begin(), info.end());
    
    for (auto itr : info)
    {
        cout << itr.number << " ";
    }

}


Measured memory_bytes: 1780