akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main() {
    int a = 0;
    int b = 0;
    while (true) {
        cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        if (a > b) {
            cout << b << " " << a << endl;
        } else {
            cout << a << " " << b << endl;
        }
    }
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B;
	set<int> s;
	s.insert(A); s.insert(B);

	rep(x, 1, 4) if (!s.count(x)) {
		cout << x << endl;
		return;
	}
}







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

int main()
{
  string word; cin >> word;
  string s;
  int ans=0;
  while(true){
    // getline(cin, s);
    cin >> s;
    if (s == "END_OF_TEXT") break;
    transform(s.begin(), s.end(), s.begin(), ::tolower);

    // int pos = s.find(word);
    // if (pos != string::npos) ans++;

    if(s == word) ans++;
    // while (pos != string::npos) {
    //   ans++;
    //   pos = s.find(word, pos+1);
    // }

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


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[200010];
  vector<int> b[200010];
  int mx=0;
  repi(i,1,n+1){
    cin>>a[i];
    for(int j=i*2;j<=n;j+=i){
      b[j].push_back(i);
    }
    
  }
  vector<int> ans;
  int aa[200010]={0};
  repn(i,n){
    if(i==0) break;
    if(aa[i]%2 ^ a[i]){
      ans.push_back(i);
      rep(j,b[i].size() ){
	aa[b[i][j]]++;
	aa[b[i][j]]%=2;
      }
    }
  }
  //rep(i,10) cout<<aa[i]<<" ";
  cout<<ans.size()<<endl;
  rep(i,ans.size() ){
    cout<<ans[i];
    if(i!=ans.size() -1) cout<<" ";
  }
  if(ans.size() != 0) cout<<endl;

  return 0;
}

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

int main() {
    int n;
    set< int> st;
    cin >> n;
    while (n--) {
        int a;
        cin >> a;
        if(st.count(a)) st.erase(a);
        else st.insert(a);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int dp[1000001][2][2];
int N;
int solve(int idx, int o, int n) {
    if(idx == N) {
        return o && n;
    }
    if(dp[idx][o][n] != -1)
        return dp[idx][o][n];
    int ans = 0;
    for(int i = 0; i<=9; i++) {
        ans = ans + solve(idx+1, (o || (i == 0) ? 1 : 0), (n || (i == 9)) ? 1 : 0);
        ans %= 1000000007;
    }
    return dp[idx][o][n] = ans;
}
int main() {
    int tc = 1;
    while(tc--) {
        int n;
        cin>>n;        
        N = n;
        memset(dp, -1, sizeof(dp));
        cout<< solve(0, 0, 0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 97368
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
    	
    	if (A < 10) {
	        System.out.println(A);
    		return ;
    	}
    	if (A < 100) {
	        System.out.println(9);
    		return ;
    	}
    	if (A < 1000) {
	        System.out.println(A-10*10+9+1);
    		return ;
    	}
    	if (A < 10000) {
	        System.out.println(10*10*10-10*10+9);
    		return ;
    	}
    	if (A < 100000) {
	        System.out.println(A-10*10*10*10+10*10*10-10*10+9+1);
    		return ;
    	}
	    System.out.println(10*10*10*10*10-10*10*10*10+10*10*10-10*10+9);
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define fi first
#define se second
#define vll vector<int>
#define pii pair<int,int>
#define vvll vector< vector<int> >
#define pb push_back
#define sz(v) (int)(v).size()
#define inf 1e10
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define M 2010
     

int32_t main(){
    IOS;
    
    int n;cin>>n;
    string s;cin>>s;
    int r=0,w=0,ans;
    rep(i,0,n)r+=(s[i]=='R'),w+=(s[i]=='W');
    ans=min(r,w);
    int cnt=0;
    rep(i,0,r)if(s[i]=='W')cnt++;
    cout<<min(ans,cnt);
   	
	
    return 0;
}

Measured memory_bytes: 3776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  int two = 0, four = 0;
  REP(_, n) {
    int a; cin >> a;
    if (a % 4 == 0) {
      ++four;
    } else if (a % 2 == 0) {
      ++two;
    }
  }
  if (four > 0) {
    n -= 2 * (four - 1) + 3;
    if (n > 0) ++n;
  }
  cout << (two >= n ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.BufferedWriter

fun main() = Case().exec(::solve)
fun solve(c: Case) {
    val n = c.long().toInt()

    val mem = mutableListOf<MutableList<ModInt>>()

    // init
    val first = mutableListOf<ModInt>()
    repeat(n + 1) { first.add(ModInt(0)) }
    (3..n).forEach { first[it] = ModInt(1) }
    mem.add(first)

    (2..(n / 3)).forEach {
        val tail = mem.last()
        val list = mutableListOf<ModInt>()
        repeat(n + 1) { list.add(ModInt(0)) }
        var sum = ModInt(0)
        (3..(n - 3)).forEach {
            sum = sum + tail[it]
            list[it + 3] = sum
        }
        mem.add(list)
    }

    c.println(mem.map { it[n] }.reduce { acc, modInt -> acc + modInt }.v.toString())
}

class ModInt(var v: Long) {
    companion object {
        const val MOD = 1000000007L
    }

    override operator fun equals(other: Any?) = other != null && other is ModInt && v == other.v
    override fun hashCode() = v.hashCode()
    override fun toString() = "ModInt($v)"

    operator fun plus(o: ModInt): ModInt = ModInt(v).also { it += o }
    operator fun minus(o: ModInt): ModInt = ModInt(v).also { it -= o }
    operator fun times(o: ModInt): ModInt = ModInt(v).also { it *= o }
    operator fun div(o: ModInt): ModInt = ModInt(v).also { it /= o }

    operator fun plusAssign(o: ModInt) {
        v += o.v; if (v > MOD) v -= MOD
    }

    operator fun minusAssign(o: ModInt) {
        v -= o.v; if (v < 0) v += MOD
    }

    operator fun timesAssign(o: ModInt) {
        v = v * o.v % MOD
    }

    operator fun divAssign(o: ModInt) {
        v = v * o.v.inv() % MOD
    }

    fun inv(): ModInt {
        var (g, x, y, r) = listOf(MOD, 0L, 1L, v)
        while (r != 0L) {
            val q = g / r
            g %= r
            g = r.also { r = g }
            x -= q * y
            x = y.also { y = x }
        }
        return ModInt(if (x < 0) x + MOD else x)
    }
}

class Case(
    private val input: BufferedReader = System.`in`.bufferedReader(),
    private val out: BufferedWriter = System.out.bufferedWriter()
) {
    fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }
    private fun execInThread(fn: (Case) -> Unit) =
        Thread(null, { fn(this) }, "solve", 64 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
            .apply { start() }.join()

    fun println(c: CharSequence?) = out.appendln(c)
    fun string(): String = input.readLine().trimEnd()
    fun long(): Long = input.readLine().toLong()
    fun intList(): List<Int> = input.readLine().split(" ").map { it.toInt() }
    fun longList(): List<Long> = input.readLine().split(" ").map { it.toLong() }
}

Measured memory_bytes: 93972
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};


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

	double d,t,s;
	cin>>d>>t>>s;
	double time = d/s;
	if(t>=time)
		cout<<"Yes";
	else 
		cout<<"No";
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    //入力
    ll N,K; cin >> N >> K;
    ll h[1000100];
    for (ll i = 0;i<N;i++) cin >> h[i];

    //dpテーブル
    ll dp[1000100];
    for (ll i = 0;i<N;i++) dp[i] = INF;

    //初期条件
    dp[0] = 0;

    //遷移
    for (ll i = 0;i<N;i++) {
        for (ll j = 1;j<K+1;j++) {
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

    //答え
    cout << dp[N-1] << endl;

}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<long long> a(5,0);
long long n;

void solve(){
    auto m = *min_element(a.begin(),a.end());
    long long b;
    if(m != 1) b = n/m;
    else b = n-1;
    cout << 5 + b << endl;
}

int main(){
    cin >> n;
    for(int i=0; i<5; i++){
        cin >> a[i];
    }
    solve();
    return 0;
}


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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 double distance(int X1, int X2, int Y1, int Y2) {
   return (double)sqrt((X1 - X2) * (X1 - X2) +  (Y1 - Y2) * (Y1 - Y2));
 }

 int main() {
   int N;
   double ave = 0.0;
   cin >> N;
   vector<int> x(N), y(N), perm(N);
   rep(i, N) perm.at(i) = i;
   rep(i, N) cin >> x.at(i) >> y.at(i);
   int bunbo = 1;
   rep(i, N) bunbo *= (i + 1);

   do {
     rep(i, N - 1) {
       ave += distance(x.at(perm.at(i)), x.at(perm.at(i + 1)), y.at(perm.at(i)), y.at(perm.at(i + 1)));
     }
   } while(next_permutation(perm.begin(), perm.end()));

   cout << fixed << setprecision(7) << (double)(ave / bunbo) << endl;

 }


Measured memory_bytes: 256
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = (int)1e5 + 10;
const ll inf = (ll) 1e18;
int h[N];
ll dp[N];
int n, k;

void solve() {
   for (int i = 1; i <= n; ++i) dp[i] = inf;
   dp[1] = 0;

   for (int i = 2; i <= n; ++i) {
      for (int j = 1; j <= k; ++j) {
         if (i - j > 0) dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
      }
   }
   cout << dp[n] << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n >> k;
   for (int i = 1; i <= n; ++i) cin >> h[i];
   solve();

   return EXIT_SUCCESS;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repri(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;
typedef vector<int> VI;
typedef vector<ll> VL;

void Main() {
	string s;
	cin >> s;
	if (s == "SAT") cout << "1\n";
	else if (s == "FRI") cout << "2\n";
	else if (s == "THU") cout << "3\n";
	else if (s == "WED") cout << "4\n";
	else if (s == "TUE") cout << "5\n";
	else if (s == "MON") cout << "6\n";
	else if (s == "SUN") cout << "7\n";
	return;
}

int main(){
	FAST;
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sonic ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define fi first
#define se second
#define pb push_back
using namespace std;
int main(){sonic
	int T=1;
//	cin>>T;
	while(T--){
		string s;
		cin>>s;
		if(s[0]==s[1]&&s[1]==s[2])cout<<"No\n";
		else cout<<"Yes\n";
	}
}


Measured memory_bytes: 256
# coding: utf-8


if __name__ == '__main__':
  n,k = map(int,input().split())
  a = list(map(int,input().split()))
  s = sorted(a)
  tmp = s[0]
  count = 0 
  dif_a = [1]
  for i in range(1,n):
    if s[i] == tmp:
      dif_a[count] += 1
    else:
      tmp = s[i] 
      count += 1
      dif_a.append(1)

  ds = sorted(dif_a)
  kind = count + 1
  remove = 0
  for i in range(len(ds)-k):
    remove += ds[i]
  print(remove)


Measured memory_bytes: 25716
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  char a[5],b[7],c[5];
  for(int i=0;i<19;i+=1)
  {
    if(i<=4)
    {
     	cout<<s[i];
    }
    if(i==5)
    	cout<<' ';
    if(i>5 && i<=12)
      	cout<<s[i];
    if(i==13)
      	cout<<' ';
    else if(i>13)
      cout<<s[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[200005],q,sum;
deque<int>deq;
int main(){
	cin>>n;
	repn(i,n-1){
		cin>>a[i];
		if(i>=3) sum+=a[i];
	}
	for(int i=0;i<=1000005;i++) deq.pb(i);
	for(int i=3;i<n;i++){
		repn(t,a[i]){
			deq.push_front(deq[2*t-1]);
		}
		repn(t,a[i]){
			deq.pop_back();
		}
	}
	scanf("%d",&q);
	rep(i,q){
		int v; scanf("%d",&v);
		if(v>1000005){
			printf("%d\n",v-sum+a[1]-a[2]);
		}
		else{
			printf("%d\n",deq[v]+a[1]-a[2]);
		}
	}
}

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

/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______
 * |\  \|\  \  |\  ___ \  |\  ___ \
 * \ \  \/  /|_\ \   __/| \ \   __/|
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

const int mxN = 110;

vector<int> tree[mxN];
int par[mxN][20];
int h[mxN];

pair<int,int> up(pair<int,int> c) {return {c.first+1,c.second};}

pair<int,int> di(int v,int p = -1) {
	pair<int,int> res = {1,v};
	for(auto u : tree[v]) if(p != u) res = max(res,up(di(u,v)));
	return res;
}

void dfs(int v = 0,int p = -1){
	h[v] = (p==-1?0:h[p]+1);
	par[v][0] = p;
	for(int i = 1;par[v][i-1] != -1;i++)
		par[v][i] = par[par[v][i-1]][i-1];
	for(auto u : tree[v]){
		if(u != p)
			dfs(u,v);
	}
}
int lca(int u,int v){
	if(h[u] > h[v])
		swap(u,v);
	for(int i = 19;i >= 0;i--){
		if(par[v][i] != -1 && h[par[v][i]] >= h[u])v = par[v][i];
	}
	if(u == v)return u;
	for(int i = 19;i >= 0;i--){
		if(par[v][i] != par[u][i])v = par[v][i],u = par[u][i];
	}
	return par[v][0];
}

int dst(int u,int v) {
	return h[u] + h[v] - 2 * h[lca(u,v)] + 1;
}

size_t mx[mxN];
void get(int u,int p = -1,int at = 0) {
	for(auto v : tree[u]) if(v != p) get(v,u,at+1);
	mx[at] = max(mx[at],tree[u].size() - (p != -1));
}

int N;
long long solve(int d, bool f = 0) {
	int u,v;
	u = di(0).second;
	v = di(u).second;
	memset(par,-1,sizeof par);
	dfs();
	if(d != dst(u,v) && !f) return LLONG_MAX;
	if(!f) for(int i = 0;i < N;i++) {
		if(dst(u,i)<<1 == d + 1 && dst(v,i)<<1 == d + 1) {
			memset(mx,0,sizeof mx);
			long long res = 1;
			get(i);
			for(int j = 0;j * 2 + 2 < d;j++) res *= mx[j];
			return res;
		}
	}
	assert(!(d&1));
	long long res = LLONG_MAX;
	for(int i = 0;i <= N;i++) {
		if(f) if(dst(u,i)<<1 != d || dst(v,i)<<1 != d) continue;
		for(auto j : tree[i]) {
			int a = di(i,j).first;
			if(a*2 == d) {
				memset(mx,0,sizeof mx);
				long long cur = 1;
				get(i,j);
				get(j,i);
				for(int at = 0;at * 2 + 2 < d;at++) cur *= mx[at];
				res = min(res,2*cur);
			}
		}
	}
	return res;
}

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

	int u,v;
	cin>>N;
	for(int i = 1;i < N;i++) {
		cin>>u>>v;
		u--,v--;
		tree[u].push_back(v);
		tree[v].push_back(u);
	}
	u = di(0).second;
	v = di(u).second;
	memset(par,-1,sizeof par);
	dfs();
	int d = dst(u,v);
	long long res = solve(d);
	cerr<<(d+1)/2<<' '<<(d+2)/2<<'\n';
	if((d+1)/2 == (d+2)/2) res = min(res,solve(d+1,1));
//	cerr<<solve(d)<<' '<<solve(d+1,1)<<'\n';
	cout<<(d+1)/2<<' '<<res<<'\n';
	return 0;
}


Measured memory_bytes: 384
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())
    K = int(input())

    ans = 0
    if len(S) == 1:
        return K // 2
    
    if len(set(S)) == 1:
        return len(S) * K // 2
    
    l, r = 0, 0
    if S[0] == S[-1]:
        while len(set(S[0:l+1])) <= 1:
            l += 1
        while len(set(S[-r-1:])) <= 1:
            r += 1
    
    cnt = 0
    T = S[0]
    for s in S[1:]:
        if s == T[-1]:
            cnt += 1
            T += '_'
        else:
            T += s
    
    ans = cnt * K
    if max(l, r) >= 1:
        ans -= (l//2 + r//2 - (l+r)//2) * (K-1)
    
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll  INF = ll(1e18)+5;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    if(a[0] +1 <a.back()){
        cout <<"No" << endl;
        return 0;
    }
    if(a[0] == a.back()){
        if(a[0] == N-1 || a[0] <=N/2){
            cout <<"Yes" << endl;
            return 0;
        }
        cout <<"No" << endl;
        return 0;        
    }
    ll repeated =0;
    for(int i=1;i<N;i++){
        if(a[i] == a[0]){
            repeated++;
        }
    }

    
    if((a[0]-repeated) * 2 <= N-repeated-1 && a[0]>repeated && repeated+1<N-1){
        cout <<"Yes" << endl;
        return 0;
    }
    
    cout <<"No" << endl;

    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int ans = max(60*h2 + m2 - (60*h1 + m1) - k,0);

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cmath>

#define N 10000

using namespace std;

bool Primality(int);

int main(){
	int n, a[N];
	int count = 0;
	
	cin >> n;
	for(int i = 0;i < n;++i) cin >> a[i];
	for(int i = 0;i < n;++i) 
		if(Primality(a[i]))++count;
	cout << count << endl;
	
	return 0;
}

bool Primality(int x){
	if(x < 2)return false;
	else if(x == 2)return true;
	else if(x % 2 == 0) return false;
	for(int i = 3;i <= sqrt(x);++i)
		if(x % i == 0)return false;
	return true;
}


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

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int a;
	string s;
	cin >> a;
	cin >> s;
	if(a>3199){
		cout <<s<<endl;
	}
	else{
		cout <<"red"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int n, k;
  cin >> n >> k;
  
  //vector<int> a(n);  rep(i, 0, n) cin >> a[i];
  
  int x = pow(k-1, n-1)*k;
  cout << x << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << pow(k-1, n-1)*k << "\n";

}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, m, k;
int a[N], b[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> k;
	for(int i=1; i<=n; i++) {
		cin >> a[i];
		a[i] += a[i-1];
	}
	for(int i=1; i<=m; i++) {
		cin >> b[i];
		b[i] += b[i-1];
	}
	int ans = 0;
	for(int i=0; i<=n; i++){
		int r = k - a[i];
		if (r < 0) break;
		int idx = upper_bound(b, b+m+1, r) - b;
		ans = max(ans, i+idx-1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6744
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <climits>
#include <queue>

using namespace std;

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << max(max(a*10+b+c, a+b*10+c),a+b+c*10) << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main(){
    int a;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i<3; i++) {
        scanf("%d", &a);
        if (a==5) {
            cnt1++;
        }
        if (a==7) {
            cnt2++;
        }
    }
    if (cnt1==2 && cnt2==1) {
        printf("YES\n");
    }
    else
        printf("NO\n");
}

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

int main()
{	
	int t=1;
	//cin>>t;
	while(t--){
        int a,b;
		cin>>a>>b;
		if(2*b>=a){
			cout<<0<<endl;
		}
		else{
			cout<<a-2*b<<endl;
		}
		
	}
	//chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
	//chrono::high_resolution_clock::time_point t2 = chrono::high_resolution_clock::now();
	//chrono::duration<double> time_span = (t2 - t1);
	//cout<<time_span.count()<<" Seconds"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;


int main() {
	string s, t; cin >> s >> t;
	int n = s.size();
	map<char, char> mp1, mp2;
	for (int i = 0; i < n; i++) mp1[s[i]] = t[i], mp2[t[i]] = s[i];
	for (int i = 0; i < n; i++) {
		if (mp1[s[i]] != t[i] || mp2[t[i]] != s[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main(){
	array<int,26> a;
	a.fill(0);
	int N,K;
	cin>>N>>K;
	for(int i=0;i<N;++i){
		string str;
		cin>>str;
		++a[str.front()-'A'];
	}

	sort(begin(a),end(a),[](int x,int y)->bool{return x>y;});
	int ans=0;
	while(1){
		bool flag=false;
		for(int i=0;i<K;++i){
			if(a[i]>0)--a[i];
			else{
				flag=true;
				break;
			}
		}
		if(flag)break;
		else ++ans;
		sort(begin(a),end(a),[](int x,int y)->bool{return x>y;});
	}

	cout<<ans<<endl;
//	system("pause");
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int l,r;
		cin >> l >> r;
		sum += (r - l + 1);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split(' '))
A_list = []
count = 0
for i in range(K):
    di = int(input())
    Ai = list(map(int,input().split(' ')))
    [A_list.append(A) for A in Ai]
set_a = set(A_list)
count = N - len(set_a)
print(count)

Measured memory_bytes: 68820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios::sync_with_stdio(0);	
	cin.tie(0);
	int s,w;
  	cin>>s>>w;
  	if(w>=s)
    {
      cout<<"unsafe";
    }
  else
  {
    cout<<"safe";
  }
	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main(){
  int a,b;
  int ans = 0;
  int count = 0;
  while(cin>>a>>b){
  ans = a + b;
  while(ans!=0){
    ans = ans / 10;
    count++;
  }
  cout << count << endl;
  count = 0;  
}
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll A, B;

    cin >> A >> B;

    cout << max({A + B, A - B, A * B}) << endl;

    return 0;
}

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

#define N (1<<18)
#define ll long long
#define ld long double
#define M 1000000007
#define INF 0x5ADFACE5
#define LINF 0x51DEEFFEC7C0DECALL
#define pii pair<int, int>
#define pll pair<long long, long long>
#define F first
#define S second

using namespace std;

char v[1000][1000];
int b[1000][1000];

int main() {
	int n, m, k;
	cin>>n>>m>>k;
	int cy;
	int cx;
	for (int y = 1; y <= n; y++) {
		for (int x = 1; x <= m; x++) {
			cin>>v[y][x];
			if (v[y][x] == 'S') {
				v[y][x] = '.';
				cy = y;
				cx = x;
			}
		}
	}
	priority_queue<pair<pii, pii>> q;
	q.push({{0, -k}, {cy, cx}});
	int ans = INF;
	while (!q.empty()) {
		int i = -q.top().F.F;
		int l = q.top().F.S;
		if (i % k == 0) {
			l += k;
		}
		int y = q.top().S.F;
		int x = q.top().S.S;
		q.pop();
		if (y == 1 || x == 1 || y == n || x == m) {
			ans = min(ans, i);
			continue;
		}
		if (b[y][x]) continue;
		b[y][x] = i;

		if (l) {
			if (v[y + 1][x] == '#') q.push({{-(i + 1), l - 1}, {y + 1, x}});
			else q.push({{-(i + 1), l}, {y + 1, x}});

			if (v[y - 1][x] == '#') q.push({{-(i + 1), l - 1}, {y - 1, x}});
			else q.push({{-(i + 1), l}, {y - 1, x}});

			if (v[y][x + 1] == '#') q.push({{-(i + 1), l - 1}, {y, x + 1}});
			else q.push({{-(i + 1), l}, {y, x + 1}});

			if (v[y][x - 1] == '#') q.push({{-(i + 1), l - 1}, {y, x - 1}});
			else q.push({{-(i + 1), l}, {y, x - 1}});
		} else {
			int w = i / k * k + k + 1;
			if (v[y + 1][x] == '#') q.push({{-w, k - 1}, {y + 1, x}});
			else q.push({{-(i + 1), l}, {y + 1, x}});

			if (v[y - 1][x] == '#') q.push({{-w, k - 1}, {y - 1, x}});
			else q.push({{-(i + 1), l}, {y - 1, x}});

			if (v[y][x + 1] == '#') q.push({{-w, k - 1}, {y, x + 1}});
			else q.push({{-(i + 1), l}, {y, x + 1}});

			if (v[y][x - 1] == '#') q.push({{-w, k - 1}, {y, x - 1}});
			else q.push({{-(i + 1), l}, {y, x - 1}});
		}
	}
	if (ans % k == 0) cout<<ans / k<<endl;
	else cout<<ans / k + 1<<endl;
}

Measured memory_bytes: 22504
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;



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

	int N, M;
	cin >> N >> M;

	int K;
	int A[100] = { 0 };

	int a;
	rep(i, 0, N)
	{
		cin >> K;
		rep(j, 0, K)
		{
			cin >> a;
			A[a]++;
		}
	}

	int ans = 0;
	rep(i, 0, 100)
	{
		if (A[i] == N)
		{
			ans++;
		}
	}

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

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

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

    vector<int> xB(10);
    for (int i=0; i<10; i++) {
        xB[i] = 10*B+i;
    }

    int ans = -1;
    vector<int> xA(12);
    if (A%2 == 0) {
        for (int i=0; i<12; i++) {
            xA[i] = 100*A/8+i;
        }
        xA.push_back(100*A/8+12);
        for (int i=0; i<10; i++) {
            for (int j=0; j<13; j++) {
                if (xA[j] == xB[i]) {
                    ans = xB[i];
                    cout << ans << endl;
                    exit(0);
                }
            }
        }
    }

    if (A%2 != 0) {
        for (int i=0; i<12; i++) {
            xA[i] = (100*(A+1)-96)/8+i;
        }

        for (int i=0; i<10; i++) {
            for (int j=0; j<12; j++) {
                if (xA[j] == xB[i]) {
                    ans = xB[i];
                    cout << ans << endl;
                    exit(0);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
int main()
{
		int a, b,c;
		scanf("%d%d%d", &a,&b,&c);
		if (a < b && b < c)printf("Yes\n");
		else printf("No\n");
	return 0;
}



Measured memory_bytes: 2032
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

long long int data[3000][3000]={0};

long long int combination(long long int n, long long int r)
{
    if (r == 0 || r == n){
      data[n][r]=1;
        return (1);
    }
    else if (r == 1){
      data[n][r]=n;
        return (n);
    }
  if(data[n-1][r-1]==0&&data[n-1][r]==0){
    data[n-1][r-1]=combination(n - 1, r - 1)%1000000007;
    data[n-1][r]=combination(n - 1, r)%1000000007;
    return (data[n-1][r-1]+data[n-1][r]);
  }
  else if(data[n-1][r-1]!=0&&data[n-1][r]==0){
    data[n-1][r]=combination(n-1,r)%1000000007;
    return(data[n-1][r-1]+ data[n - 1][r]);
  }
  else if(data[n-1][r-1]==0&&data[n-1][r]!=0){
    data[n-1][r-1]=combination(n-1,r-1)%1000000007;
    return(data[n-1][r]+ data[n - 1][r-1]);
  }
  else{
    return data[n-1][r]+data[n-1][r-1];
  }
    
}



int main (void)
{
	long long int n,i,s,tem,k,max,j=1,count=0;
scanf("%lld",&s);
  for(i=1;s-3*i>=0;i++){
    tem=s-3*i;
    count+=combination(tem+i-1, i-1);
    count=count%1000000007;
  }
  
  printf("%lld\n",count);
return 0;
}


Measured memory_bytes: 14952
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll x, y;
  cin >> x >> y;
  
  cout << x + y / 2 << endl;

  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
char a[1200][1200],b[120][120];
int n,m;
int mark=1;
int main() {
	cin>>n>>m;
    for(int i=0;i<n;i++) {
    	scanf("%s",a[i]);
    }
     for(int i=0;i<m;i++) {
    	scanf("%s",b[i]);
     }
    for(int i=0;i<n;i++) {
         for(int j=0;j<n;j++) {
             if(a[i][j]==b[0][0]) {
                mark=0;
                 for(int x=0;x<m;x++) {
                     for(int y=0;y<m;y++) {
                         if(a[i+x][j+y]!=b[x][y]) {
                             mark=1;
                             break;
                         }
                     }
                 }
             }
             if(mark==0) {
                 printf("Yes");
                 return 0;
             }
         }
     }
     printf("No");
     return 0;
}

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

long long int L[87];

long long int make_lucas(int i){
    if(L[i]==0){
        L[i]=make_lucas(i-1)+make_lucas(i-2);
    }
    return L[i];
}

int main(){
    int n;

    for(int i=0; i<88; i++){
        L[i]=0;
    }
    cin>>n;
    L[0]=2;
    L[1]=1;
    int dum=make_lucas(87);
    cout<<L[n]<<endl;

    return 0;
}



Measured memory_bytes: 384
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Collections;
using System.Threading.Tasks.Dataflow;
using System.Runtime.InteropServices.ComTypes;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine().Trim());
    static int[] ReadInts => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine().Trim());
    static long[] ReadLongs => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    const int mod = 1000000007;
    public static int Mod(int a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion

    static void Main()
    {
        long N = ReadLong;
        long[] As = ReadLongs;

        long ans = 0;
        long cur = As[0];

        for (int i = 1; i < N; i++)
        {
            if (As[i] >= cur)
            {
                cur = As[i];
            }
            else
            {
                ans += cur - As[i];
            }
        }
        WriteLine(ans);
    }
}



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    constexpr int MX_V = 1000000;
    int cp[MX_V + 1] = {};
    Vi ps;
    for (ll i = 2; i <= MX_V; i++) {
        if (cp[i] == 0) {
            ps.emplace_back(i);
            cp[i] = i;
        }
        for (ll j = 0; j < (ll)ps.size() && ps[j] <= cp[i] && i * ps[j] <= MX_V; j++) {
            cp[i * ps[j]] = ps[j];
        }
    }

    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    int ns[MX_V + 1];
    for (ll i = 0; i <= MX_V; i++) {
        ns[i] = 0;
    }

    set<int> st;
    for (ll i = 0; i < N; i++) {
        st.clear();
        int t = A[i];
        while (t > 1) {
            ll q = cp[t];
            if (q > 1) {
                st.emplace(q);
            }
            t /= q;
        }
        for (auto x : st) {
            ++ns[x];
        }
    }

    ll mx = 0;
    for (ll i = 0; i < MX_V; i++) {
        chmax(mx, ns[i]);
    }

    if (mx <= 1) {
        prints()("pairwise coprime");
    }
    else if (mx < N) {
        prints()("setwise coprime");
    }
    else {
        prints()("not coprime");
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 19272
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<cstring>
#include<string>
#define MAX_N 100
#define MAX_K 100
using namespace std;

int N,K;
int d[MAX_K];
int a[MAX_N];
set<int>A;

int main()
{
    int a;
    cin >> N >> K;
    for(int i=0;i<K;i++){
        cin >> d[i];
        for(int j=0;j<d[i];j++){
            cin >> a;
            A.insert(a);
        }
    }
    cout << N - A.size();

    
    return 0;
}

Measured memory_bytes: 3164
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);

        int min = 1_000_000_000;
        for (int p = 1; p <= 100; p++) {
            int tmp = 0;
            for (int i = 0; i < N; i++) {
                tmp += (X[i]-p)*(X[i]-p);
            }
            min = Math.min(min, tmp);
        }

        System.out.println(min);
    }
}



Measured memory_bytes: 23252
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N; std::cin >> N;
    std::vector<int> cnt(N+1, 0);
    for(int x(1); x*x <= N; ++x){
        for(int y(1); x*x + y*y <= N; ++y){
            for(int z(1); x*x + y*y + z*z <= N; ++z){
                int a(x*x + y*y + z*z + x*y + y*z + z*x);
                if(a > N) break;
                ++cnt[a];
            }
        }
    }
    for(int i(1); i <= N; ++i){
        std::cout << cnt[i] << "\n";
    }
    return 0;
}


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

using namespace std;

int a[555][555], b[555][555], c[555][555];
int main() {
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 0; i < m; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		a[l][r]++;
	}
	for (int l = 1; l <= n; l++)
		for (int r = l; r <= n; r++)
			b[l][r] = b[l][r - 1] + a[l][r];
	for (int r = 1; r <= n; r++)
		for (int l = r + 1; --l;)
			c[l][r] = c[l + 1][r] + b[l][r];
	for (int i = 0; i < q; i++) {
		int p, q;
		scanf("%d%d", &p, &q);
		cout << c[p][q] << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
 
int main(){
    int t,i=0,j,d[100],n,c,m;
    scanf("%d",&n);
    while(i!=n){
        scanf("%d",&d[i]);
        i++;
    }
 
    for(i=0,c=0;i<=n-1;i++){
        m = i;
        for(j=i;j<=n-1;j++){
            if(d[j] < d[m]){
                m = j;
            }
        }
        if(d[i] != d[m])c++;
        t = d[i];
        d[i] = d[m];
        d[m] = t;
    }
    for(i=0;i<=n-1;i++){
        i <n-1 ? printf("%d ",d[i]):printf("%d\n",d[i]);
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 600