akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X, Y, Z, K;
  IN(X,Y,Z,K);
  vll A(X), B(Y), C(Z);
  REP(i,X) IN(A[i]);
  REP(i,Y) IN(B[i]);
  REP(i,Z) IN(C[i]);

  vll AB(X*Y);
  REP(i,X){
    REP(j,Y){
      AB[i*Y+j] = A[i]+B[j];
    }
  }

  sort(ALL(AB));
  reverse(ALL(AB));

  ll K_tmp = min(K, X*Y);
  vll AB_(K_tmp);
  REP(i,K_tmp) AB_[i] = AB[i];

  vll ABC(K*Z);
  REP(i,K_tmp){
    REP(j,Z){
      ABC[i*Z+j] = AB_[i]+C[j];
    }
  }

  sort(ALL(ABC));
  reverse(ALL(ABC));

  REP(i,K){
    printf("%lld\n", ABC[i]);
  }
  


  return 0;
}

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

int main()
{
    //string s;
    //cin >> s;
    int64_t N,K;
    cin >> N >> K;
    //vector<int> A(N);
    //vector<vector<int>> vec(N, vector<int>(N,99));

    int64_t ans;

    if(N < 0) N = -N;
    //if(N >= 0){
        int64_t amari = 0;
        amari = N%K;
        if((K - amari) < amari) ans = K - amari;
        else ans = amari;
    //}

    cout << ans << endl;

    return 0;
}

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

long long dp[444][444];
vector<long long> sum(1);

int main(){
	int N;
	cin >> N;
	vector<long long> a(N);
	for(auto &i:a)cin >> i;
		
	for(int i=0;i<N;i++)sum.push_back(sum[i]+a[i]);
	
	for(int w=2;w<=N;w++){
		for(int l=0;l<=N-w;l++){
			int r=l+w;
			long long tmp=9999999999999999LL;
			for(int x=l+1;x<r;x++)tmp=min(tmp,dp[l][x]+dp[x][r]);
			dp[l][r]=tmp+sum[r]-sum[l];
		}
	}
	cout << dp[0][N] << endl;
	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Linq;

namespace Volume0_0006
{
    class Program
    {
        static void Main(string[] args)
        {
            String input = Console.ReadLine();
            
            foreach(var value in input.Reverse())
            {
                Console.Write(value);
            }

            Console.WriteLine();
        }
    }
}

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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

using namespace std;

typedef uint64_t ulint;
typedef int64_t lint;

// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;

template<class T> lint sum(vector<T> a);
template<class T> double ave(vector<T> a);
template<typename T> ostream& operator << (ostream& s, const vector<T>& v);
ulint gcd(lint a, lint b);
ulint lcm(lint a, lint b);

bool flagdebug = false;





////////////////////////////////////////////////////////////////////////
// Union - Find

// グローバル変数
const int MAX_N = 100000;
int par[MAX_N];
int rnk[MAX_N];

// 関数
void initunion(int n){
    rep0(i, n){
        par[i] = i;
        rnk[i] = 0;
    }
}

//木を駆け上がりrootを探索する
int findroot(int x){
    if(par[x] == x)return x;
    else return par[x] = findroot(par[x]);
}

//結合
void uniteroot(int x, int y){
    x = findroot(x);
    y = findroot(y);
    if( x == y )return; //結合済
    if(rnk[x] < rnk[y])par[x] = y;
    else if(rnk[x] > rnk[y])par[y] = x;
    else {
        par[y] = x;
        rnk[x]++;
    }
}

bool sameroot(int x, int y){
    return findroot(x) == findroot(y);
}

int main(){
//////////////////////////////////////////////////////

    //flagdebug = true; ///本番時削除！！！！！

    //入力
    lint n, m;
    cin >> n >> m;
    initunion(n);
    lint x , y, z;
    rep0(i, m)
    {
        cin >> x >> y >> z;
        uniteroot(x,y);
        
    }

    vector<lint> isroot(n,0);
    rep0(i,n)
    {
        isroot[findroot(i)] ++;
    }

    lint rootnum = 0;
    rep0(i,n)
    {
        if(isroot[i]>0)rootnum++;
    }

    cout << rootnum << endl;
    return 0;
}

//vectorprint用
template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
    s << "[\t";
    for (auto i = v.begin(); i < v.end() - 1; i++){s << *i << "\t";}
    s << *(v.end() - 1) << "\t]\n";
	return s;
}

