akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  int64_t n;
  cin>>n;
  int64_t mn = 1000000000000000ll;
  REP(i,5) {
    int64_t v;
    cin>>v;
    mn=min(mn, v);
  }
  cout << 4 + ((n + mn - 1) / mn) << endl;
  return 0;
}


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

int main() {

string x;
  cin >> x;
  if(x=="Sunny")
    cout << "Cloudy" ;
  else if(x=="Cloudy")
    cout << "Rainy" ;
  else if(x=="Rainy"){
    cout << "Sunny" ;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1000000007;

// ref: https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint
{
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD)
  {
  }
  mint operator-() const
  {
    return mint(-x);
  }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const
  {
    return mint(*this) += a;
  }
  mint operator-(const mint a) const
  {
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const
  {
    return mint(*this) *= a;
  }
  bool operator==(const mint a) const
  {
    return x == a.x;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const
  {
    return pow(MOD - 2);
  }
  mint &operator/=(const mint a)
  {
    return *this *= a.inv();
  }
  mint operator/(const mint a) const
  {
    return mint(*this) /= a;
  }
};
istream &operator>>(istream &is, const mint &a)
{
  return is >> a.x;
}
ostream &operator<<(ostream &os, const mint &a)
{
  return os << a.x;
}

int main()
{
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  vector<string> a(H);
  for (int i = 0; i < H; i++)
  {
    cin >> a[i];
  }
  vector<vector<mint>> dp(H + 1, vector<mint>(W + 1));
  dp[1][1] = 1;
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      if (a[i][j] == '.' && dp[i + 1][j + 1] == mint(0))
      {
        dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j];
      }
    }
  }
  cout << dp[H][W] << endl;

  return 0;
}


Measured memory_bytes: 9216
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans>10**18:
        print(-1)
        break
else:
    print(ans)


Measured memory_bytes: 21656
package main

import (
	"fmt"
)

func main() {
	var n int
    var a int64
	fmt.Scan(&n)
	a = 1
	for i := 0; i < n; i++ {
		var b int64
		fmt.Scan(&b)
		a = a/ gcd(a, b) * b
	}
	fmt.Println(a)
}
func gcd(x, y int64) int64 {
    if y == 0 {
        return x
    }
    return gcd(y, x%y)
}


Measured memory_bytes: 512
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint n,D,i,j,x,y;cin>>n>>D;
	static int kaz[1001][1001]={0};
	for(i=0;i<n;i++){cin>>x>>y;kaz[y%D][x%D]++;}
	int syo=0;
	for(y=0;y<D;y++){
		for(x=0;x<D;x++){maxeq(syo,kaz[y][x]);}
	}
	syo=(int)(sqrt(syo)+0.999999);
	//syoが最大のあれ トーラスに気を付ける
	//kazの意味を変える
	for(y=0;y<D;y++){
		for(x=0;x<D;x++){
			//cerr<<kaz[y][x]<<" ";
			if(kaz[y][x]>syo*(syo-1)){kaz[y][x]=2;}
			else if(kaz[y][x]>(syo-1)*(syo-1)){kaz[y][x]=1;}
			else {kaz[y][x]=0;}
		}//cerr<<endl;
	}
	//区間内に2や1があるかどうかを累積和で調べる
	static int niwa[2001][2001]={0};
	static int itwa[2001][2001]={0};
	for(y=0;y<D+D;y++){
		for(x=0;x<D+D;x++){
			niwa[y+1][x+1]=niwa[y+1][x];
			itwa[y+1][x+1]=itwa[y+1][x];
			if(kaz[y%D][x%D]==2){niwa[y+1][x+1]++;}
			if(kaz[y%D][x%D]>=1){itwa[y+1][x+1]++;}
		}
	}
	for(y=0;y<D+D;y++){
		for(x=0;x<D+D;x++){
			niwa[y+1][x+1]+=niwa[y][x+1];
			itwa[y+1][x+1]+=itwa[y][x+1];
		}
	}
	int bmin=0,bmax=D;
	int nisu=niwa[D][D];//全体の2の数
	while(bmax-bmin>1){
		int b=(bmin+bmax)/2;
		bool can=0;
		for(y=0;y<D;y++){
			for(x=0;x<D;x++){
				if(nisu==niwa[y+b][x+b]+niwa[y][x]-niwa[y+b][x]-niwa[y][x+b]&&
				0==itwa[y+D][x+D]+itwa[y+b][x+b]-itwa[y+D][x+b]-itwa[y+b][x+D])
				{can=1;break;}
			}
		}
		if(can){bmax=b;}
		else{bmin=b;}
	}
	cout<<(syo-1)*D+bmax-1<<endl;
	return 0;
}

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

