akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
  def __init__(self,n):
    self.par=[i for i in range(n)]
    self.size=[1]*n
    self.rank=[0]*n
  
  def find(self,x):
    if self.par[x]==x:
      return x
    else:
      self.par[x]=self.find(self.par[x])
      return self.par[x]
     
  def union(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x!=y:
      if self.rank[x]<self.rank[y]:
        x,y=y,x
      if self.rank[x]==self.rank[y]:
        self.rank[x]+=1
      self.par[y]=x
      self.size[x]+=self.size[y]
  
  def same(self,x,y):
    return self.find(x)==self.find(y)

n,m,k=map(int,input().split())
uf=UnionFind(n)
rmv=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  rmv[a-1].append(b-1)
  rmv[b-1].append(a-1)
  uf.union(a-1,b-1)
for i in range(k):
  c,d=map(int,input().split())
  if uf.find(c-1)==uf.find(d-1):
    rmv[c-1].append(d-1)
    rmv[d-1].append(c-1)
ans=""
for i in range(n):
  uf.find(i)
  ans+=str(uf.size[uf.par[i]]-len(rmv[i])-1) + " "
print(ans)

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

void solve() {
	int n;
	cin >> n;
	vector<int> a(n + 2);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}	
	map<int, int> m;
	int s = 0;
	for (int i = 0; i <= n; i++) {
		int t = abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i + 2]);
		m[i + 1] = t;
		s += abs(a[i] - a[i + 1]);
	}
	for (int i = 1; i <= n; i++) {
		int t = s - m[i] + abs(a[i - 1] - a[i + 1]);
		cout << t << '\n';
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 8332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

int main()
{
	int ans = 0;

	rep(i,10)
	{
		int temp;
		cin >> temp;

		ans += temp;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1160
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(ll N) {
  ll a = N / 1000;
  ll b = (N / 100) % 10;
  ll c = (N / 10) % 10;
  ll d = (N % 10);

  bool r = (a == b && b == c) || (b == c && c == d);
  yesOrNo(r);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
 
 
def calc(H, W):
    if H % 3 == 0 or W % 3 == 0:
        return 0
    ans = min(H, W)
    h1 = H // 2
    h2 = H - h1
    for w in range(W + 1):
        a = H * w
        b = (W - w) * h1
        c = (W - w) * h2
        ans = min(ans, max(abs(a - b), abs(a - c)))
    return ans
 
 
def solve(H, W):
    return min(calc(H, W), calc(W, H))
 
 
def main():
    H, W = map(int, input().split())
    print(solve(H, W))
 
if __name__ == '__main__':
    main()

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


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



Measured memory_bytes: 4840
#include<iostream>
#include<string>
using namespace std;
char orzhjw[5];
int main(){
	for(int i=1;i<=4;i++){
	    cin>>orzhjw[i];
	    orzhjw[i]=orzhjw[i]-'0';
	}
	if(orzhjw[1]==orzhjw[2]&&orzhjw[2]==orzhjw[3]&&orzhjw[3]==orzhjw[4]){cout<<"Yes"<<endl;return 0;}
	if(orzhjw[1]==orzhjw[2]&&orzhjw[2]==orzhjw[3]){cout<<"Yes"<<endl;return 0;}
	if(orzhjw[2]==orzhjw[3]&&orzhjw[3]==orzhjw[4]){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    //#define long  long long
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll a[200005];
    ll b[200005];
    ll c[200005];
    ll m=1000000007;
    // Function to find modulo inverse of a
    ll gcdExtended(ll a, ll b, ll *x, ll *y)
    {
        // Base Case
        if (a == 0)
        {
            *x = 0, *y = 1;
            return b;
        }
 
        ll x1, y1; // To store results of recursive call
        ll gcd = gcdExtended(b%a, a, &x1, &y1);
 
 
        *x = y1 - (b/a) * x1;
        *y = x1;
 
        return gcd;
    }
      ll modInverse(ll a, ll m)
    {
        ll x, y;
        ll g = gcdExtended(a, m, &x, &y);
 
           ll res = (x%m + m) % m;
        return res;
    }
 
    int main()
    {
        fastread;
        ll n,i,j,k,l;
        cin>>n>>k;
        for(i=1;i<=n;i++)
        cin>>c[i];
        sort(c+1,c+n+1);
        if(k>=2){
        	ll temp=k-2;
        	a[temp]=1;
        	for(i=1;i+temp<=n;i++){
        		ll bash=((a[i+temp-1]%m)*((i+temp)%m))%m;
        		ll kola=modInverse(i,1000000007);
        		a[i+temp]=((bash)*(kola))%m;
			}
			for(i=temp;i<=n;i++){
				b[i]=a[i]+b[i-1];
			}
			ll sum=0;
			for(i=1;i<=n;i++){
				if(i-1-1>=k-2){
					sum=(sum+((c[i]%m)*(b[i-1-1]%m))%m)%m;
				}
				if(n-i-1>=k-2){
					sum=(sum-((c[i]%m)*(b[n-i-1]%m))%m)%m;
				}
			}
			cout<<sum;
		}
		else{
			cout<<'0';
		}
    	return 0;
    }

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  
  lint D; cin >> D;
  vi c(26); // contest 0-25
  for(lint i=0; i<26; i++) cin >> c[i];
  vvi s(D+1, vi(26)); // day 0-D
  for(lint d=1; d<=D; d++){
    for(lint j=0; j<26; j++){
      cin >> s[d][j];
    }
  }
  
  vi t(D+1); // day 0-D
  /*
  for(lint d=1; d<=D; d++){
    cin >> t[d];
    t[d]--;
  }
  */
  
  vi last(26,0);
  
  // lint ans = 0;
  
  // lint incr = 2;
  
  for(lint d=1; d<=D-1; d+=2){// 2days!!!!!
    vvi diff(26, vi(26));
    
    for(lint i=0; i<26; i++){ // if contest i (0-25)
      for(lint ii=0 ;ii<26; ii++){
        // ans += s[d][t[d]];
        lint plus = s[d][i];
    
        // last[t[d]] = d;
        lint oldlast = last[i];
        last[i] = d;
    
        lint minus = 0;
    
        for(lint j=0; j<26; j++){
          // ans -= c[j] * (d - last[j]);
          minus += c[j] * (d - last[j]);
        }
      
        // last[i] = oldlast;
        // diff[i] = plus - minus;
        
        ////////////////////
        
        // ans += s[d][t[d]];
        lint pluss = s[d+1][ii];
    
        // last[t[d]] = d;
        lint oldlastt = last[ii];
        last[ii] = d+1;
    
        lint minuss = 0;
    
        for(lint j=0; j<26; j++){
          // ans -= c[j] * (d - last[j]);
          minuss += c[j] * (d+1 - last[j]);
        }
      
        // last[i] = oldlast;
        // diff[i] = plus - minus;
        
        ////////////////////
        
        diff[i][ii] = plus + pluss - minus - minuss;
        last[i] = oldlast;
        last[ii] = oldlastt;
      }
    }
    
    vi soto (0);
    for(lint i=0; i<26; i++){
      for(lint ii=0; ii<26; ii++){
        soto.PB(diff[i][ii]);
      }
    }
    sort(ALL(soto));
    reverse(ALL(soto));
    lint t = -1;
    lint tt = -1;
    for(lint i=0; i<26; i++){
      for(lint ii=0; ii<26; ii++){
        if(diff[i][ii] == soto[0]){
          t = i;
          tt = ii;
        }
      }
    }
    cout << t+1 << endl;
    cout << tt+1 << endl;
    last[t] = d;
    last[tt] = d+1;
    
  }
  
  // 364 days so far
  // last one day
  
  vi dif(26);
  for(lint i=0; i<26; i++){
    lint plu = s[D][i];
    // lint oldlas = last[i];
    last[i] = D;
    
    lint minu = 0;
    
    for(lint j=0; j<26; j++){
    minu += c[j] * (D - last[j]);
    }
    
    dif[i] = plu - minu;
  }
  
  vi sot(0);
    for(lint i=0; i<26; i++){
      sot.PB(dif[i]);
    }
    sort(ALL(sot));
    // lint tl = -1;
    for(lint i=0; i<26; i++){
      if(dif[i] == sot[sot.size()-1]){
        // tl = i;
        cout << i+1 << endl;
        break;
      }
    }
 // cout << tl+1 << endl;
}
 
  
  
  
  

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

using namespace std;

int main( void )
{
	string buf;
	while(getline(cin, buf)) {
		buf += '.';
		string str = "", output = "";
		int len = buf.size();
		int count = 0;
		bool first = true;
		for(int i=0; i < len; ++i) {
			if(buf[i] != ' ' && buf[i] != '.' && buf[i] != ',') {
				str += buf[i];
				++count;
			}
			else {
				if(2 < count && count < 7) {
					if(first)	first = false;
					else		output += ' ';
					output += str;
				}
				count = 0;
				str = "";
			}
		}
		cout << output << endl;
	}
	return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;
using ll = int64_t;

map<ll, int> A;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || '9' < c) break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;
    gc(N);

    ll suma = 0;
    A[suma]++;

    ll ans = 0;
    REP(i, N)
    {
        ll a;
        gc(a);
        suma += a;

        ans += A[suma];

        A[suma]++;
    }

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


Measured memory_bytes: 12800
#include<stdio.h>
#define N 8
#define nfree -1
#define free 1
 
int A[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
void p();
void Queen(int i){
  int j;
  
  if(i==N){
    p();
    return;
  }
    
  for(j=0; j<N; j++){
    if(nfree==col[j]||nfree==dpos[i+j]||nfree==dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = nfree;
    Queen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = free;
  }
}
  
void p(){
    
  int i,j;
    
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(A[i][j]){
    if(row[i]!=j) return;
      }
    }
  }
    
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
int main(){
  
  int n;
  int i,j;
  int x,y;
    
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      A[i][j] = 0;
    }
  }
    
  for(j=0; j<N; j++){
    row[j]=0;
    col[j]=0;
  }
  for(j=0; j<2*N-1; j++){
    dpos[j]=0;
    dneg[j]=0;
  }
    
  scanf("%d",&n);
    
  for(i=0; i<n; i++){
    scanf("%d %d",&x,&y);
    A[x][y] = 1;
  }
    
  Queen(0);
  
  return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[7];
    Scs(s);

    int N = strlen(s);
    int d = 0;
    bool zero = N > 1;
    for( int i = N-1; i >= 1; i-- ){
        zero = zero & s[i] == '0';
        d += s[i] - '0';
    }
    d += (s[0] - '0') * (zero ? 10 : 1);

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

    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
p = [int(i) for i in input().split()]

ans = 0
for i in range(n - 1):
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1
if p[-1] == n:
    ans += 1
print(ans)


Measured memory_bytes: 13880
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int w,h,k;
inline ll solve(int w,int h,int k){
	ll ans=0;
	/*FOR(y,1,w)
		FOR(z,1,h)
			For(x,1,z) if (1ll*y*z+1ll*x*(w-y)-__gcd(x,y)-__gcd(w-y,z)-__gcd(w,z-x)<=2*k-2){
				ans++;
				printf("%d %d %d %d\n",w,y,z,x);
				if (z!=x) ans++;
			}
	return ans;*/
	ll sum=0;
	FOR(y,1,w){
		++ans;
		For(z,2,h-1){
			if (1ll*y*z+1ll*z*(w-y)-__gcd(z,y)-__gcd(w-y,z)-w<=2*k-2) ++ans;
			int l=1,r=z-1,tmp=__gcd(w-y,z),L=0,R=0,lim=2*k-2;
			while (l<=r){
				int mid=l+r>>1;
				if (1ll*y*z+1ll*(w-y)*mid-2-tmp<=lim) L=mid,l=mid+1;
					else r=mid-1;
			}
			l=1,r=z-1;
			while (l<=r){
				int mid=l+r>>1;
				if (1ll*y*z+1ll*(w-y)*mid-y-min(z-mid,w)-tmp<=lim) R=mid,l=mid+1;
					else r=mid-1;
			}
			if (R==0) break;
			sum+=R-L;
			int ret=2*L;
			For(x,L+1,R) if (1ll*y*z+1ll*(w-y)*x-tmp-__gcd(x,y)-__gcd(w,z-x)<=lim){
				ret+=2;
			}
			ans+=ret;
		}
	}
	return ans;
}

int main(){
	w=read(),h=read(),k=read();
	if (w==1||h==1) return puts("0"),0;
	printf("%lld\n",2*(solve(w,h,k)+solve(h,w,k)));
}
/*
100000 100000 100000
*/

Measured memory_bytes: 3752
#include <algorithm>
#include <bitset>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000007

using namespace std;
typedef long long ll;

mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

template <typename T> void read(T &x) {
    x = 0;
    char c = getchar();
    T sig = 1;
    for (; !isdigit(c); c = getchar())
        if (c == '-')
            sig = -1;
    for (; isdigit(c); c = getchar())
        x = (x << 3) + (x << 1) + c - '0';
    x *= sig;
}

class Solution {
public:
    void solve() {
        int n;
        read(n);
        vector<int> a(n);
        for (int i = 0; i < n; ++i)
            read(a[i]);
        vector<int> primes = {2, 3, 5, 7, 11, 13};
        for (int i = 17; i < 2000; i += 2) {
            bool ok = true;
            for (int j = 0; primes[j] * primes[j] <= i; ++j) {
                if (i % primes[j] == 0) {
                    ok = false;
                    break;
                }
            }
            if (ok)
                primes.emplace_back(i);
        }
        map<int, int> cnt;
        for (int i : a) {
            int t = i;
            for (int j = 0; primes[j] * primes[j] <= t; ++j) {
                if (t % primes[j] == 0)
                    cnt[primes[j]]++;
                while (t % primes[j] == 0)
                    t /= primes[j];
            }
            if (t != 1)
                cnt[t]++;
        }
        int hi = 0;
        for (auto p : cnt)
            hi = max(hi, p.second);
        if (hi <= 1) {
            printf("pairwise coprime");
            return;
        }
        printf(hi < n ? "setwise coprime" : "not coprime");
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    Solution solution = Solution();
    solution.solve();
}

Measured memory_bytes: 10680
main = do
  li <- getLine
  let [a,b] = map read $ words li
  let ans = compute a b
  case ans of
    Nothing -> putStrLn "IMPOSSIBLE"
    Just x -> print x

compute :: Int -> Int -> Maybe Int
compute a b
  | even d = Just m
  | True = Nothing
  where
    d = abs (a - b)
    m = (a + b) `div` 2

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

int main(){
	int R; cin >> R;
	string ans;
	if (R<1200)
	{
		ans = "ABC";
	}else if (R<2800){
		ans = "ARC";
	}else{
		ans = "AGC";
	}
	cout << ans << endl;
	return 0;
}


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

int pow10[20];

//1???n??§???????????°????????????
int getCnt(int n) {
	return n - n / 3 - n / 5 + n / 15;
}

//l???r??§???????????°????????????
int getCnt(int l, int r) {
	if (l > r) return 0;
	return getCnt(r) - getCnt(l - 1);
}

//FizzBuzz String(n)????????????1???n?????§?????????)
int getLength(int n) {
	int ret = 4 * (n / 3 + n / 5);
	for (int i = 0; pow10[i] <= n; i++) {
		ret += (i + 1) * getCnt(pow10[i], min(n, pow10[i + 1] - 1));
	}
	return ret;
}

//FizzBuzz String(n)????????? <= length?????????????????§???????????´??°n?????????
int getNum(int length) {
	int st = 0, ed = 200000000000000000, mid; //oooxxx
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (getLength(mid) <= length) st = mid;
		else ed = mid;
	}
	return st;
}

//???num???????¨??????????
string fizzBuzz(int num) {
	if (num == 0) return "";
	if (num % 3 == 0 && num % 5 == 0) return "FizzBuzz";
	if (num % 3 == 0) return "Fizz";
	if (num % 5 == 0) return "Buzz";
	
	string s;
	while (num > 0) {
		s += (char)('0' + num % 10);
		num /= 10;
	}
	string ret;
	for (int i = s.length() - 1; i >= 0; i--) ret += s[i];
	return ret;
}

signed main() {
	int s;
	cin >> s;
	
	pow10[0] = 1;
	for (int i = 1; i < 20; i++) pow10[i] = pow10[i - 1] * 10;
	
	int num = getNum(s - 1);
	string ans;
	for (int i = num + 1; i <= num + 20; i++) {
		ans += fizzBuzz(i);
	}
	
	int offset = s - 1 - getLength(num);
	for (int i = 0; i < 20; i++) {
		cout << ans[offset + i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.StreamTokenizer;
import java.util.InputMismatchException;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		int n = sc.nextInt();
		int[][] a = new int[n][n];

		for (int i = 0; i < n; i++) {
			int u = sc.nextInt();
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				a[u - 1][sc.nextInt() - 1] = 1;
			}
		}
		
		for (int i = 0; i < n; i++) {
			pr.printArray(a[i]);
		}

		pr.close();
		sc.close();
	}
	
	private static class Scanner {
		InputStreamReader isr;
		BufferedReader br;
		StreamTokenizer st;
		
		Scanner (InputStream in) {
			isr = new InputStreamReader(in);
			br = new BufferedReader(isr);
			st = new StreamTokenizer(br);
		}
		
		String next() throws RuntimeException  {
			try {
				if (st.nextToken() != StreamTokenizer.TT_WORD) {
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}
			
			return st.sval;
		}
		
		int nextInt() throws RuntimeException {
			try {
				if (st.nextToken() != StreamTokenizer.TT_NUMBER) {
					throw new InputMismatchException();
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}
			
			return (int)st.nval;
		}

		void close() {
		}
	}
	
	private static class Printer {
		PrintStream out;
		StringBuffer strbuf;
		int bufSize;
		final String CR;

		Printer(PrintStream out) {
			this.out = out;
			strbuf = new StringBuffer();
			bufSize = 64 * 1024;
			CR = System.getProperty("line.separator");
		}

		void println(String str) {
			strbuf.append(str);
			strbuf.append(CR);
			checkStringBuffer();
		}

		void print(String str) {
			strbuf.append(str);
			checkStringBuffer();
		}

		void println(int n) {
			strbuf.append(n);
			strbuf.append(CR);
			checkStringBuffer();
		}

		void print(int n) {
			strbuf.append(n);
			checkStringBuffer();
		}

		void print(char c) {
			strbuf.append(c);
			checkStringBuffer();
		}

		void printArray(int[] array) {
			for (int i = 0; i < array.length; i++) {
				checkStringBuffer();
				strbuf.append(array[i]);
				strbuf.append(" ");
			}
			strbuf.delete(strbuf.length() - 1, strbuf.length());
			strbuf.append(CR);
		}

		void close() {
			flashStringBuffer();
		}
		
		private void flashStringBuffer() {
			if (strbuf.length() > 0) {
				out.print(strbuf);
				strbuf.setLength(0);
			}
		}
		
		private void checkStringBuffer() {
			if (strbuf.length() > bufSize) {
				out.print(strbuf);
				strbuf.setLength(0);
			}
		}
	}
}

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

#define fst first
#define snd second
#define fore(i,a,b) for(int i=a, ThxDem=b; i<ThxDem; ++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define SZ(s) int(s.size())
#define DBG(x) cerr <<#x << " = " << (x) << "\n"

#define SQR(x) ((x) * (x))

#define PI 3.1415926535897932385
#define INF 1000111222
#define eps 1e-7
#define maxN 11

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<bool> vbool;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vbool> vvbool;

int main(){FIN

	ll n,w,s=0;
	cin >> n >> w;
	vll ws(n),vs(n);
	fore(i,0,n){
		cin >> ws[i] >> vs[i];
		s+=vs[i];
	}
	vll dp(s+1,1e18L);
	dp[0] = 0;	
	fore(i,0,n){
		for(int j=(s-vs[i]);j>=0;j--)
			dp[j+vs[i]] = min(dp[j+vs[i]],dp[j]+ws[i]);
	}
	ll ans = 0;
	fore(i,0,s+1){
		if(dp[i]<=w) ans = max(ans,(ll)i);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3872
#include <iostream>
#include <vector>
#include <deque>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOREQ(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

static const int INF = 1e9;

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

    int H, W; cin >> H >> W;
    int start_y, start_x; cin >> start_y >> start_x;
    int goal_y, goal_x; cin >> goal_y >> goal_x;

    vector<vector<char>> field(H+2, vector<char>(W+2, '#'));
    FOREQ(y, 1, H) FOREQ(x, 1, W) cin >> field[y][x];

    deque<pair<int, int>> Q;
    vector<vector<int>> dist(H+2, vector<int>(W+2, INF));

    Q.emplace_back(start_y, start_x);
    dist[start_y][start_x] = 0;

    while (!Q.empty()) {
        auto [y, x] = Q.front(); Q.pop_front();
        if (y == goal_y && x == goal_x) {
            break;
        }
        static const int dy[] = {-1, 0, 1, 0};
        static const int dx[] = {0, -1, 0, 1};
        REP(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (field[ny][nx] != '.') { continue; }

            int new_dist = dist[y][x];
            if (new_dist < dist[ny][nx]) {
                dist[ny][nx] = new_dist;
                Q.emplace_front(ny, nx);
            }
        }
        FOREQ(dy, -2, 2) {
            int ny = y + dy;
            if (ny < 0 || ny > H) { continue; }
            FOREQ(dx, -2, 2) {
                int nx = x + dx;
                if (nx < 0 || nx > W) { continue; }
                if (field[ny][nx] != '.') { continue; }

                int new_dist = dist[y][x] + 1;
                if (new_dist < dist[ny][nx]) {
                    dist[ny][nx] = new_dist;
                    Q.emplace_back(ny, nx);
                }
            }
        }
    }

    if (dist[goal_y][goal_x] < INF) {
        cout << dist[goal_y][goal_x] << '\n';
    } else {
        cout << -1 << '\n';
    }
}


Measured memory_bytes: 8592
#include <cstdio>

using namespace std;

const int N = 200'009;

int a[N];
int ne[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  ne[n - 1] = n;
  for (int i = n - 2; i >= 0; --i) {
    ne[i] = a[i + 1] != 0 ? i + 1 : ne[i + 1];
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int v = a[i];
    int j = i;
    while (true) {
      ans += ne[j] - j;
      j = ne[j];
      if (j == n || (v & a[j]) != 0) {
        break;
      }
      v |= a[j];
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 1664
a, b = [int(i) for i in input().split()]


if a < b:
    if (b <= 0) or (a >= 0):
        ans = b - a
    else:
        ans = abs(abs(b) - abs(a)) + 1
else:
    if (a < 0) or (b > 0):
        ans = a - b + 2
    else:
        ans = abs(abs(a) - abs(b)) + 1

print(ans)

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

#define dcm(x) cerr << #x << ": " << x << endl;

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
    //clock_t start = clock();
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,k,x,y; cin>>n>>k>>x>>y;
    if (n>=k) cout << x*k+(n-k)*y << endl;
    else cout << x*n << endl;
    //clock_t stop = clock();
    //cout << (double)(stop-start)/CLOCKS_PER_SEC << " (s)" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

ll mod = 1e9+7;
template<typename T> void add(T &a,T b){a=(a+b)%mod;}
template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}

long double x=0,y=1;
array<long double,2> f(long double n){
    long double nx = x*cos(n)-y*sin(n);
    long double ny = x*sin(n)+y*cos(n);
    x = nx, y = ny;
    return {x,y};
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    long double n;
    cin>>n;
    n = pi*n/180.0;
    int cnt = 1;
    long double nx=0,ny=1;
    while(abs(nx)>eps || abs(ny)>eps){
        array<long double,2> a = f(n);
        nx += a[0], ny += a[1];
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4116
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
V g[ohara];
ll nene[ohara],ne,out[ohara];
ll dp[ohara];
V kae[ohara];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m;
    rep(i,n+m-1){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        g[a[i]].p_b(b[i]);
        nene[b[i]]++;
    }
    rep(i,n){
        if(nene[i]==0){
            ne=i;
            break;
        }
    }
    queue<ll> que;
    que.push(ne);
    while(1){
        if(que.empty())break;
        ll moto=que.front();
        que.pop();
        rep(i,Size(g[moto])){
            ll to=g[moto][i];
            nene[to]--;
            if(nene[to]==0)que.push(to);
            dp[to]=max(dp[to],dp[moto]+1);
        }
    }
    rep(i,n+m-1){
        if(dp[a[i]]+1==dp[b[i]])continue;
        out[i]=1;
    }
    rep(i,n+m-1){
        if(out[i])continue;
        kae[b[i]].p_b(a[i]);
    }
    rep(i,n){
        if(i==ne)Cout(0);
        else Cout(kae[i][0]+1);
    }
    return 0;
}

Measured memory_bytes: 64384
N, K = [int(_) for _ in input().split()]
S = list(input())

cnt = 0
l = 1

def f(w, start):
    l_idx = -1
    # while
    for i in range(start, N - 1):
        if S[i] == w[0] and S[i + 1] == w[1]:
            l_idx = i
            break

    if l_idx < 0: return -1
    r_idx = -1

    for i in range(l_idx + 1, N - 1):
        if S[i] == w[1] and S[i + 1] == w[0]:
            r_idx = i
            break

    if r_idx < 0: return -1

    for i in range(l_idx + 1, r_idx + 1):
        S[i] = 'R' if S[i] == 'L' else 'L'

    return l_idx + 1


cnt = 0

l = 1

while cnt < K and l > 0 and l < N - 1:
    l = f('LR', l)
    if l > 0: cnt += 1

l = 1
while cnt < K and l > 0 and l < N - 1:
    l = f('RL', l)
    if l > 0: cnt += 1

l = 0
for i in range(N - 1):
    if cnt >= K: break

    if S[i] != S[i + 1]:
        for j in range(l,i+1):
            S[j] = 'R' if S[j] == 'L' else 'L'
        cnt += 1
        l=i+1

m = 0
pre = ''
ans = 0
for i in range(N):
    if pre == S[i]:
        m += 1
    else:
        ans += m
        m = 0
        pre = S[i]
ans += m
print(ans)

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

int main(){
	char input1[200001], input2[200001];
	int diff = 0, len;

	gets(input1);
	gets(input2);

	for(int i = 0; i < strlen(input1); i++)
		if(input1[i] != input2[i])
			diff++;

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

	return 0;	
}

Measured memory_bytes: 2012
#include<stdio.h>
int main(){
  int n[6],d,i,id,min=10000;
  int rgb[3];
  char c[8][10]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
  int const R[8]={0,0,0,0,255,255,255,255};
  int const G[8]={0,0,255,255,0,0,255,255};
  int const B[8]={0,255,0,255,0,255,0,255};
  char s[10];
  while(1){
    fgets(s,9,stdin);
    if(s[0]=='0')break;
    min=100000;
    for(i=1;i<7;i++){
      if('0'<=s[i]&&s[i]<='9')n[i]=s[i]-'0';
      else                    n[i]=(s[i]-'a')+10;
    }
    for(i=0;i<3;i++){
      rgb[i]=n[i*2+1];
      rgb[i]*=16;
      rgb[i]+=n[i*2+2];
    }
    for(i=0;i<8;i++){
      d=(R[i]-rgb[0])*(R[i]-rgb[0])
       +(G[i]-rgb[1])*(G[i]-rgb[1])
       +(B[i]-rgb[2])*(B[i]-rgb[2]);
      if(min>d){
	id=i;
	min=d;
      }
    }
    printf("%s\n",c[id]);
  }
  return 0;
}

Measured memory_bytes: 524
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll X[30], Y[30], P[30], dist[30];
long double eps = 1e-9;
ll ans[35];
ll distx[40000][30], disty[40000][30];

void init_dist() {
  rep(i, 0, N) {
    ll d = INF;
    chmin(d, abs(X[i]));
    chmin(d, abs(Y[i]));
    dist[i] = d;
  }
}

void dfs(int cur, int cnt, int xx, int yy) {
  if (cur >= N) {
    ll score = 0;
    rep(i, 0, N) { score += min(distx[xx][i], disty[yy][i]) * P[i]; }
    chmin(ans[cnt], score);
    return;
  }

  dfs(cur + 1, cnt, xx, yy);

  dfs(cur + 1, cnt + 1, xx + ll(pow(2, cur) + eps), yy);

  dfs(cur + 1, cnt + 1, xx, yy + ll(pow(2, cur) + eps));
}

int main() {
  //
  cin >> N;
  rep(i, 0, N) { cin >> X[i] >> Y[i] >> P[i]; }

  init_dist();
  repe(i, 0, N) { ans[i] = INF; }

  for (ll bit = 0; bit < (1 << N); ++bit) {
    rep(i, 0, N) {
      distx[bit][i] = min(abs(X[i]), abs(Y[i]));
      disty[bit][i] = min(abs(X[i]), abs(Y[i]));
    }

    rep(i, 0, N) {
      if (bit & (1 << i)) {
        rep(j, 0, N) {
          chmin(distx[bit][j], abs(X[j] - X[i]));
          chmin(disty[bit][j], abs(Y[j] - Y[i]));
        }
      }
    }
  }

  /*
  for (ll bit = 0; bit < pow(3, N) + eps; ++bit) {
    ll b = bit;
    ll xx = 0;
    ll yy = 0;
    ll digit = 1;
    ll cnt = 0;
    rep(i, 0, N) {
      if (b % 3 == 1) {
        xx += digit;
        ++cnt;
      } else if (b % 3 == 2) {
        yy += digit;
        ++cnt;
      }
      digit *= 2;
      b /= 3;
    }

    ll score = 0;
    rep(i, 0, N) { score += min(distx[xx][i], disty[yy][i]) * P[i]; }
    chmin(ans[cnt], score);
  }
  */

  dfs(0, 0, 0, 0);

  cout << ans[0] << "\n";
  repe(i, 1, N) {
    chmin(ans[i], ans[i - 1]);
    cout << ans[i] << "\n";
  }
}


Measured memory_bytes: 19376
def resolve():
    a, b = map(int, input().split())
    if 0 in range(a, b+1):
        print('Zero')
    elif a >= 1:
        print('Positive')
    elif b < 0 and len(range(a, b+1)) % 2 == 0:
        print('Positive')
    else:
        print('Negative')

resolve()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1e9+7;
/* テンプレートここまで */

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

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  int n = s.size();
  int m = t.size();

  vector<vector<int>> dp(n+1, vector<int>(m+1, 0));

  REP(i, n){
    REP(j, m){
      if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
      else{
        chmax(dp[i+1][j+1], dp[i][j+1]);
        chmax(dp[i+1][j+1], dp[i+1][j]);
      }
    }
  }

  int l = dp[n][m];
  string ans = "";
  int x = n-1;
  int y = m-1;  
  while(l != 0){
    if(s[x] == t[y]){
      ans = s[x] + ans;
      x--; y--; l--;
      continue;
    }
    if(dp[x][y+1] == l) x--;
    else y--;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 35584
# question 3
N = input()
H = input().split()

# question 3
i = 0
res = [0]

for n in range(0, int(N)-1):
  if int(H[n]) >= int(H[n+1]):
    i += 1
  else:
    res.append(i)
    i = 0

res.append(i)
    
print(max(res))


Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, k;

    cin >> n >> k;

    ll sum = 0;
    ll low = 0, high = 0;
    for(int i = 0; i < k; i++) {
        low  += i;
        high += n - i;
    }
    for(int i = k; i <= n+1; i++) {
        sum += high - low + 1;
        sum %= SMOD;
        high += n - i;
        low += i;
    }

    cout << sum << endl;
    
    
    return 0;
}



Measured memory_bytes: 3648
/*
BIT。
fw.add(i,a)->fw[i]+=a
fw.sum(l,r)->[l,r)の和を出力
*/

#pragma region Template

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(vec) (vec).begin(), (vec).end()
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x, 0, sizeof(x))
#define m1(x) memset(x, 0xff, sizeof(x)) // init by -1
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, begin, end) for (int i = begin; i < end; i++)
#define endl '\n'
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
void inpl(const int n, vl &A)
{
    rep(i, n)
    {
        cin >> A[i];
    }
}
void inpl2(const int n, vvl &A)
{
    rep(i, n)
    {
        ll tmp;
        while (cin >> tmp)
        {
            A[i].push_back(tmp);
        }
    }
}
void printvec(const int n, vl &a, string sep = "\n")
{
    rep(i, n)
    {
        cout << a[i] << sep;
    }
}
#pragma endregion

void solve()
{
    ll n, m;
    cin >> n >> m;
    scc_graph ss(n);
    rep(i, m)
    {
        ll a, b;
        cin >> a >> b;
        ss.add_edge(a, b);
    }
    vector<vector<int>> ans = ss.scc();
    cout << ans.size() << endl;
    rep(i, ans.size())
    {
        cout << ans[i].size() << " ";
        rep(j, ans[i].size())
        {
            cout << ans[i][j];
            if (j == ans[i].size() - 1)
                cout << endl;
            else
                cout << " ";
        }
    }
}

signed main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 40112
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define all(a) a.begin(),a.end()
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//sort 降順
//reverse 逆順
 
int main() {
  ll a,b;
  ci(a>>b);
  string s;
  ci(s);
  vec c(b),d(b);
  for(i,0,b)
    ci(c[i]>>d[i]);
  //OK
  //co(s.size());
  vec e(a);
  ll f=0;
  for(i,0,a){
    if(s[i-1]=='A'&&s[i]=='C')
      f++;
    e[i]=f;
  }
  for(i,0,b)
    co(e[d[i]-1]-e[c[i]-1]);
}

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


int main()
{
  int n;
  cin>>n;
  vector<long long> v(n);
  double ans=0.0;
  for(int i=0;i<n;i++){cin>>v[i];
                       ans+=(double)1/(double)v[i];
    
                      }
  ans=(double)1/(double)ans;
  
  cout<<setprecision(10)<<fixed<<ans<<endl;
  
  
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes";
            break;
        }
        a-=d;
        if(a<=0){
            cout<<"No";
            break;
        }
    }
    
    return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int tempSum(int n) {
  return (n * (n + 1)) / 2;
}

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

  vector<double> probability(N);
  rep(i, N) {
    int current = P[i];
    double tempProbability = (double) tempSum(current) / (double) current;
    probability[i] = tempProbability;
  }

  vector<double> sum(N + 1, 0);
  rep(i, N) {
    sum[i + 1] = sum[i] + probability[i];
  }
  double result = -1.0;
  rep(i, N - K + 1) {
    double val = sum[K + i] - sum[i];
    if (val > result) {
      result = val;
    }
  }

  cout << fixed << setprecision(12) << result << endl;

  return 0;
}


Measured memory_bytes: 4096
/*s1190073  Rina Sato,
File name:prog1b.c,
2012 4/18(Wed),
This is a program which finds the greatest common divisor.*/

#include<stdio.h>
int main(void){
  int a,b,c,m,n;
  
  scanf("%d%d",&a,&b);
    
  if(a < b){
    m = a;
    n = b;
  }
  else {
    m = b;
    n = a;
  }
  
  /*use Ecclidean geometry*/
  while(1){
    c = m % n;
    if(c == 0) break;
    else {
      m = n;
      n = c;
    }
    
  }
  printf("%d\n",n);
  return 0;
}

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

int main()
{
    //データ定義
    int numA;
    int numB;
    char op;

    //
    while(1){
        //データ入力
        cin >> numA >> op >> numB;

        //演算子が?だったら終了
        if(op == '?') break;

        //計算
        switch (op){
            case '+':
                cout << numA + numB << endl;
                break;
            case '-':
                cout << numA - numB << endl;
                break;
            case '*':
                cout << numA * numB << endl;
                break;
            case '/':
                cout << numA / numB << endl;
                break;
            default:
                break;
        }
    }

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 

int a[100005];
int tree[200005];

void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}

void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}

int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main(){
	ios_base::sync_with_stdio(false);
    int n,m,a,b;
    cin >> n >> m;
    map<int,vector<int> > v;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a<=m){
            v[a].pb(b);
        }
    }
    ll ans = 0;
    priority_queue<int> pq;
    for(int i=1;i<=m;i++){
        for(int j=0;j<v[i].size();j++){
            pq.push(v[i][j]);
        }
        if(!pq.empty()){
            int rew = pq.top();
            ans+=rew;
            pq.pop();
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define int long long

using namespace std;

vector<vector<int>> g;
vector<int> indegree;
vector<int> visited;
vector<int> depth;

void dfs(int v){
	visited[v] = 1;
	for(int u : g[v]){
		depth[u] = max(depth[u], depth[v] + 1);
		--indegree[u];
		if(indegree[u] == 0)
			dfs(u);
	}
}

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

	int n, m; cin >> n >> m;
  g.resize(n, vector<int>()); visited.resize(n); indegree.resize(n); depth.resize(n);

	for(int i=0; i<m; i++){
		int a, b; cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		indegree[b]++;
	}

	for(int i = 0; i < n; i++){
		if(!visited[i] && indegree[i] == 0){
			dfs(i);
		}
	}

	cout << *max_element(depth.begin(), depth.end());


	#ifdef LOCAL
	cerr << "\n";
	#endif
	return 0;
}


Measured memory_bytes: 15544
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;
 
int main()
{
    ull r;
    cin >> r;
    cout << (3 * r * r) << endl;
    return 0;
}

Measured memory_bytes: 256