// 最大公約数
ulint gcd(lint a, lint b){
    if(b!=0){return gcd(b, a % b);}
    return a;    
}

//最小公倍数
ulint lcm(lint a, lint b){
    return a / gcd(a, b) * b;
}


Measured memory_bytes: 1792
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    int A, B;

    cin >> A >> B;

    if (A > 8 || B > 8)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 3100
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    s, t = sys.stdin.read().split()
    n, m = len(s), len(t)
    s = sorted(s)
    t = list(reversed(sorted(t)))
    if n < m:
        for i in range(n):
            if s[i] < t[i]: ans = 'Yes'; break
            elif s[i] > t[i]: ans = 'No'; break  
        else:
            ans = 'Yes'
    else:
        for i in range(m):
            if s[i] < t[i]: ans = 'Yes'; break
            elif s[i] > t[i]: ans = 'No'; break  
        else:
            ans = 'No'

    print(ans)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3064
n=int(input())
F=[]
for i in range(n):
    F.append(list(map(int,input().split())))
P=[]
for i in range(n):
    P.append(list(map(int,input().split())))
#ビット探索
count=2**10
both=[0]*n
ans=-1000000000
profit=0
num=0#同時に出店した数を数える
for i in range(1023):
    count+=1
    bit=bin(count)
    for j in range(n):
        for k in range(10):
            if int(bit[k+3])&F[j][k]:#初め３桁は0b1が入っているので４桁目から
                num+=1
        profit+=P[j][num]   
        num=0           
    if profit>ans:
        ans=profit
    profit=0
print(ans)

Measured memory_bytes: 3064
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline void Assert(bool b)
{
  if (!b)
    exit(1);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int q;
  cin >> q;
  ll b_sum = 0;
  priority_queue<ll> L;
  smaller_queue<ll> R;
  ll Ls = 0, Rs = 0;
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 1)
    {
      ll a, b;
      cin >> a >> b;
      b_sum += b;
      if (L.empty())
      {
        Ls += a;
        L.push(a);
      }
      else if (R.empty())
      {
        if (a < L.top())
        {
          Rs += L.top();
          R.push(L.top());
          Ls -= L.top();
          L.pop();
          Ls += a;
          L.push(a);
        }
        else
        {
          Rs += a;
          R.push(a);
        }
      }
      else if (a < L.top())
      {
        Rs += L.top();
        R.push(L.top());
        Ls -= L.top();
        L.pop();
        Ls += a;
        L.push(a);
      }
      else if (a > R.top())
      {
        Ls += R.top();
        L.push(R.top());
        Rs -= R.top();
        R.pop();
        Rs += a;
        R.push(a);
      }
      else
      {
        Rs += a;
        R.push(a);
      }
      if (L.size() - R.size() == 2)
      {
        Rs += L.top();
        R.push(L.top());
        Ls -= L.top();
        L.pop();
      }

      if (L.size() < R.size())
      {
        Ls += R.top();
        L.push(R.top());
        Rs -= R.top();
        R.pop();
      }
      Assert((int)L.size() - (int)R.size() == 0 || (int)L.size() - (int)R.size() == 1);
    }
    else if (type == 2)
    {
      ll sz = (int)L.size() + (int)R.size();
      ll x = L.top();
      ll val = Rs - Ls + x * (sz % 2) + b_sum;
      cout << x << " " << val << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	priority_queue<ll> A;
	int N, M;
	cin >> N >> M;
	ll a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		A.push(a);
	}
	ll tmp;
	for (int i = 0; i < M; i++) {
		tmp = A.top();
		A.pop();
		A.push(tmp / 2);
	}
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A.top();
		A.pop();
	}
	cout << sum << endl;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int w;cin>>w&&w;){
		vvi a(2,vi(w));
		rep(i,2) rep(j,w) cin>>a[i][j];
		vvi dp(2,vi(w));
		dp[0][0]=a[0][0];
		rep(i,2) rep(j,w){
			if(i) chmax(dp[i][j],dp[i-1][j]+a[i][j]);
			if(j) chmax(dp[i][j],dp[i][j-1]+a[i][j]);
		}
		cout<<dp[1][w-1]<<endl;
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    rep(i, N) {
        if (A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)) {
            write("DENIED");
            return 0;
        }
    }
    write("APPROVED");
}

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