int main(){
	long long int N,res=0;
	cin>>N;
	vector<int>A(N),B(N),C(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N;i++){
		cin>>B[i];
	}
	for(int i=0;i<N;i++){
		cin>>C[i];
	}
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());

	long long int a,b;

	for(int i=0;i<N;i++){
		a=(long long int)(lower_bound(A.begin(),A.end(),B[i])-A.begin());
		b=N - (long long int)(upper_bound(C.begin(),C.end(),B[i])-C.begin());
			res+=a*b;
	}
	cout<<res<<endl;

}

Measured memory_bytes: 1408
#include <iostream>
 
using namespace std;
 
int main()
{
int h=0, m=0, s=0;
 
cin >>h >>m;

if(h < m)
{
cout <<"a < b"<<endl;
}
else if(h > m)
{
cout <<"a > b"<<endl;
}
else
{
cout <<"a == b"<<endl;
}
 
return 0;
}

Measured memory_bytes: 3112
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;
int a[100];
int n ;
int main ()
{
  cin >> n ;
  for (int i =0 ; i < n ;i++)cin >> a[i];
  sort(a,a+n);
  int ans =0 ;
  for (int i = n-1 , j =0  ;i >=0 ;i--,j=!j)
  {
    ans += ( j ? -a[i] : a[i]);
  }
  cout << ans <<"\n";
  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
xs = list(map(int,input().split()))
ans = 0
dist = t - xs[ans]*0.006
for x in range(n):
    if abs(dist - a) > abs((t-xs[x]*0.006) - a):
        ans = x
    dist = t - xs[ans]*0.006
print(ans+1)

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/******************************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/******************************************************************************************************/

const ll nax=2e5+1,mod=1e9+7;



int main(){

    sync
   // file();
    
    int n,x;
    cin>>n>>x;
    fore(i,x-n+1,x+n-1){
        cout<<i<<" ";
    }


  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
     int n,k,s=1,c=0;
    scanf("%d%d",&n,&k);
    do
    {
        s=n%k;
        n=n/k;
        c++;
    }while(n!=0);
    printf("%d",c);

    return 0;
}


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

class DisjointSet {
public:
  vector<int> p, rank, size;
  DisjointSet(int n) {
    p.assign(n, 0);
    rank.assign(n, 0);
    size.assign(n, 0);
    for (int i = 0; i < n; i++) {
      make_set(i);
    }
  }
 
  void make_set(int x) {
    p[x] = x;
    rank[x] = 0;
    size[x] = 1;
  }
 
  int find_set(int x) {
    if (x != p[x]) {
      p[x] = find_set(p[x]);
    }
    return p[x];
  }
 
  bool same(int x, int y) {
    return find_set(x) == find_set(y);;
  }
 
  int union_size(int x) {
    if (x != p[x]) {
      size[x] = union_size(find_set(x));
    }
    return size[x];
  }
 
  void link(int x, int y) {
    if(rank[x]  > rank[y]) {
        p[y] = x;
        size[x] = size[x] + size[y];
    }else if(rank[x] < rank[y]){
        p[x] = y;
        size[y] = size[x] + size[y];
    }else if(x != y) {
      p[y] = x;
      rank[x]++;
      size[x] = size[x] + size[y];
    }
  }
 
  void unite(int x, int y) {
      link(find_set(x), find_set(y));
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  char c[H][W];
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < W; j++) {
      c[i][j] = s[j];
    }
  }
  int n = H * W;
  DisjointSet ds1(n);
  DisjointSet ds2(n);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W - 1; j++) {
      int k = W * i + j;
      if (c[i][j] == '.' && c[i][j + 1] == '.') {
        ds1.unite(k, k + 1);
      }
    }
  }

  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H - 1; j++) {
      int k = W * j + i;
      if (c[j][i] == '.' && c[j + 1][i] == '.') {
        ds2.unite(k, k + W);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, ds1.union_size(i) + ds2.union_size(i));
  }
  cout << ans - 1 << "\n";
  return 0;
}

Measured memory_bytes: 97920
#include <iostream>

using namespace std;

int main(){
	int H, W;
	cin >> H >> W;

	string fig[H];

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

	string line;
	for(int i = 0; i < W + 2; i++){
		line += "#";
	}

	for(int i = 0; i < H; i++){
		fig[i].push_back('#');
		fig[i].insert(0, "#");
	}


	cout << line << endl;
	for(int i = 0; i < H; i++){
		cout << fig[i] << endl;
	}
	cout << line << endl;

	return 0;
}


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

string s;

void input() {
    cin >> s;
}

