akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int N, M;
vector<int> G[100100];
int S, T;
int d[100100];
bool used[100100];


int bfs() {
    queue<int> que;

    rep(i, N) d[i] = 1001000;
    que.push(S);
    d[S] = 0;

    while(que.size()) {
        int k = que.front(); que.pop();
        if(k == T) break;
        for(auto i : G[k]) {
            if(used[i]) continue;
            used[i] = true;
            for(auto j : G[i]) {
                for(auto l : G[j]) {
                    if(d[l] == 1001000) {
                        que.push(l);
                        d[l] = d[k] + 1;
                    }
                }
            }
        }
    }

    if(d[T] == 1001000) return -1;
    return d[T];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> M;
    rep(i, N) used[i] = false;
    rep(i, M) {
        int u, v; cin >> u >> v;
        u --; v --;
        G[u].pb(v);
    }
    cin >> S >> T; S --; T --;

    int res = bfs();
    cout << res << endl;

	return 0;
}


Measured memory_bytes: 6272
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int GCD(int a,int b)
{
  int r, tmp;
   /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,ans=0;
  cin>>n;
  vector<string> v(n);
  rep(i,n) cin>>v[i];
  
  vector<map<char,int>> w(n,map<char,int>());
  rep(i,n){
    rep(j,v[i].size()){
      w[i][v[i][j]]++;
    }
  }
  
  map<char,int> mp;
  rep(i,26){
    mp['a'+i]=100;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<26;j++){
      if(mp['a'+j]>=w[i]['a'+j]){
        mp['a'+j]=w[i]['a'+j];
      }
    }
  }
  for(auto c:mp){
    if(c.second==100){
      mp[c.first]=0;
    }
  }
  for(auto c:mp){
    rep(i,c.second){
      cout<<c.first;
    }
  }
  cout<<endl;
}
///////////////////////////




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
stack<char> S;
char str[100000+5];
//一道大水题，统计有多少颜色不同的段减1就好了。复杂度O(n)
int main()
{
	scanf("%s",str);
	S.push(str[0]);
	for(int i = 1; i < strlen(str); i++ )
	{
		if(S.top()!=str[i])
			S.push(str[i]); 		
	}
	printf("%d\n",S.size() - 1);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int X, Y;
    cin >> X >> Y;

    bool flag = true;
    if (Y & 1)
        flag = false;
    if (!(2 * X <= Y && Y <= 4 * X))
        flag = false;
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3648
comands = input().split()
stack = []
for command in comands:
    if command == "+":
        stack = stack[:-2] + [stack[-1] + stack[-2]]
    elif command == "-":
        stack = stack[:-2] + [stack[-2] - stack[-1]]
    elif command == "*":
        stack = stack[:-2] + [stack[-1] * stack[-2]]
    else:
        stack.append(int(command))
assert len(stack) == 1
print(stack[0])



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

void Main()
{
    long a, b,c, d;
    cin >> a >> b >> c >> d;
    long ans = -1e19;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int MAX = 0, ans = 0;
    rep(i, 0, n){
        int a, b;
        cin >> a >> b;
        if(MAX < a){
            MAX = a;
            ans = a + b;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}
int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  
  bool isChained = false;
  int tmp = 0;
  int ans = 0;
  rep(i,n){
    if(a[i] == i+1){
      tmp++;
    }else {
      ans += (tmp - tmp / 2);
      tmp = 0;
    }
  }
  if(tmp != 0){
    ans += (tmp - tmp / 2);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String colorNumber = "Three";
    for(int i = 0; i<N; i++){
      String str = sc.next();
      if(str.equals("Y")){
        colorNumber = "Four";
        break;
      }
    }
  System.out.println(colorNumber);
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main(int argc, char *argv[]){
        long a,b,k;
        int i,f = 0;
        scanf("%ld\n", &k);
        scanf("%ld %ld", &a, &b);
        for(i = a; i <= b; i++){
                if(i % k == 0){
                        f = 1;
                }
        }
        if(f){
                printf("OK\n");
        }else{
                printf("NG\n");
        }
        return 0;
}

Measured memory_bytes: 1620
n = int(input())
h = [int(i) for i in input().split()]
flag = 'Yes'
for i in range(1, n):
    if h[i] == h[i-1]:
        pass
    elif h[i] > h[i-1]:
        h[i] -= 1
    else:
        flag = 'No'
        break
print(flag)

Measured memory_bytes: 14396
#include <iostream>

using namespace std;

int c[5][5],a[5];
bool test;

int main()
{
    for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)cin>>c[i][j];
    for(a[1]=0;a[1]<=100;a[1]++)
      for(a[2]=0;a[2]<=100;a[2]++)
        for(a[3]=0;a[3]<=100;a[3]++){
          test=true;
          for(int i=1;i<=3;i++){
            if(!(c[1][i]-a[1]==c[2][i]-a[2]&&c[2][i]-a[2]==c[3][i]-a[3]))
              test=false;
          }
          if(test){
            cout<<"Yes";
            return 0;
          }
        }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;

using namespace std;

int cond(int x, int y, int z){
        return x*x + y*y + z*z + x*y + y*z + z*x;
}

int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        int n; cin >> n;
        int max = sqrt(n) + 1;
        vector<ll> ans(100000,0);

        rep2(x,1,max){
                rep2(y,1,max){
                        int z = 1;
                        while(1){
                                if(cond(x,y,z) > n) break;
                                else {
                                        ans[cond(x,y,z)]++;
                                        z++;
                                }
                        }
                }
        }

        rep2(i,1,n+1) cout << ans[i] << "\n";
        
        return 0;
}


Measured memory_bytes: 3916
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;

int main() {
    map<ll, ll>m;
    int n;
    cin>>n;
    ll a[n];
    for(int i=0; i<n; i++){cin>>a[i], m[a[i]]++;}
    ll ans=0;
    for(auto x=m.begin(); x!=m.end(); x++){
        ll y=(*x).S;
        ans+=(y*(y-1))/2;
    }
    for(int i=0; i<n; i++){
       ll x=m[a[i]];
       cout<<ans-(x*(x-1))/2+((x-1)*(x-2))/2<<"\n";
    }
}



Measured memory_bytes: 11008
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <queue>

using namespace std;
int a[100100];
int main()
{
    int n,l;
    scanf ("%d%d",&n,&l);
    for (int i=0;i<n;i++)
    {
        scanf ("%d",&a[i]);
    }
    int flag=-1;
    for (int i=0;i<n-1;i++)
    {
        if (a[i]+a[i+1]>=l) {flag=i;break;}
    }
    if (flag!=-1)
    {
        printf ("Possible\n");
        for (int i=0;i<flag;i++)
        {
            printf ("%d\n",i+1);
        }
        for (int i=n-1;i>flag+1;i--)
        {
            printf ("%d\n",i);
        }
        printf ("%d\n",flag+1);
    }
    else
    {
        printf ("Impossible\n");
    }
    return 0;
}


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

using namespace std;

void dfs(vector< vector<int> > &g, vector<int> &dist, int v, int d=0, int p=-1) {
    dist[v] = d;
    for(auto u: g[v]) {
        if(u == p) continue;
        dfs(g, dist, u, d+1, v);
    }
    return;
}

int main(void) {
    int N, u, v;
    cin >> N >> u >> v;
    --u; --v;
    vector< vector<int> > g(N);
    for(int i=0; i<N-1; i++) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        g[A].push_back(B);
        g[B].push_back(A);
    }

    vector<int> distT(N), distA(N);
    dfs(g, distT, u);
    dfs(g, distA, v);

    int ans = 0;
    for(int i=0; i<N; i++) {
        if(distT[i] <= distA[i]) ans = max(ans, distA[i]-1);
    }

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


Measured memory_bytes: 12928
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 2e5 + 5;
using ll = long long;
int n, a[maxn];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		scanf("%d", a + i);
		a[i] -= i + 1;
	}
	sort(a, a + n);
	ll ans = 0;
	for (int i = 0; i < n; i ++)
		ans += abs(a[i] - a[n / 2]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

//0-indexed
class BIT{
public:
  int N;
  vector<ll> data;
  BIT(){}
  BIT(int n):N(n),data(n){}

  ll sum(int l,int r){//[l,r)
    return sum(r)-sum(l);
  }

  void add(int p,ll x){
    p++;
    while(p<=N){
      data[p-1]+=x;
      p+=p&(-p);
    }
  }

private:
  ll sum(int r){
      ll s=0;
      while(r>0){
          s+=data[r-1];
          r-=r&(-r);
      }
      return s;
  }
};


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

  int N,Q;
  cin>>N>>Q;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  BIT fw(N);
  rep(i,N) fw.add(i,A[i]);

  rep(q,Q){
      int T;
      cin>>T;
      if(T==0){
          int p;ll x;
          cin>>p>>x;
          fw.add(p,x);
      }else{
          int l,r;
          cin>>l>>r;
          cout<<fw.sum(l,r)<<"\n";
      }
  }

  return 0;
}


Measured memory_bytes: 12172
#include<stdio.h>
#include <string.h>
int main(void)
{
  char S[1000],T[1000];
  int i,n,s,t,check=0,ans=0;
  
  scanf("%s %s",S,T);
	s = strlen(S);
	t = strlen(T);

  for(n=0;n<s+1-t;n++)
  {
    for(i=0;i<t;i++)
    {
      if(S[n+i]==T[i]){check++;}
    }
    if(check>ans){
      ans = check;
    }
    check = 0;
  }
  
  printf("%d",t-ans);
  return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

string s;

signed main()
{
	init();
	solve();
}

void init()
{
	cin >> s;
}

void solve()
{
	bool f = true;
	int st = 0, go = 0;
	rep(i, s.length()) {
		if (f && s[i] == 'A') {
			f = false;
			st = i;
		}
		if (s[i] == 'Z') go = i;
	}
	cout << go-st+1 << endl;
}


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


using namespace std;

typedef long long ll;

const ll INF = (ll) (1e18+5);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll N, W; cin >> N >> W;
    vector <ll> weight, value;
    for (ll i = 0; i < N; ++i){
        ll w, v; cin >> w >> v;
        weight.push_back(w); value.push_back(v);
    }
    ll sum = 0;
    for(ll x : value){
        sum += x;
    }
    //dp table needs only to be as long as the sum of the values of all items combined
    vector <ll> dp(sum + 1, INF);
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with value exactly i
    for (ll item = 0; item < N; ++item){
        for (ll excess_value = sum - value[item]; excess_value >= 0; --excess_value){
            dp[value[item] + excess_value] = min(dp[value[item] + excess_value], dp[excess_value] + weight[item]);
        }
    }
    ll ans = 0;
    for (ll i = 0; i <= sum; ++i){
        if (dp[i] <= W){
            ans = max(ans, i);
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
    #include<valarray>
     
    using namespace std;
    
    int n;
    set<int> s;
	#define MAX 402
	char ans[MAX];

    inline int query(){
		int red=0;
		int b=0;
		for(int i=1;i<=2*n;i++){
			if(ans[i]=='R'){
				red++;
			}
			if(ans[i]=='B'){
				b++;
			}
		}
		if(red==n){
			for(int i=1;i<=2*n;i++){
				if(ans[i]!='R'){
					ans[i]='B';
				}
			}
		}
		if(b==n){
			for(int i=1;i<=2*n;i++){
				if(ans[i]!='B'){
					ans[i]='R';
				}
			}
		}
		if(red==n||b==n){
			cout<<"! ";
	for(int i=1;i<=2*n;i++){
		cout<<ans[i];
	}
	cout<<endl;
	exit(0);
		}
		cout<<"?";
		for(int el:s){
			cout<<" "<<el;
		}
		cout<<endl;
		string ans;
		cin>>ans;
		return ans[0];
	} 
	char ok(int x){
		s.clear();
		for(int i=x;i<x+n;i++){
			s.insert(i);
		}
		return query();
	}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		s.insert(i);
	}
	char cur=query();
	int mint=1;
	int maxt=n+1;
	while(mint+1<maxt){
		int mid=(mint+maxt)/2;
		if(ok(mid)==cur){
			mint=mid+1;
		}
		else{
			maxt=mid;
		}
	}
	if(ok(mint)!=cur){
		maxt=mint;
	}
	else{
		mint=maxt;
	}
	for(int i=mint;i<=n+1;i++){
		char go=ok(i);
		if(cur!=go){
			ans[i-1]=cur;
			ans[i+n-1]=go;
			s.erase(i+n-1);
			for(int j=i-2;j>=1;j--){
				s.insert(j);
				ans[j]=query();
				s.erase(j);
			}
			for(int j=i+n;j<=2*n;j++){
				s.insert(j);
				ans[j]=query();
				s.erase(j);
			}
			s.insert(i+n-1);
			s.insert(i-1);
			for(int j=i;j<i+n-1;j++){
				s.erase(j);
				ans[j]=query();
				if(ans[j]=='R'){
					ans[j]='B';
				}
				else{
					ans[j]='R';
				}
				s.insert(j);
			}
			break;
		}
		continue;
	}
	cout<<"! ";
	for(int i=1;i<=2*n;i++){
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=200010;
const int inf=2147483647;
const int mod=924844033,gn=5;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
void upd(int&x,int y){x+=y;if(x>=mod)x-=mod;}
void cmin(int&x,int y){x=min(x,y);}
void cmax(int&x,int y){x=max(x,y);}
int n,sz[Maxn];
struct Edge{int y,next;}e[Maxn<<1];
int last[Maxn],len=0;
void ins(int x,int y)
{
	int t=++len;
	e[t].y=y;e[t].next=last[x];last[x]=t;
}
int Pow(int x,LL y)
{
    if(!y)return 1;
    int t=Pow(x,y>>1),re=(LL)t*t%mod;
    if(y&1)re=(LL)re*x%mod;
    return re;
}
int fac[Maxn],fin[Maxn];
void pre()
{
    fac[0]=1;for(int i=1;i<=n;i++)fac[i]=(LL)fac[i-1]*i%mod;
    fin[n]=Pow(fac[n],mod-2);for(int i=n-1;i>=0;i--)fin[i]=(LL)fin[i+1]*(i+1)%mod;
}
int C(int n,int m)
{
    if(n<m)return 0;
    return(LL)fac[n]*fin[m]%mod*fin[n-m]%mod;
}
int cnt[Maxn];
void dfs(int x,int ff)
{
	sz[x]=1;
	for(int i=last[x];i;i=e[i].next)
	{
		int y=e[i].y;
		if(y==ff)continue;
		dfs(y,x);
		sz[x]+=sz[y];cnt[sz[y]]++;
	}
	cnt[n-sz[x]]++;
}
int rev[(1<<19)+10],A[(1<<19)+10],B[(1<<19)+10];
void NTT(int *a,int n,int o)
{
	for(int i=0;i<n;i++)if(i<rev[i])swap(a[i],a[rev[i]]);
	for(int i=1;i<n;i<<=1)
	{
		int wn;
		if(o==1)wn=Pow(gn,(mod-1)/(i<<1));
		else wn=Pow(gn,mod-1-(mod-1)/(i<<1));
		for(int j=0;j<n;j+=(i<<1))
		{
			int w=1;
			for(int k=0;k<i;k++)
			{
				int t=(LL)a[i+j+k]*w%mod;w=(LL)w*wn%mod;
				a[i+j+k]=(a[j+k]-t+mod)%mod;
				a[j+k]=(a[j+k]+t)%mod;
			}
		}
	}
	if(o==-1)
	{
		int inv=Pow(n,mod-2);
		for(int i=0;i<n;i++)a[i]=(LL)a[i]*inv%mod;
	}
}
int main()
{
    n=read();pre();
    for(int i=1;i<n;i++)
    {
    	int x=read(),y=read();
    	ins(x,y),ins(y,x);
	}
	dfs(1,0);
	int N=1;while(N<=((n+1)<<1))N<<=1;
	rev[0]=0;for(int i=1;i<N;i++)rev[i]=((rev[i>>1]>>1)|((i&1)*(N>>1)));
	A[0]=0;for(int i=1;i<=n;i++)A[i]=(LL)cnt[i]*fac[i]%mod;
	for(int i=0;i<=n;i++)B[n-i]=fin[i];
//	for(int i=0;i<=n;i++)printf("%d ",A[i]);puts("");
//	for(int i=0;i<=n;i++)printf("%d ",B[i]);puts("");
	NTT(A,N,1),NTT(B,N,1);
	for(int i=0;i<N;i++)A[i]=(LL)A[i]*B[i]%mod;
	NTT(A,N,-1);
//	for(int i=0;i<=2*n;i++)printf("%d ",A[i]);puts("");
	for(int k=1;k<=n;k++)
	{
		int ans=(LL)n*C(n,k)%mod;
		upd(ans,mod-(LL)A[n+k]*fin[k]%mod);
//		for(int i=k;i<=n;i++)upd(ans,mod-(LL)cnt[i]*C(i,k)%mod);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 23296
#include <algorithm>
#include <iostream>

using namespace std;

const int A = 100;

bool good[1 + A];

int main() {
	int x, n; cin >> x >> n;
	fill(good, good + 1 + A, true);
	while (n--) {
		int a; cin >> a;
		good[a] = false;
	}
	for (int d = 0; ; d++) {
		if (x - d < 0 || good[x - d]) {
			cout << x - d << '\n';
			return 0;
		}
		if (x + d > A || good[x + d]) {
			cout << x + d << '\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int[] P = new int[N];
		Arrays.setAll(P, $ -> Integer.parseInt(sc.get()));

		int[] sorted = Arrays.copyOf(P, N);
		Arrays.sort(sorted);

		int difference = 0;
		for (int i = 0; i < N; i++) {
			if (P[i] != sorted[i]) difference += 1;
		}

		System.out.println(difference <= 2 ? "YES" : "NO");
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 27088
#include<iostream>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
  int z;
  z=x-1;
  if(z>0)
 { 
  for(int i=-z;i<=z;i++)
  {
  	cout<<(y+i)<<" ";
  }
 }
    else
    cout<<y;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int[] rate = new int[13];
            for(var i=0;i<N;i++){
                rate[a[i]/400]++;
            }
            int sum=0;
            for(var i=0;i<=7;i++){
                if(rate[i]>0)sum++;
            }
            int sum_min = sum;
            int sum_max = sum;
            for(var i=8;i<13;i++){
                sum_max += rate[i];
            }
            if(sum<sum_max&&sum==0){
                sum_min = sum+1;
            }
            Console.WriteLine("{0} {1}",sum_min,sum_max);
        }  
    } 
}

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

ll dp [1000][1000];
int h , w;
char a [1000][1000];

//prototypes
ll go (int , int);

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

    cin >> h >> w;
    for (int i=0; i<h; ++i)
        for (int j=0; j<w; ++j)
            dp [i][j] = -1;

    for (int i=0; i<h; ++i)
        for (int j=0; j<w; ++j)
            cin >> a[i][j];

    cout << go (0 , 0);
}

ll go (int i , int j)
{
    if (i==h-1 && j==w-1)
        return 1;

    if (dp [i][j] != -1)
        return dp [i][j];

    ll ans = 0;
    if (i<h-1 && a[i+1][j] == '.')
        ans += go (i+1 , j);
    if (j<w-1 && a[i][j+1] == '.')
        ans += go (i , j+1);
    ans %= 1000000007;
    return dp [i][j] = ans;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define nn 200008
int ai[nn];int n;
int m,v,p;
map<int,int> able;
int ans=0;int sum[nn];
signed main(){
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++) scanf("%lld",&ai[i]);
	sort(ai+1,ai+n+1);for(int i=1;i<=n;i++) sum[i]=sum[i-1]+ai[i];
	
	v=n-v;int j=1;
	for(int i=1;i<=n;i++) if(!able[ai[i]]){
		int l=i,r=n,res=i;
		while(l<=r){
			int mid=(l+r)/2;
			if(sum[mid]-sum[i]-ai[i]*(mid-i)<=v*m and ai[mid]-ai[i]<=m)
				res=mid,l=mid+1;
			else r=mid-1;
		}
		if(res>=n-p+1) able[ai[i]]=1;
	}
	
	
	for(int i=1;i<=n;i++) if(able[ai[i]]) ans++;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  map<string,ll> cnt;
  for(ll i=1;i<=k;i++) {
    for(ll j=0;j<s.size()-i+1;j++) {
      cnt[s.substr(j,i)]++;
    }
  }
  for(auto p:cnt) {
    if(k==1) {
      cout << p.first << endl;
      return 0;
    }
    else {
      k--;
    }
  }
}

Measured memory_bytes: 1920
s = input()

# check 2
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1,i+2)
        exit()

# check 3
for i in range(len(s)-2):
    if s[i] == s[i+2]:
        print(i+1,i+3)
        exit()

print("-1 -1")

Measured memory_bytes: 39408
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

int main()
{
    long long int n,w;
    cin>>n>>w;
    long long int a[n],v[n],i,j,k,l;
    for(i=0;i<n;i++) {
        cin>>a[i]>>v[i];
    }
    long long int h[n+1][w+1]={0};
    memset(h, 0, sizeof(h));
    for(i=1;i<=n;i++) {
        for(j=1;j<=w;j++) {
            //cout<<a[i-1]<<" "<<j<<endl;
            if(a[i-1]>j) h[i][j]=h[i-1][j];
            else {
                h[i][j]=max(h[i-1][j], v[i-1]+h[i-1][j-a[i-1]]);
            }
            //cout<<h[i][j]<<endl;
        }
    }
    cout<<h[n][w]<<endl;

    return 0;
}


Measured memory_bytes: 82552
#include <stdio.h>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair

const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const string ds = "NESW";

int main() {
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0) return 0;
        map<pair<int, int>, int> hs;
        rep (i, n) {
            int x, y;
            scanf("%d%d", &x, &y);
            hs[mp(x, y)] = 1;
        }
        int m;
        scanf("%d", &m);
        int cnt = 0;
        int cx = 10, cy = 10;
        if (hs[mp(cx, cy)] == 1) {
            hs[mp(cx, cy)] = 0;
            cnt++;
        }
        rep (i, m) {
            char c;
            int a;
            scanf(" %c%d", &c, &a);
            int dir = ds.find(c);
            rep (_, a) {
                cx += dx[dir];
                cy += dy[dir];
                if (hs[mp(cx, cy)] == 1) {
                    hs[mp(cx, cy)] = 0;
                    cnt++;
                }
            }
        }
        puts(cnt == n ? "Yes" : "No");
    }
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1, 0);
  for (int i = 0; i < n - 1; i++) {
    int tem;
    cin >> tem;
    a.at(tem)++;
  }
  for (int i = 1; i < n + 1; i++) {
    cout << a.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,m,c;
cin >> n >> m >> c;
int b[m];
REP(i,m) cin >> b[i];
int a[m];
int ans=0;
int temp;
REP(i,n) {
  temp=c;
  REP(j,m) {
    cin >> a[j];
    temp+=a[j]*b[j];
  }
  if(temp>0) ans++;
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#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;
int main(){
	int N,V[100],C[100];
	scan(N);
	int ans=0;
	rep(i,N){
		scan(V[i]);
	}
	rep(i,N){
		scan(C[i]);
		if(V[i]>C[i]) ans+=V[i]-C[i];
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define maxn 100010
#define mod 1000000007
using namespace std;
char s[maxn];
int x[30];
int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++)
		x[s[i] - 'a' + 1]++;
	int res = 1;
	for (int i = 1; i <= 26; i++)
		res = res * ((ll)x[i] + 1) % mod;
	res = (res - 1 + mod) % mod;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
import itertools
import math
from functools import reduce

k=int(input())
l=list(range(1,k+1))
ans=0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in itertools.product(l,repeat=3):
    ans+=(gcd(i[0],i[1],i[2]))
print(ans)

Measured memory_bytes: 69152
import sys

r,c = map(int,raw_input().split())
table_list = [[0 for i in range(c)]for j in range(r)]
for k in range(r):
	Sum = 0
	table_list[k] = map(int,raw_input().split())
	for l in table_list[k]:
		Sum += l
	table_list[k].append(Sum)
end_list = []
for m in range(c):
	Sum = 0
	for n in range(r):
		Sum += table_list[n][m]
	end_list.append(Sum)
Sum = 0
for o in end_list:
	Sum += o
end_list.append(Sum)
table_list.append(end_list)
for p in range(r+1):
	for q in range(c+1):
			if q==c:
				print '%d' %table_list[p][q]
			else :
				sys.stdout.write(str(table_list[p][q]))
				sys.stdout.write(' ')

Measured memory_bytes: 6444
#include <iostream>

using namespace std;

int main(void){

  char r[8][8];

    for( int i = 0 ; i < 8 ; i++ ){
      for( int j = 0 ; j < 8 ; j++ ){
	cin >> r[i][j];
      }
    }

       cout << "90" << endl;
    for( int i = 0 ; i < 8 ; i++ ){
      for( int j = 7 ; j >= 0 ; j-- ){
	cout << r[j][i];
      }
      cout << endl;
    }

    cout << "180" << endl;
    for( int i = 7 ; i >= 0 ; i-- ){
      for( int j = 7 ; j >= 0 ; j-- ){
	cout << r[i][j];
      }
      cout << endl;
    }
 cout << "270" << endl;
    for( int i = 7 ; i >= 0 ; i-- ){
      for( int j = 0 ; j < 8 ; j++ ){
	cout << r[j][i];
      }
      cout << endl;
    }

  return 0;
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
const ll mod = 1e9 + 7;
int n;
ll ans;
int main() {
	cin >> n;
	for (ll i = 1; i <= n; i++) ans += i * (n - i + 1);
	for (int i = 1; i < n; i++) {
		ll u, v;
		cin >> u >> v;
		if (u > v) swap(u, v);
		ans -= u * (n - v + 1);
	}
	cout << ans;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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 INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k,q; cin>>n>>k>>q;
  vi cnt(n);
  vll a(q); rep(i,q){
    int a; cin>>a; a--;
    cnt[a]++;
  }
  
  rep(i,n){
    if(k-(q-cnt[i])>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  for (int l = S.length() - 2; l > 0; l -= 2) {
    bool ok = true;
    for (int i = 0; i < l / 2; i++) {
      if (S[i] != S[i + l / 2]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << l;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b);
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    char w;
    map<char, int> mci;
    map<char, int>::iterator it;
    while(cin >> w){ mci[w]++; }
    for(it = mci.begin(); it != mci.end(); it++){
        if(it->second % 2){
            cout << "No" << endl;
            return 0;
        }else{
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import sys
sys.setrecursionlimit(20000)


def dfs(x,y,fruit):
  #visited.append((x,y))
  visited[y][x] = 1
  for v in vec:
    nx = x + v[0]
    ny = y + v[1]
    if nx in xrange(w) and ny in xrange(h):
      if visited[ny][nx]==0 and matrix[ny][nx] == fruit:
        dfs(nx,ny,fruit)
  return 0

matrix = []
vec = [[1,0],[-1,0],[0,1],[0,-1]]
visited =[]
h = 0
w = 0

while True:
  h,w = map(int,raw_input().split())
  if h == 0 and w == 0:
    break
#  print h,w
  matrix = []
  visited = []
  ans = 0
  for i in xrange(h):
    s = raw_input().rstrip()
    matrix.append(list(s))
    visited.append([0]*w)
  for i in xrange(h):
    for j in xrange(w):
      #if not (j,i) in visited:
      if visited[i][j] == 0:
        dfs(j,i,matrix[i][j])
        ans+=1
  print ans

Measured memory_bytes: 14848
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, m;
std::vector<long> edge[100005];
long depth[100005];
long lowlink[100005];

void dfs(long par, long vis){
    for(int i = 0; i < edge[vis].size(); i++){
        long nx = edge[vis][i];
        if(par == nx){
            continue;
        }else if(depth[nx] == LINF){
            depth[nx] = lowlink[nx] = depth[vis] + 1;
            dfs(vis, nx);
            lowlink[vis] = std::min(lowlink[nx], lowlink[vis]);
        }else{
            lowlink[vis] = std::min(depth[nx], lowlink[vis]);
        }
    }
}

int main(){
    scanf("%ld%ld", &n, &m);
    for(int i = 0; i < m; i++){
        long a, b;
        scanf("%ld%ld", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for(int i = 0; i < n; i++){
        depth[i] = lowlink[i] = LINF;
    }
    depth[0] = lowlink[0] = 0;
    dfs(0, 0);
    /*
    for(int i = 0; i < n; i++){
        printf("%ld  %ld %ld\n", i, depth[i], lowlink[i]);
    }
    //*/
    long cnt = 0;
    for(long i = 0; i < edge[0].size(); i++){
        long nx = edge[0][i];
        if(depth[nx] == 1){
            cnt++;
        }
    }
    if(cnt > 1){
        printf("0\n");
    }
    for(long vis = 1; vis < n; vis++){
        for(int i = 0; i < edge[vis].size(); i++){
            long nx = edge[vis][i];
            if(depth[nx] == 1 + depth[vis] && depth[vis] <= lowlink[nx]){
                printf("%ld\n", vis);
                break;
            }
        }
    }
}



Measured memory_bytes: 7568
N,K = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0 for i in range(200001)]
ans=0
count=0
num = [0 for i in range(200001)]
for i in range(N):
    b[a[i]] += 1

for i in range(200001):
    if(b[i] >= 1):
        count+=1
        num[b[i]]+=1

for i in range(200000):
    if(count-K) > 0:
        ans += min(num[i+1],count-K)*(i+1)
        count -= num[i+1]

print(ans)

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

int main(){
	string s;
	cin>>s;
	int fi,la;
	rep(i,s.size()){
		if(s[i]=='A'){fi=i;break;}
	}
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='Z'){
			la=i;
			break;
		}
	}
	puts(la-fi+1);
}


Measured memory_bytes: 640
S = input()
LIST = [int(_) for _ in S]
pra_fla = []
for _ in range(2**3):
    lis = ['-' for fl in range(3)]
    for x in range(3):
        if (_ >> x)&1:
            lis[x] = '+'
    pra_fla.append(lis)

ans_lis = []
for x in pra_fla:
    pre = []
    x.append('')
    for y in range(4):
        pre.append(LIST[y])
        pre.append(x[y])
    ans_lis.append(pre)
flag = 0 #0:null #1:+ #2:-
for x in ans_lis:
    ans = 0
    ans_str = ''
    for y in x:
        #print(y)
        ans_str += str(y) 
        if y == '+':
            flag = 1
        elif y == '-':
            flag = 2
        elif y == '':
            flag = 0
        else:
            if flag == 1 or flag == 0:
                ans += y
            elif flag == 2:
                ans -= y
            flag = 0
    if ans == 7:
        break
ans_str += '=7'
print(ans_str)

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


int main(){
	int n;
    vector<int> a(100001), b(100001), c(100001);
    int ans=100, p=0;

    cin >> n;

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

    for(int i=0;i<=n;i++){
        b[i] = abs(a[i+1] - a[i]);
        if(i!=n) c[i] = abs(a[i+2] - a[i]);
    }

    for(int i=0;i<=n;i++){
        p = p + b[i];
    }

    for(int i=1;i<=n;i++){
        ans = p - b[i-1] - b[i] + c[i-1];
        cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 2432
#include "stdio.h"

int main(){
	char str[21];
	int i=0;
	int flag=0;

	fgets(str,sizeof(str),stdin);
	
	for(i=20,flag=0;i>=0;i--){
		if(str[i]=='\0'){
			flag=1;
		}else if(flag==1){
			printf("%c",str[i]);
		}
		//printf("%c",str[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 524
def solve(m1, d1, m2, d2):
    if m1 == m2:
        return 0
    else:
        return 1


def main():
    m1, d1 = map(int, input().split())
    m2, d2 = map(int, input().split())
    res = solve(m1, d1, m2, d2)
    print(res)


def test():
    assert solve(11, 16, 11, 17) == 0
    assert solve(11, 30, 12, 1) == 1


if __name__ == "__main__":
    test()
    main()


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

int main() {
	ios_base::sync_with_stdio( false );

	int n, q;
	cin >> n >> q;

	vector<list<int>> l( n );
	while( q-- > 0 ) {
		int cmd, t, x;
		cin >> cmd >> t;

		if( cmd == 0 ) {
			cin >> x;
			l[t].push_back( x );
		}
		else if( cmd == 1 ) {
			for( auto i = l[t].begin(); i != l[t].end(); ++i ) {
				cout << *i;

				if( next( i ) != l[t].end() ) {
					cout << ' ';
				}
			}

			cout << '\n';
		}
		else if( cmd == 2 ) {
			cin >> x;
			l[x].splice( l[x].end(), l[t] );
		}
	}

	return 0;
}



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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}



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



string s;cin>>s;
ll count=0;

vector<ll>v1,v2;

char cur=s[0];
if(cur!='<')v1.pb(0);
for(char x:s)
{
if(x==cur)
{
  count++;
}
else 
{
  if(cur=='<')v1.pb(count);
  else v2.pb(count);
  count=1;
  cur=x;
}

}

ll ans=0;

 if(cur=='<')v1.pb(count);
  else v2.pb(count);



  if(v1.size()<v2.size())v1.pb(0LL);
  else if(v1.size()>v2.size())v2.pb(0LL);

  //  for(auto x:v1)cout<<x<<" ";

for(int i=0;i<v1.size();i++)
{
  ll a=min(v1[i],v2[i]);
  ll b=max(v1[i],v2[i]);

  ll temp=a*(a-1)+b*(b+1);
  ans+=temp/2;
}

cout<<ans<<"\n";


return 0;

}


Measured memory_bytes: 3608
import copy
s = str(input())
N = len(s)
num = [0,0,0,0,0,0]
all = [76923 for i in range(13)]
all[0] = 76924

num1 = [1,1,1,1,1,1,1,1,1,1,0,0,0] # 10**(6k)
num2 = [1,1,1,0,1,1,0,1,1,0,1,1,1] # 10**(6k+1)
num3 = [1,1,1,1,0,1,1,1,0,1,1,1,0] # 10**(6k+2)
num4 = [1,0,0,0,1,1,1,1,1,1,1,1,1] # 10**(6k+3)
num5 = [1,1,1,1,0,1,1,0,1,1,0,1,1] # 10**(6k+4)
num6 = [1,0,1,1,1,0,1,1,1,0,1,1,1] # 10**(6k+5)

tgt = copy.deepcopy(all)

md = 0
for i in range(N):
    t = s[N-i-1]
    if t == '?':
        num[i%6] += 1
    else:
        md += ((10**(i%6)) * int(t))%13
allnum = min(num)
for i in range(6):
    num[i] -= allnum
#print(num)

if allnum == 0:
    tgt = [0,0,0,0,0,0,0,0,0,0,0,0,0]
    tgt[md%13] = 1
else:
    for i in range(allnum-1):
        tgt2 = [0,0,0,0,0,0,0,0,0,0,0,0,0]
        for j in range(13):
            for k in range(13):
                tgt2[(j+k)%13] += all[j]*tgt[k]
        for j in range(13):
            tgt2[j] = tgt2[j]%(10**9+7)
        tgt = copy.deepcopy(tgt2)

for i in range(num[0]):
    tgt2 = [0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(13):
        for k in range(13):
            tgt2[(j+k)%13] += tgt[j]*num1[k]
    for j in range(13):
        tgt2[j] = tgt2[j]%(10**9+7)
    tgt = copy.deepcopy(tgt2)
for i in range(num[1]):
    tgt2 = [0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(13):
        for k in range(13):
            tgt2[(j+k)%13] += tgt[j]*num2[k]
    for j in range(13):
        tgt2[j] = tgt2[j]%(10**9+7)
    tgt = copy.deepcopy(tgt2)
for i in range(num[2]):
    tgt2 = [0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(13):
        for k in range(13):
            tgt2[(j+k)%13] += tgt[j]*num3[k]
    for j in range(13):
        tgt2[j] = tgt2[j]%(10**9+7)
    tgt = copy.deepcopy(tgt2)
for i in range(num[3]):
    tgt2 = [0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(13):
        for k in range(13):
            tgt2[(j+k)%13] += tgt[j]*num4[k]
    for j in range(13):
        tgt2[j] = tgt2[j]%(10**9+7)
    tgt = copy.deepcopy(tgt2)
for i in range(num[4]):
    tgt2 = [0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(13):
        for k in range(13):
            tgt2[(j+k)%13] += tgt[j]*num5[k]
    for j in range(13):
        tgt2[j] = tgt2[j]%(10**9+7)
    tgt = copy.deepcopy(tgt2)
for i in range(num[5]):
    tgt2 = [0,0,0,0,0,0,0,0,0,0,0,0,0]
    for j in range(13):
        for k in range(13):
            tgt2[(j+k)%13] += tgt[j]*num6[k]
    for j in range(13):
        tgt2[j] = tgt2[j]%(10**9+7)
    tgt = copy.deepcopy(tgt2)
#print(tgt)
if allnum == 0:
    print(tgt[5])
else:
    print(tgt[(5-md)%13])


Measured memory_bytes: 54104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String S=scan.nextLine();
		String a="ABC";
		String b="ARC";
		if(S.equals(a))
		{
			System.out.println(b);
		}
		else
		{
			System.out.println(a);
		}
	}
}


Measured memory_bytes: 35572
import sys
input = sys.stdin.readline
from collections import *

s = input()[:-1]
l = []
cnt = 1
    
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        l.append((s[i], cnt))
        cnt = 1
    else:
        cnt += 1
    
l.append((s[-1], cnt))
ans = 0

for si, c in l:
    if si=='R':
        ans = max(ans, c)

print(ans)

Measured memory_bytes: 64720