#define LIM (int)(10e6+1)
bool nprm[LIM];

int main() {
	nprm[0] = nprm[1] = true;
	for (int i = 2; i <= LIM; i++) {
		if (nprm[i] == 0) {
			for (int j = i * 2; j < LIM; j += i) nprm[j] = true;
		}
	}
	while (true) {
		int a, d, n, cnt = 0; cin >> a >> d >> n;
		if (a == 0 && d == 0 && n == 0)break;
		for (int i = a; i < LIM; i += d)	{
			if (nprm[i] == 0)cnt++;
			if (cnt == n) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    for(int i = 0;i < N;i++){
        cin >> F[i];
    }
    sort(F.begin(), F.end());
    ll lb = -1, ub = 1000000000000LL;
    while(ub - lb > 1){
        ll m = (lb + ub) / 2;
        ll sum = 0;
        for(int i= 0;i < N;i++){
            ll x = m / F[i];
            sum += max(0LL, A[i] - x);
        }
        (sum <= K ? ub : lb) = m;
    }
    cout << ub << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  double ret=0;
  for(int loop=1;loop<=a;loop++){
    double tmp=1.0/a;
    int now=loop;
    while(now<b){
      now*=2;
      tmp/=2;
    }
    ret+=tmp;
  }
  printf("%.12f\n",ret);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <iostream>


using namespace std;

signed main() {
    long n;
    cin >> n;
    if (n % 2) {
        cout << n * 2 << endl;
    } else {
        cout << n << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc = initScanner(os.Stdin)
	o, e := scanString(sc), scanString(sc)
	fmt.Println(solve(o, e))
}

func solve(o, e string) string {
	os := strings.Split(o, "")
	es := strings.Split(e, "")

	ans := ""
	if len(os)-len(es) == 0 {
		for i := 0; i < len(os); i++ {
			ans += os[i] + es[i]
		}
	} else {
		for i := 0; i < len(os); i++ {
			ans += os[i]
			if i != len(os)-1 {
				ans += es[i]
			}
		}
	}
	return ans
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanFloat64(sc *bufio.Scanner) float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func scanFloat64Slice(sc *bufio.Scanner, n int) []float64 {
	fs := make([]float64, n)
	for i := 0; i < n; i++ {
		fs[i] = scanFloat64(sc)
	}

	return fs
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 1000000007;

struct Combinations {
    int max, mod;
    VLL fac, finv, inv;

    Combinations(int _max, int _mod) : fac(_max), finv(_max), inv(_max) {
        max = _max;
        mod = _mod;
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        REP2(i, 2, max) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod; 
        }
    }

    LL calc(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

void solve(long long n, long long k){
    Combinations comb(400002, MOD);

    LL ans = 0;

    REP(i, min(k+1, n)) {
        //cout << comb.calc(n, i) << " " << comb.calc(n - 1, n - i - 1) << endl;
        ans += comb.calc(n, i) * comb.calc(n - 1, n - i - 1);
        ans %= MOD;
    }

    cout << ans << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    long long k;
    scanf("%lld",&k);
    solve(n, k);
    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int n,i,j,count=0;

	scanf("%d", &n);

	int *a = (int*)malloc(n * sizeof(int));

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n ; i++) {
		if (a[a[i] - 1] == i + 1)count++;
	}
	printf("%d\n", count/2);
	free(a);
	return 0;
	
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c;cin>>a>>b>>c;
  string ans="No";
  if(a==b&&b!=c) ans="Yes";
  if(b==c&&c!=a) ans="Yes";
  if(c==a&&a!=b) ans="Yes";
  print(ans);
  return 0;
}

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

int main(){
    string s,t;
    int cnt = 0,size = 0;

    cin >> s >> t ;

    size = s.size();
    for( int i = 0; i < size; i++ ){
        if( s[i] != t[i] )cnt++;
    }

    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	while(cin >> n){
		vector<ll> a(n), b(n);
		REP(i, n){
			cin >> a[i] >> b[i];
		}
		ll ans = 0;
		RREP(i, n){
			ans += (b[i] - (a[i] + ans) % b[i]) % b[i];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int ans = INF;
  for (int i = 1; i <= 100; i++) {
    int num = 0;
    rep(j, n)
      num += pow(x[j]-i, 2);
    chmin(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int a,b; cin>>a>>b;
  COUT(b*2-a);
}













Measured memory_bytes: 256
n,m=map(int,input().split())

#Union-Find
par=[-1 for i in range(n)]

def root(a):
    if par[a]<0:
        return a
    else:
        return root(par[a])

def size(a):
    return -par[root(a)]

def connect(a,b):
    a=root(a)
    b=root(b)
    if a==b:
        return False
    if size(a)<size(b):
        a,b=b,a
    par[a]+=par[b]
    par[b]=a
    return True

xyz=[]
for i in range(m):
    a=[int(j) for j in input().split()]
    xyz.append([a[0]-1,a[1]-1,a[2]%2])
    if root(a[0]-1)!=root(a[1]-1):
        connect(a[0]-1,a[1]-1)
ans=0
for i in range(n):
    ans+=1/size(i)
print(round(ans))

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

using namespace std;

using int_type = int64_t;

#define FOR(i, n) for (int_type i = 0; i < n; ++i)

int_type gcd(int_type a, int_type b) {
    return b == 0 ? a : gcd(b, a % b);
}
int_type lcm(int_type a, int_type b) {
    return (a * b) / gcd(a, b);
}

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

    int_type N;
    cin >> N;

    std::string S, T;
    cin >> S >> T;

    FOR(i, N) cout << S[i] << T[i];

    return 0;
}


Measured memory_bytes: 888
A, B, C, D, E, F = map(int, input().split())
conc = 0
answater = 100*A
anssugar = 0


for i in range(1, F//(100*A)+1):
    for j in range(F//(100*A)+1):
        if 100*A*i+100*B*j>F:
            break
        for k in range(E*(A*i+B*j)+1):
            if 100*A*i+100*B*j+C*k>F or C*k>E*(A*i+B*j):
                    break
            for l in range(E*(A*i+B*j)+1):
                if 100*A*i+100*B*j+C*k+D*l>F or C*k+D*l>E*(A*i+B*j):
                    break
                tmp = 100*(C*k+D*l)/(100*A*i+100*B*j+C*k+D*l)
                if tmp > conc:
                    conc = tmp
                    answater = 100*A*i+100*B*j+C*k+D*l
                    anssugar = C*k+D*l

print(answater, anssugar)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <cctype>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T>
inline void read(T &ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return ;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1:1;
    ret = (c == '-') ? 0:(c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return ;
}
inline void outi(int x) {if (x > 9) outi(x / 10);putchar(x % 10 + '0');}
inline void outl(ll x) {if (x > 9) outl(x / 10);putchar(x % 10 + '0');}

using namespace std;
int n,x,t;
int main()
{
    cin>>n>>x>>t;
    if(n%x==0)
        cout<<n/x*t<<endl;
    else
        cout<<n/x*t+t<<endl;
}


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

int main()
{
  string s;
  cin >> s;

  long long ans = 0;
  for (int bit = 0; bit < (1 << (s.size() - 1)); ++bit)
  {
    long long sum = s[0] - '0';
    for (int i = 0; i < s.size() - 1; ++i)
    {
      if (1 << i & bit)
      {
        ans += sum;
        sum = s[i + 1] - '0';
      }
      else
      {
        sum *= 10;
        sum += s[i + 1] - '0';
      }
    }
    ans += sum;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#define MAXN 1006
#define INF 66666666666.0
using namespace std;
long double d[MAXN],map[MAXN][MAXN],xs,xt,ys,yt,x[MAXN],y[MAXN],r[MAXN];
int in[MAXN],n;
void SPFA(int x)
{
	for(int i=1;i<=n;i++)
		d[i]=INF;
	d[x]=0.0;
	queue<int> q;
	q.push(x);
	in[x]=1;
	while(!q.empty())
	{
		int now=q.front();
		in[now]=0;
		q.pop();
		for(int i=1;i<=n;i++)
		{
			if(i==now) continue;
			if(d[i]>d[now]+map[now][i])
			{
				d[i]=d[now]+map[now][i];
				if(!in[i])
				{
					in[i]=1;
					q.push(i);
				}
			}
		}
	}
}
int main()
{
	scanf("%Lf%Lf%Lf%Lf",&xs,&ys,&xt,&yt);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%Lf%Lf%Lf",&x[i],&y[i],&r[i]);
	n++;
	x[n]=xs;
	y[n]=ys;
	r[n]=0.0;
	n++;
	x[n]=xt;
	y[n]=yt;
	r[n]=0.0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			long double len=max(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j],(long double)(0.0));
			map[i][j]=map[j][i]=len;
		}
	}
	SPFA(n-1);
	printf("%.10Lf",d[n]);
}

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

int main() {
	string S;
	cin >> S;
	int ans = 0, cnt = 0;
	for (int i = 0; i < (int)S.size(); i++) {
		if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
			cnt++;
		} else {
			cnt = 0;
		}

		if (ans < cnt) ans = cnt;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

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


int main()
{
  ll a; cin >> a;
  ll b; cin >> b;
  ll c; cin >> c;
  ll d; cin >> d;

  ll ans = a*c;
  maxs(ans, a*d);
  maxs(ans, b*c);
  maxs(ans, b*d);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let n = scan "%d" id

exception Found

let () =
  ListL.fold_left (1++n) ~init:0 ~f:(fun pred i ->
      let m = n/i in pred + i*m*(m+1)/2)
  |> Printf.printf "%d\n"


Measured memory_bytes: 242024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] line = scanner.nextLine().toCharArray();
		for(char a: line)
			if(Character.isLowerCase(a)){
			    	System.out.print(Character.toUpperCase(a));
			}else{
			        System.out.print(Character.toLowerCase(a));
			}
		System.out.println();
	}
}



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

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

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

    int sum = accumulate(a.begin(), a.end(), 0);
    int num = a.size();

    int ave = sum / num;
    int dist = 0;
    REP(i, n) dist += pow(ave - a[i], 2);

    int ave2 = sum / num + 1;
    int dist2 = 0;
    REP(i, n) dist2 += pow(ave2 - a[i], 2);

    cout << min(dist, dist2) << '\n';
    return 0;
}


Measured memory_bytes: 256
s = input()
nums = list(reversed([int(c) for c in s])) + [0]
r = (0, 1) # no borrow, with borrow
for i in range(len(nums)):
    # print(r)
    next_no_borrow = min(r[0] + nums[i], r[1] + nums[i] + 1)
    next_borrow = min(10 - nums[i] + r[0], 9 - nums[i] + r[1])
    r = (next_no_borrow, next_borrow)
print(min(r))


Measured memory_bytes: 22200
fn main() {
    let (mut q, mut h, mut s, mut d): (i64, i64, i64, i64) = readln();
    h = min(h, q * 2);
    s = min(s, h * 2);
    d = min(d, s * 2);

    let mut n: i64 = readln();

    n *= 4;

    let mut answer = 0;

    answer += d * (n / 8);
    n %= 8;
    answer += s * (n / 4);
    n %= 4;
    answer += s * (n / 2);
    n %= 2;
    answer += q * n;

    println!("{}", answer);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
vector< int > g[1000079];
bool vis[1000009];
int cnt;

void dfs(int node)
{
  if( vis[node]==1) return ;
  vis[node]=1;
  cnt++;
  
  for( auto c: g[node])
    dfs(c) ;
}










int main()
{
  int n,m;
  cin>>n>>m;
  while(m--)
  {
    int a,b; cin>>a>>b;
    g[a].push_back(b) ;
    g[b].push_back(a) ;
  }
  int mx=0;
  for(int i=1;i<=n;i++)
  {
    if( vis[i]==0 ) 
    { 
	
	  cnt=0;
      dfs(i) ;
    mx= max(cnt,mx);
    
  }
  
   


}
 cout<<mx<<endl;

}

Measured memory_bytes: 39680
#include<iostream>
#include<vector>
#include<algorithm>
#define f first
#define s second

using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef long long ll;
typedef pair<int,int> P;

mat mul(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size()));
  for(int i=0;i<A.size();i++)
    for(int k=0;k<B.size();k++)
      for(int j=0;j<B[0].size();j++)
	C[i][j]+=A[i][k]*B[k][j];

  return C;
} 

mat pow(mat A,ll n){
  mat B(A.size(),vec(A.size()));
  for(int i=0;i<A.size();i++)B[i][i]=1;
  for(;n>0;n>>=1,A=mul(A,A))
    if(n&1)B=mul(B,A);
  
  return B;
}

int main(void){

  int n,m,z,s,d;
  vector<P>G;

  while(cin >> n >> m >> z,n|m|z){
    G.clear();
    G.push_back(P(1,1));
    for(int i=0;i<m;i++){
      cin >> s >> d;
      G.push_back(P(s,d));
      G.push_back(P(d,s));
    }

    mat A(G.size(),vec(G.size()));
 
    for(int i=0;i<G.size();i++)
      for(int j=1;j<G.size();j++)
	if(i!=j && G[i].f!=G[j].s && G[i].s==G[j].f)A[i][j]=1;

    A=pow(A,z);

    bool fg=false;
    for(int i=0;i<A.size();i++)
      if(G[i].s==n && A[0][i])fg=true;

    cout << (fg?"yes":"no") << endl;
  }
  return 0;
}

Measured memory_bytes: 1380
#include <iostream>
int main() {
    int h, w;
    for (std::cin >> h >> w; h != 0 || w != 0; std::cin >> h >> w) {
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                char c;
                if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
                    c = '#';
                } else {
                    c = '.';
                }
                std::cout << c;
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
}



Measured memory_bytes: 2984
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll k;
  cin>>k;
  ll n=50;
  cout<<n<<endl;
  ll a[n+1]={};
  if(k<n){
    for(int i=0;i<k;i++){
      cout<<n<<" ";
    }
    for(int i=k;i<n-1;i++){
      cout<<0<<" ";
    }
    cout<<0<<endl;
    return 0;
  }


  for(int i=0;i<n;i++){
    a[i]=n-1+(k/n);
  }

  for(int i=0;i<k%n;i++){
    a[i]+=n-k%n+1;
  }

  for(int i=k%n;i<n;i++){
    a[i]-=k%n;
  }


  for(int i=0;i<n-1;i++){
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl;

  return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	string s;
	while(cin >> n >> s) {
		int cnt = 0;
		REP(i, SZ(s)) {
			cnt += (s[i] == 'R');
		}
		if(cnt > SZ(s) - cnt) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

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

    int N = S.length();

    int l, r;
    l=-1; r=-1;
    for (int i = 0; i < N-1; i++) {
        if(S[i] == S[i+1]){
            l = i+1;
            r = i+2;
        }
    }
    for (int i = 0; i < N-2; i++) {
        if(S[i] == S[i+2]){
            l = i+1;
            r = i+3;
        }
    }

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

}

Measured memory_bytes: 3852
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

string S;
int main(int argc, char **argv) {
    cin >> S;
    string res;
    string str[3] = {"Sunny", "Cloudy", "Rainy"};
    for(int i = 0; i < 3; ++i)
        if(S == str[i])
            res = str[(i + 1) % 3];

    cout << res << endl;
}

Measured memory_bytes: 256
import itertools as it

N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
a = -1
b = -1

li = list(it.permutations(P,N))
li.sort()
for n in range(len(li)) :
    l = li[n]
    # print(l)
    is_P = True
    is_Q = True
    for i in range(N) :
        if (P[i] != l[i]) :
            is_P = False
        if (Q[i] != l[i]) :
            is_Q = False
        if (not(is_P) and not(is_Q)) :
            break
    if (is_P) :
        a = n+1
    if (is_Q) :
        b = n+1

# print(a,b)
print(abs(a-b))



Measured memory_bytes: 8052
fun main(args: Array<String>) {
    var k = readLine()!!.toInt()
    var lunlun = mutableListOf<Long>(1, 2, 3, 4, 5, 6, 7, 8, 9)
    var tmpArray = mutableListOf<Long>()
    var q:Long
    var qt:Long
    if (k < 10) {
        println(lunlun[k-1])
    } else {
        k -= 9
        loop@while (true) {
            while (!lunlun.isEmpty()) {
                q = lunlun[0]
                lunlun.removeAt(0)
                qt = q*10
                q %= 10
                when(q) {
                    0L -> {
                        repeat(2){tmpArray.add(qt+it)}
                        k -= 2
                    }
                    9L -> { 
                        repeat(2){tmpArray.add(qt+it+8)}
                        k -= 2
                    }
                    else -> {
                        repeat(3){tmpArray.add(qt+it+q-1)}
                        k -= 3
                    }
                }
                if (k <= 0) {
                    break@loop
                }
            }
            tmpArray.forEach{lunlun.add(it)}
            tmpArray.clear()
        }
        println(tmpArray[tmpArray.size+k-1])
    }
}


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

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

int main(void)
{
    int k,a,b; cin>>k>>a>>b;
    bool ok=false;
    for(a;a<=b;a++){
        if(a%k==0) ok=true;
    }
    if(ok)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3620