void solve() {
    if(s == "SUN") cout << 7;
    else if (s == "MON") cout << 6;
    else if (s == "TUE") cout << 5;
    else if (s == "WED") cout << 4;
    else if (s == "THU") cout << 3;
    else if (s == "FRI") cout << 2;
    else if (s == "SAT") cout << 1;
    else cout << "something go wrong";
}
int main() {
    input();
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int MAXN=4e3+5;
int k,n;
ll inv[MAXN],fac[MAXN],rfac[MAXN];
ll pow[MAXN];
ll C(int n,int m){
	if (n<m) return 0;
	return fac[n]*rfac[m]%mod*rfac[n-m]%mod;
}
ll f(int x,int y,int z){
	ll ret=0;
	for (int i=0;i<=z&&i<=x;i++){
		if (i+y-1>z+y-1||i+y-1<0) continue;
		ret=(ret+C(x,i)*pow[i]%mod*C(z+y-1,i+y-1)%mod)%mod;
	}
	return ret;
}
int main(){
	scanf("%d%d",&k,&n);
	inv[1]=1;
	for (int i=2;i<=4e3;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	pow[0]=fac[0]=rfac[0]=1;
	for (int i=1;i<=4e3;i++){
		fac[i]=fac[i-1]*i%mod;
		rfac[i]=rfac[i-1]*inv[i]%mod;
		pow[i]=pow[i-1]*2ll%mod;
//		cout<<i<<" "<<fac[i]<<" "<<rfac[i]<<" "<<pow[i]<<endl;
	}
	for (int i=2;i<=2*k;i++){
		int cnt=0;
		for (int j=1;j<=k;j++){
			if (i-j<=k&&i-j>=1) cnt++;
		}
//		cout<<i<<" "<<cnt<<endl;
		if (i%2==0) printf("%lld\n",(f((cnt-1)/2,k-cnt,n)+f((cnt-1)/2,k-cnt,n-1))%mod);
		else printf("%lld\n",f(cnt/2,k-cnt,n)%mod);
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int h[n+1],ans,grow;
		rep(i,n+1)cin>>h[i];
		rep(i,n+1){
			vector<int> vec;
			rep(j,n+1){
				if(i==j)continue;
				vec.push_back(h[j]);
			}
			bool check=true;
			rep(j,vec.size()-1){
				if(j==0)grow=vec[j+1]-vec[j];
				else if(vec[j+1]-vec[j]!=grow)check=false;
			}
			if(check)ans=h[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	int graph[101][101] = {};
	cin >> n;
	int ans[101] = {};
	for(int i = 0; i < n; i++){
		ans[i] = -1;
		int u, k;
		cin >> u >> k;
		u--;
		for(int j = 0; j < k; j++){
			int v;
			cin >> v;
			v--;
			graph[u][v] = 1;
		}
	}
	queue<int> qu;
	qu.push(0);
	ans[0] = 0;
	while(!qu.empty()){
		int tmp = qu.front();
		qu.pop();
		for(int i = 0; i < n; i++){
			if(ans[i] == -1 && graph[tmp][i] > 0){
				ans[i] = ans[tmp] + 1;
				qu.push(i);
			}
		}
	}
	for(int i = 0; i < n; i++){
		cout << i + 1 << " " << ans[i] << endl;
	}
}

Measured memory_bytes: 3124
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int D = max(A, max(B, C));
    int E = min(A, min(B, C));
    int F = (A + B + C) - (D + E);

    cout << D * 10 + F + E << endl;


}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int Search(int key, vector<int>& a){
    int Max = n;
    int Min = 0;
    
    while(Min < Max){
        int Mid = (Max+Min)/2;
        if(key == a[Mid]){
            return 1;
        }
        if(key > a[Mid]){
            Min = Mid+1;
        }else if(key < a[Mid]){
            Max = Mid;
        }
    }
    return 0;
}
int main(){
  int m;
  cin >> n;
  int ans = 0;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
      cin >> a[i];
  }
  cin >> m;
  vector<int> b(m);
  for(int i = 0; i < m; i++){
      cin >> b[i];
      ans += Search(b[i], a);
  }
  
  cout << ans << endl;
}


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

int arr[1005][1005];
int days[1005];

bool visit(vector<int> &par, vector<bool> &visited, int node, int curr[]){
	//cout<<"IN: "<<node<<" "<<arr[node][curr[node]]<<endl;
	if(visited[arr[node][curr[node]]]){
		if(par[node]==arr[node][curr[node]]){
			curr[node]++;
			return true;
		}
		else{
			return false;
		}
	}
	else{
		visited[node] = true;
		par[arr[node][curr[node]]] = node;
		while(true){
			if(arr[arr[node][curr[node]]][curr[arr[node][curr[node]]]] == node){
				if(visit(par, visited, arr[node][curr[node]], curr)){
					days[node] = days[arr[node][curr[node]]] = max(days[node], days[arr[node][curr[node]]])+1;
					curr[node]++;
					visited[node] = false;
					return true;
				}
				else{
					visited[node] = false;
					return false;
				}
			}
			else{
				if(!visit(par, visited, arr[node][curr[node]], curr)){
					visited[node] = false;
					return false;
				}
			}
		}
	}
}

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

	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			cin>>arr[i][j];
		}
	}
	vector<int> par(n+1,0);
	vector<bool> visited(n+1,false);
	int curr[n+1];
	for(int i=1;i<=n;i++){
		curr[i] = 1;
		days[i] = 0;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		while(curr[i]<n){
			//cout<<i<<" "<<curr[i]<<endl;
			if(!visit(par, visited, i, curr)){
				cout<<-1<<endl;
				return 0;
			}
			// for(int i=1;i<=n;i++){
			// 	cout<<days[i]<<" ";
			// 	ans = max(ans, days[i]);
			// }
			// cout<<endl;
		}
	}
	for(int i=1;i<=n;i++){
		//cout<<days[i]<<" ";
		ans = max(ans, days[i]);
	}
	//cout<<endl;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4352
class CSR:
    def __init__(self, n: int, edges: list):
        self.start = [0] * (n+1)
        self.elist = [0] * len(edges)
        for e in edges:
            self.start[e[0]+1] += 1
        
        for i in range(1, n+1):
            self.start[i] += self.start[i-1]
        
        counter = self.start[::] # copy
        for e in edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1


class SccGraph:
    def __init__(self, n: int = 0):
        self.__n = n
        self.__edges = []
    
    def __len__(self):
        return self.__n
    
    def add_edge(self, s: int, t: int):
        assert 0 <= s < self.__n and 0 <= t < self.__n
        self.__edges.append([s, t])
    
    def __scc_ids(self):
        g = CSR(self.__n, self.__edges)
        now_ord = group_num = 0
        visited = []
        low = [0] * self.__n
        order = [-1] * self.__n
        ids = [0] * self.__n
        parent = [-1] * self.__n
        for root in range(self.__n):
            if order[root] == -1:
                stack = [root, root]
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        visited.append(v)
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        for i in range(g.start[v], g.start[v+1]):
                            t = g.elist[i]
                            if order[t] == -1:
                                stack += [t, t]
                                parent[t] = v
                            else:
                                low[v] = min(low[v], order[t])
                    
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = self.__n
                                ids[u] = group_num
                                if u == v:
                                    break
                                
                            group_num += 1
                        
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]], low[v])
        
        for i, x in enumerate(ids):
            ids[i] = group_num - 1 - x
        
        return group_num, ids
    
    def scc(self):
        group_num, ids = self.__scc_ids()
        counts = [0] * group_num
        for x in ids:
            counts[x] += 1
        
        groups = [[] for _ in range(group_num)]
        for i, x in enumerate(ids):
            groups[x].append(i)
        
        return groups


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int,readline().split())
data = list(map(int,read().split()))
sg = SccGraph(N)

it = iter(data)
for a, b in zip(it, it):
    sg.add_edge(a,b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(*([len(group)] + group))

Measured memory_bytes: 202812
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

int l[10];
int n, a, b, c;

int bin(int m, int i) {
	if (i == 1) { return m % 2; }
	else { return bin(m / 2, i - 1); }
}

int boocnt(int m) {
	if (m == 0) { return 0; }
	return boocnt(m / 2) + m % 2;
}

int mp(int ai, int bi, int ci) {

	ll al = 0;
	ll bl = 0;
	ll cl = 0;

	repn(i, n) {
		if (bin(ai, i) + bin(bi, i) + bin(ci, i) >= 2) { return 100000000; }
		if (bin(ai, i) == 1) { al += l[i]; }
		if (bin(bi, i) == 1) { bl += l[i]; }
		if (bin(ci, i) == 1) { cl += l[i]; }
	}

	
	return abs(a - al) + abs(b - bl) + abs(c - cl) + 10 * (boocnt(ai) + boocnt(bi) + boocnt(ci) - 3);

}


int main() {
	
	cin >> n >> a >> b >> c;

	repn(i, n) cin >> l[i];

	ll ans = 100000000;

	repn(ai, pow(2, n)-1) {
		repn(bi, pow(2, n)-1) {
			repn(ci, pow(2, n)-1) {
				ans = min(ans, mp(ai, bi, ci));



			}
		}
	}
	
	cout << ans;

	system("PAUSE");
}

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

struct Card { char suit, value; };

void bubble(Card A[], int N) {
    for ( int i = 0; i < N - 1; i++ ) {
        for ( int j = N - 1; j >= i + 1; j-- ) {
            if ( A[j].value < A[j - 1].value ) {
                swap(A[j], A[j - 1]);
            }
        }
    }
}

void selection(Card A[], int N) {
    int minj;
    for ( int i = 0; i < N; i++ ) {
        minj = i;
        for ( int j = i; j < N; j++ ) {
            if ( A[j].value < A[minj].value ) {
                minj = j;
            }
        }
        swap(A[i], A[minj]);
    }
}

void print(Card A[], int N) {
    for ( int i = 0; i < N; i++ ) {
        if ( i ) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(Card C1[], Card C2[], int N) {
    for ( int i = 0; i < N; i++ ) {
        if ( C1[i].suit != C2[i].suit ) return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;

    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        cin >> C1[i].suit >> C1[i].value;
        C2[i] = C1[i];
    }

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if ( isStable(C1, C2, N) ) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
#define ll long long 
using namespace std;
const int maxn=2e5+3;
const unsigned ll inf=-1; 
int  a[maxn]; 
ll  sum,n;
int  main()
{
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i]; 
	} 
	ll ans=inf>>1; 
	ll tmp=0; 
	for(int i=0;i<n-1;i++)
	{
		tmp+=a[i]; 
		ans=min(ans,abs(sum-tmp-tmp)); 
	} 
	printf("%lld\n",ans); 
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll r;
   cin>>r;
   
   cout<<r*r;
   
   return 0;
}  
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 998244353
using namespace std;
typedef long long ll;



void Main(){

  int H,W,A,B;
  cin>>H>>W>>A>>B;

  int dp[H][W]={};

  rep(i,H){
    rep(j,A){
      dp[i][j]=1;
    }
  }

  rep(i,B){
    rep(j,W){
      dp[i][j]=1-dp[i][j];
    }
  }

  rep(i,H){
    rep(j,W){
      cout<<dp[i][j];
    }
    cout<<"\n";
  }
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 5120
/* ex3_3
   tamayama */

#include<stdio.h>
 int main (void){
 
    int N,K;
    int input_K;
    int digit=1;
    scanf("%d %d",&N,&K);
    input_K = K;

    while(K <= N){
    K = input_K*K;
    digit++;
    }
    printf("%d\n",digit);

   return 0;
}


Measured memory_bytes: 128
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;


int main(int argc, char const *argv[]) {
    // code
    int n, m;
    cin >> n >> m;
    int ans = n*(n-1)/2 + m*(m-1)/2;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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


int main()
{
  int N, M; cin >> N >> M;
  vector<vector<int>> a(N, vector<int>(2));
  REP(i, N) {
    if (i == 0) {
      a[i][0] = 1;
      a[i][1] = 0;
    } else {
      a[i][0] = 0;
      a[i][1] = 1;
    }
  }
  REP(i, M) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    if (a[x][0] > 0) {
      a[x][0]--;
      a[y][0] += 1 + a[y][1];
      a[y][1] = 0;
    } else {
      a[x][1]--;
      if (a[y][0] > 0) a[y][0]++;
      else a[y][1]++;
    }
  }

  int ans = 0;
  REP(i, N) {
    if (a[i][0] > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
import sys

INF = float('inf')

def Bellmanford(n, edges, r): #r: ?§????
    d = [INF] * n
    d[r] = 0
    
    for i in range(n):
        
        for (u, v, c) in edges:
            if d[u] != INF and d[u] + c < d[v]:
                d[v] = d[u] + c
                if i == n-1:
                    return ['NEGATIVE CYCLE']
    
    d = [di if di < INF else 'INF' for di in d]
    return d
    

V, E, R = map(int, sys.stdin.readline().split())
Edges = [None] * E

for i in range(E):
    si, ti, di = map(int, sys.stdin.readline().split())
    Edges[i] = (si, ti, di)
    
ans = Bellmanford(V, Edges, R)

print(*ans, sep = '\n')

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    char a;
    cin>>a;
    if(a=='Y'){cout<<"Four"<<endl;break;}
    else if(a!='Y'&&i==n-1){cout<<"Three"<<endl;}
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    char a[3];
    for (int ik=0;ik<3;ik++){
        cin>>a[ik];
    }
    int ans=0;
    int sna=0;
    for (int i=0;i<3;i++){
        if(a[i]=='A')ans++;
        if(a[i]=='B')sna++;
    }
    if(ans==3||sna==3)cout<<"No"<<endl;
    else cout <<"Yes"<<endl;
    return 0;
    
}


Measured memory_bytes: 256
n,*b=map(int,open(0).read().split())
a=[]
while n:
  j=-1
  for i in range(n):
    if b[i]==i+1:
      j=i
  if j+1:
    b=b[:j]+b[j+1:]
    a+=[j+1]
  else:
    a=[-1]
    break
  n-=1
print(*a[::-1])

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

#define REP(i,num) for(int i=0;i<(num);++i)

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int N=in(),K=in();
  string S=in<string>();
  
  vector<int> p;
  p.reserve(N/2);
  p.push_back(0);
  char c=S[0];
  for(int i=1;i<N;i++){
    if(S[i]!=c){
      p.push_back(i);
      c=S[i];
    }
  }
  vector<int> l(p.size());
  for(int i=0,ei=p.size();i<ei;i++){
    int next = S[p[i]]=='1' ? i+2*K+1 : i+2*K;
    l[i] = next<ei ? p[next]-p[i] : N-p[i];
  }
  
  cout << *max_element(l.begin(),l.end()) << endl;
  
  return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <utility>
#include <tuple>
#include <map>
#include <ctype.h>
#include <set>
using namespace std;
using ll = long long;
ll gcd(ll p,ll q){
    ll r;
    while (q>0) {
        r=p%q;
        p=q;
        q=r;
    }
    return p;
}
ll lcm(ll m, ll n){
    ll gcd(ll,ll);
    ll x=m*n / gcd(m,n);
    return x;
}
int main() {
    ll A,B,C,D; cin >> A >> B >> C >> D;
    ll c,d,e;
    c = B/C - (A-1)/C;
    d = B/D - (A-1)/D;
    e = B/lcm(C,D) - (A-1)/lcm(C,D);
    cout << (B-A+1) - (c+d-e) << endl;

    return 0;
}

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

#define abs(x) ((x < 0) ? -(x) : x)
const double EPS = 1e-9;

const int T = 86400;
int N, L;
vector<int> s, t, u;

bool check(double pump) {
    double tank = L;
    int past;
    vector<double> res(2);
    for (int i = 0; i < 2; i++) {
        past = 0;
        for (int i = 0; i < N; i++) {
            tank = min((double)L, tank + (s[i] - past) * pump);
            tank = min((double)L, tank + (t[i] - s[i]) * (pump - u[i]));
            if (tank < 0) return false;
            past = t[i];
        }
        tank = min((double)L, tank + (T - past) * pump);
        res[i] = tank;
    }
    return res[0] == res[1];
}

double binary_search(double ok, double ng) {
    while (abs(ng - ok) > EPS) {
        double mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    return ok;
}

int main() {
    while (cin >> N >> L, N) {
        s.resize(N); t.resize(N); u.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> s[i] >> t[i] >> u[i];
        }
        double ok = 1e6;
        double ng = 0;
        double res = binary_search(ok, ng);
        printf("%.6f\n", res);
    }
    return 0;
}


Measured memory_bytes: 3972
N = int(input())
A = [0] + list(map(int,input().split())) + [0]

total = 0
for i in range(1,N+2):
    total += abs(A[i] - A[i-1])

for i in range(1,N+1):
    a = abs(A[i-1] - A[i])
    b = abs(A[i] - A[i+1])
    c = abs(A[i-1] - A[i+1])
    print(total - abs(c - (a + b)))


Measured memory_bytes: 14176
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
VEC<int> ope(VEC<int> const &A) {
  int N = A.size();
  VEC<int> B(N + 1, 0);
  REP(i, 0, N) {
    B[max(0, (int)i - A[i])]++;
    B[min(N, (int)i + A[i] + 1)]--;
    // DUMP(B);
  }

  VEC<int> sum(N, 0);
  sum[0] = B[0];
  REP(i, 1, N) { sum[i] = sum[i - 1] + B[i]; }
  // DUMP("Sum", sum);

  return sum;
}

int main() {
  int N, K;
  cin >> N >> K;
  VEC<int> A(N);
  REP(i, 0, N) cin >> A[i];

  REP(i, 0, K) {
    auto res = ope(A);
    if (A[0] == N) {
      bool all = 1;
      REP(i, 1, N) {
        if (A[i] != N) all = 0;
      }
      if (all) {
        REP(i, 0, N) { printf("%d ", A[i]); }
        puts("");
        return 0;
      }
    }

    A = res;
  }

  REP(i, 0, N) { printf("%d ", A[i]); }
  puts("");

  return 0;
}


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

int main()
{
  long long int n,k;
  cin>>n>>k;
  
  n=n%k;
  
  if(n > (k-n))
  {
    cout<<(k-n);
  }
  else{
cout<<n;
  }
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

ll M = pow(10, 7);
vector<string> H(M);

struct dict {
    ll strtokey(string s) {
        ll res = 0, p = 1;
        rep(i, s.size()) {
            if (s[i] == 'A')
                res += 1;
            else if (s[i] == 'C')
                res += 2 * p;
            else if (s[i] == 'G')
                res += 3 * p;
            else if (s[i] == 'T')
                res += 4 * p;
            p *= 5;
        }

        return res;
    }

    ll h1(ll key) { return key & M; }
    ll h2(ll key) { return 1 + (key % (M - 1)); }

    bool find(string s) {
        ll key, i, h;
        key = strtokey(s);
        for (int i = 0;; i++) {
            h = (h1(key) + i * h2(key)) % M;
            if (H[h] == s)
                return 1;
            else if (H[h].size() == 0)
                return 0;
        }
        return 0;
    }

    void insert(string s) {
        ll key, i, h;
        key = strtokey(s);
        for (int i = 0;; i++) {
            h = (h1(key) + i * h2(key)) % M;
            if (H[h] == s)
                return;
            else if (H[h].size() == 0) {
                H[h] = s;
                return;
            }
        }

        return;
    }
};

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

    dict D;
    int N;
    cin >> N;
    rep(i, N) {
        string s1, s2;
        cin >> s1 >> s2;
        if (s1[0] == 'i')
            D.insert(s2);
        else {
            cout << (D.find(s2) ? "yes" : "no") << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 93932
n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0]*n

for i in range(n):
    for j in range(i + 1, n):
        d = min(abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x))
        ans[d] += 1
for i in range(1, n):
    print(ans[i])


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  string key = "keyence";
  for(int i = 0; i <= key.size(); ++i){
    string f = s.substr(0, i);
    string b = s.substr(n - (key.size() - i), key.size() - i);
    string fb = f + b;
    if(key == fb)  {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void sort(int*, int*, int*);

int main(){
	int i,n,a,b,c;

	scanf("%d", &n);

	for(i=0;i<n;i++){
		scanf("%d %d %d", &a, &b, &c);
		sort(&a,&b,&c);
		if((a*a + b*b) == c*c){
			printf("YES\n");
		} else{
			printf("NO\n");
		}
	}

	return 0;
}

void sort(int* a, int* b, int* c){
	int tmp;
	if(*a > *b){
		tmp = *a;
		*a = *b;
		*b = tmp;
	}
	if(*a > *c){
		tmp = *a;
		*a = *c;
		*c = tmp;
	}
	if(*b > *c){
		tmp = *b;
		*b = *c;
		*c = tmp;
	}
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,s,ans=0;
    scanf("%d%d",&k,&s);
    for(int x=0;x<=k;x++)
    {
    for(int y=0;y<=k;y++)
    {
    if(s-x-y>=0&&s-x-y<=k) 
	ans++;
    }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d %d", $a, $b, $c);

if ($a == $b && $a != $c) {
  echo 'Yes';
} else if ($b == $c && $b != $a) {
  echo 'Yes';
} else if ($c == $a && $c != $b) {
  echo 'Yes';
} else {
  echo 'No';
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}

int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum+=gcd(gcd(i,j),k);
            }
        }
    }
    cout<<sum;
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> connect(M, vector<bool> (N, false));
  for(int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for(int j = 0; j < k; j++) {
      int s;
      cin >> s;
      connect.at(i).at(s - 1) = true;
    }
  }
  vector<int> mod(M);
  for(int i = 0; i < M; i++) {
    cin >> mod.at(i);
  }
  int ans = 0;
  for(int i = 0; i < (1 << N); i++) {
    bitset<10> Switch(i);
    for(int j = 0; j < M; j++) {
      int count = 0;
      for(int k = 0; k < N; k++) {
        if(connect.at(j).at(k) && Switch.test(k)) {
          count++;
        }
      }
      if(count % 2 != mod.at(j)) {
        break;
      }
      else if(j == M - 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define N (1800009)
#define LL long long
#define MOD (1000000007)
using namespace std;

LL inv[N],fac[N],facinv[N];
LL n,m,k,ans,f[N];

void Init()
{
	fac[0]=facinv[0]=inv[1]=1;
	for (int i=1; i<=1800000; ++i)
	{
		if (i!=1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		fac[i]=fac[i-1]*i%MOD; facinv[i]=facinv[i-1]*inv[i]%MOD;
	}
}

LL C(LL n,LL m)
{
	if (n<m) return 0;
	return fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;
}

LL Qpow(LL a,LL b)
{
	LL ans=1;
	while (b)
	{
		if (b&1) ans=ans*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return ans;
}

int main()
{
	Init();
	cin>>n>>m>>k;
	f[0]=1; f[1]=2;
	for (int i=1; i<=m+k; ++i)
		f[i]=(f[i-1]*2-C(i-1,m)-C(i-1,k))%MOD;
	for (int i=n; i<=n+m+k; ++i)
		(ans+=f[i-n]*C(i-1,n-1)%MOD*Qpow(3,n+m+k-i)%MOD)%=MOD;
	cout<<(ans+MOD)%MOD<<endl;
}

Measured memory_bytes: 50304
l = ['AKIHABARA',
     'KIHABARA','AKIHBARA','AKIHABRA','AKIHABAR',
     'KIHBARA','KIHABRA','KIHABAR',
     'AKIHBRA','AKIHBAR',
     'AKIHABR',
     'AKIHBR','KIHABR','KIHBAR','KIHBRA',
     'KIHBR']

print('YES' if input() in l else 'NO')

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  
  ll ans = 0;
  rep(i, n-1) {
    if (a[i] + a[i+1] > x) {
      ans += (a[i] + a[i+1]) - x;
      a[i+1] = x - a[i];
      if (a[i+1] < 0) {
        a[i] -= (-a[i+1]);
        a[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    int sum = 0, i;
    for(i = 1; i <= n; i++){
        sum += i;
        if(sum >= n) break;
    }
    for(int ans = 1; ans <= i; ans++){
        if(sum - n == ans) continue;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N; ll L;
    cin >> N >> L;
    vector<int> T(N);
    for (int n = 0; n < N; ++n) cin >> T[n];
    
    double SumX = 0.0, SumY = 0.0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            double dTemp = M_PI * (T[i] + T[j]) / L;
            int nTemp = N - (j - i) - 1;
            SumX += nTemp * cos(dTemp);
            SumY += nTemp * sin(dTemp);
            
            dTemp += M_PI;
            nTemp = j - i - 1;
            SumX += nTemp * cos(dTemp);
            SumY += nTemp * sin(dTemp);
        }
        //cerr << SumX << " " << SumY << endl;
    }
    double dTemp = N * (N-1) * 0.5 * (N-2) / 3.0;
    SumX /= dTemp;
    SumY /= dTemp;
    cout.precision(15);
    cout << fixed <<  SumX << " " << SumY << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
bool is_prime(ll nn){
    for(ll i=2; i*i <= n ;i++){
        if(nn%i==0) return 0;
    }
    return 1;
}

int main(){
    cin>>n;
    if(is_prime(n)) {
        cout<<n-1<<endl;
        return 0;;
    }
    ll min=INF;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            if(min>i+n/i-2) min=i+n/i-2;
        }
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
c = []
nil = [c.append([int(x) for x in input().split(" ")]) for y in range(3)]

if c[0][0] + c[2][2] == c[0][2] + c[2][0] and c[0][1] + c[1][2] + c[2][1] + c[1][0] - c[1][1] == c[0][0] + c[1][1] + c[2][2] :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define EPS 1e-9
const double PI = acos(-1);

const int N = 5001;
const int oo = 1e9;
const int MOD = 1000000007;

int t , n , q,dp[N][N][2],sz[N],fact[N],tmp[N][2];
vector<int> g[N];


int calc(int u,int p){
	sz[u] = 1;
	dp[u][1][0] = 1;
	for(auto v : g[u])if(v!=p){
		calc(v,u);
		for(int i = 0 ; i <= sz[u];++i)
			for(int j = 0 ; j<= 1 ; ++j)
				tmp[i][j] = dp[u][i][j],dp[u][i][j]=0;
		for(int i = sz[u];  i >= 1;--i)
			for(int j = sz[v] ; j >= 1 ; --j)
				for(int p1 = 0 ; p1 <= 1;++p1)
					for(int p2 = 0 ; p2 <= 1 ; ++p2){
						dp[u][i+j][p1^p2] = (1ll*dp[u][i+j][p1^p2]+1ll*tmp[i][p1]*dp[v][j][p2])%MOD;
						dp[u][i][p1^p2^1] = (1ll*dp[u][i][p1^p2^1]+(1ll*tmp[i][p1]*dp[v][j][p2])%MOD*fact[j])%MOD;
					}

		sz[u] += sz[v];
	}
}

int main() {
	cin >> n;
	fact[0] = 1l;
	for(int i = 2 ; i <= n ; i += 2){
		fact[i] = ((i-1)*1ll*fact[i-2])%MOD;
	}
	for (int u, v, i = 0; i < n - 1; ++i) {
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	calc(1,-1);
	ll res = 0;
	for(int i = 1 ; i <= n ; i ++){
		res = (res+(dp[1][i][0]-dp[1][i][1]*1ll)*fact[i])%MOD;
		if(res<0)
			res += MOD;
	}
	printf("%lld\n", res);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
void trace(int a[],int N){
  int k;
  for(k=0;k<N;k++){
      if(k>0){
         printf(" ");
      }
    printf("%d",a[k]);
    }
  printf("\n");
}
 
void insertionsort(int a[],int N){
  int i,j,v;
  for(i=1;i<N;i++){
    v=a[i];
    j=i-1;
    while(j>=0&&a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    trace(a,N);
  }
}
 
int main(void)
{
  int N,i,j,a[100];
 
  scanf("%d",&N);
 
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  trace(a,N);
  insertionsort(a,N);
       
  return 0;
}

Measured memory_bytes: 1812
import sys,math,itertools
def r(x):
    sum = 0
    for i in range(1,x+1):
        sum += i
    return sum

N = int(input())
s = []
ans = [0] * N
for i in range(N):
    tmp = input()
    li_tmp = list(tmp)
    s_tmp = sorted(li_tmp)
    st = "".join(s_tmp)
    s.append(st)

data = {}
a = set()
a.add(s[N-1])
for i in range(N-2,-1,-1):
    if s[i] in a:
        if s[i] in data:
            data[s[i]] += 1
        else:
            data[s[i]] = 1 
    else:
        a.add(s[i])
for i in data:
    data[i] = r(data[i])
print(sum(data.values()))

Measured memory_bytes: 17192
#include <iostream>
using namespace std;
#define INF 1e9
int n;
int row[200], col[200];
int dp[200][200];

int dfs(int l, int r) {
  // row[i],col[i]=row[i+1],col[i+1]
  // row[i]*col[i]*col[i+1]
  if (l == r) return 0;
  if (dp[l][r] != INF) return dp[l][r];
  for (int c = l; c < r; c++) {
    dp[l][r] = min(dp[l][r], dfs(l,c)+dfs(c+1,r)+row[l]*col[c]*col[r]);
  }
  return dp[l][r];
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> row[i] >> col[i];
  }
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      dp[i][j]=INF;
  cout << dfs(0, n-1) << endl;
}




Measured memory_bytes: 3148
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll X,Y;
int main() {
	cin>>X>>Y;

	if(X>Y)cout<<X-Y<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 764