akhauriyash/Code-Regression huggingface dataset:
/*#include<bits/stdc++.h>
#define ll long long
using namespace std;
void o
void ins(int x,int l,int r,int t,int k,int w){
	if(l==t&&r==k){
		f[x]+=w;
		g[x]+=w;
		return;
	}
	pushdown(x);
	int mid=(l+r)/2;
	if(mid>=k)ins(x*2,l,mid,t,k,w);
	 else if(t>mid)ins(x*2+1,mid+1,r,mid+1,k,w);
	  else ins(x*2,l,mid,t,mid),ins(x*2+1,mid+1,r,mid+1,k);
	f[x]=min(f[x*2],f[x*2+1]);
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s0[i]=s0[i-1];s1[i]=s1[i-1];
		if(a[i])s1[i]++;
		 else s0[i]++;
	}
	scanf("%d",&m);
	for(i=1;i<=m;i++)scanf("%d%d",&b[i].x,&b[i].y);
	sort(b+1,b+m+1);
	for(i=1;i<=m;i++)zh[b[i].x].push_back(b[i].y);
	memset(f,44,sizeof(f));
	ins(1,0,n,0,0);
	for(i=1;i<=n;i++){
		for(j=0;j<zh[i].size();j++)ins(1,0,n,zh[i][j],query(1,0,n,0,zh[i][j]));
		if(a[i]==1)ins(1,0,n,0,i-1,1);
		 else ins(1,0,n,0,i-1,-1);
	}
	printf("%d",query(1,0,n,0,n)+s0[n]);
}*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

const int N=200005;
const int inf=1000000000;

int n,m,s1[N],s0[N];
struct tree{int mn,tag;}t[N*5];
vector<int> vec[N];
pair<int,int> a[N];

int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

void pushdown(int d,int l,int r)
{
    if (!t[d].tag||l==r) return;
    int w=t[d].tag;t[d].tag=0;
    t[d*2].tag+=w;t[d*2+1].tag+=w;
    t[d*2].mn+=w;t[d*2+1].mn+=w;
}

void ins(int d,int l,int r,int x,int y)
{
    pushdown(d,l,r);
    if (l==r) {t[d].mn=min(t[d].mn,y);return;}
    int mid=(l+r)/2;
    if (x<=mid) ins(d*2,l,mid,x,y);
    else ins(d*2+1,mid+1,r,x,y);
    t[d].mn=min(t[d*2].mn,t[d*2+1].mn);
}

void modify(int d,int l,int r,int x,int y,int z)
{
    if (x>y) return;
    pushdown(d,l,r);
    if (l==x&&r==y) {t[d].tag+=z;t[d].mn+=z;return;}
    int mid=(l+r)/2;
    modify(d*2,l,mid,x,min(y,mid),z);
    modify(d*2+1,mid+1,r,max(x,mid+1),y,z);
    t[d].mn=min(t[d*2].mn,t[d*2+1].mn);
}

int query(int d,int l,int r,int x,int y)
{
    if (x>y) return inf;
    pushdown(d,l,r);
    if (l==x&&r==y) return t[d].mn;
    int mid=(l+r)/2;
    return min(query(d*2,l,mid,x,min(y,mid)),query(d*2+1,mid+1,r,max(x,mid+1),y));
}

int main()
{
    n=read();
    for (int i=1;i<=n;i++)
    {
        s0[i]=s0[i-1];s1[i]=s1[i-1];
        int x=read();
        if (!x) s0[i]++;
        else s1[i]++;
    }
    m=read();
    for (int i=1;i<=m;i++) a[i].first=read(),a[i].second=read();
    sort(a+1,a+m+1);
    for (int i=1;i<=m;i++) vec[a[i].first].push_back(a[i].second);
    for (int i=1;i<=n*4+4;i++) t[i].mn=inf;
    ins(1,0,n,0,0);
    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<vec[i].size();j++) ins(1,0,n,vec[i][j],query(1,0,n,0,vec[i][j]));
        if (s1[i]-s1[i-1]) modify(1,0,n,0,i-1,1);
        else modify(1,0,n,0,i-1,-1);
    }
    printf("%d",query(1,0,n,0,n)+s0[n]);
    return 0;
}

Measured memory_bytes: 21888
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main(){
  string s;
//  int count = 1;
  bool flag1 = true,flag2 = true;
  cin >> s;
  for(int i=0;i<s.size();i++) {
    int j = i+1;
    if(j%2){
      if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') flag1 = false;
    }else{
      if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') flag2 = false;
    }
  }
  if(flag1 & flag2) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n;
  cin>>n;
  set<string> s;
  rep(i,n){
    string t;
    cin>>t;
    s.insert(t);
  }
  out(s.size());
}

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


Measured memory_bytes: 19240
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let a = (0..n).map(|_| it.next().unwrap().parse::<i32>().unwrap()).collect::<Vec<_>>();
    let b = a.iter().max().unwrap();
    let c = a.iter().max_by_key(|&&x| (std::cmp::min(x, b-x), -x)).unwrap();
    println!("{} {}", b, c);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iomanip>    // setw 控制输出间隔函数
#include <iostream>   // cin, cout, abs
#include <algorithm>  // max, min, swap, sort
#include <cmath>      // pow
#include <cstring>    // strlen, memset
#include <set>        // set 集合
#include <stack>      // stack 栈
#include <queue>      // queue 队列
#include <string>     // string 字(yang)符(rou)串, substr
#include <map>
#include <fstream>
using namespace std;
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    printf("%d\n", ( n - 1) * ( m - 1));
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template <int COL_SIZE> class mat {
private:
    // (or, and) の意味での積(正方かつ対称行列に限る(重みなし無向グラフの隣接行列とか))
    mat operator*(const mat& m) const {
        mat ans;
        for(int i = 0; i < COL_SIZE; i++){
            for(int j = 0; j < COL_SIZE; j++){
                if(this->a[i][j] == 0) continue;
                ans.a[i] |= m.a[j];
            }
        }
        return ans;
    }
    
public:
    bitset<COL_SIZE>* a;
    int r;
    // 正方行列の場合
    mat(){ a = new bitset<COL_SIZE>[COL_SIZE]; }
    // 一般の行列の場合
    mat(int row_size) : r(row_size){ a = new bitset<COL_SIZE>[r]; }
    int rank() const {
        int res = 0;
        mat<COL_SIZE> b(r);
        for(int i = 0; i < r; i++) b[i] = a[i];
        for(int i = 0; i < COL_SIZE; i++){
            if(res == r) return res;
            int pivot = res;
            if(!b[pivot][i]){
                for(int j = res + 1; j < r; j++){
                    if(b[j][i]){
                        pivot = j;
                        break;
                    }
                }
                if(!b[pivot][i]) continue;
                swap(b[pivot], b[res]);
            }
            for(int j = res + 1; j < r; j++){
                if(b[j][i]) b[j] ^= b[res];
            }
            res++;
        }
        return res;
    }
    inline const bitset<COL_SIZE>& operator[](size_t index) const {
        return a[index];
    }
    inline bitset<COL_SIZE>& operator[](size_t index){
        return a[index];
    }
    friend mat pow(mat m, long long cnt){
        mat res;
        for(int i = 0; i < COL_SIZE; i++) res[i][i] = 1;
        while(cnt){
            if(cnt & 1){
                res = res * m;
            }
            m = m * m;
            cnt >>= 1;
        }
        return res;
    }
};
ll mod = 998244353;
ll mod_pow(ll a, ll b){
    if(b==0)return 1;
    if(b==1)return a;
    ll res = mod_pow(a,b/2);
    res = res * res % mod;
    if(b%2)res = res * a % mod;
    return res;
}
int main(){
    int n,m;
    cin >> n >> m;
    mat<300>a(n);
    rep(i,n){
        rep(j,m){
            int x;
            cin >> x;
            a[i][j] = x;
        }
    }
    int r = a.rank();
    cerr << r << endl;
    cout << (mod_pow(2,n+m-1) - mod_pow(2,n+m-r-1) + mod ) % mod << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0);
		else sum+=i;
	}
	cout<<sum;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define debug(n) cerr << "[" << #n << " = " << n << "]" << '\n'
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, (b)<(e)?1:-1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define lp(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define each(x, a) for (auto &x: a)
#define pb push_back
template<class A> void read(vector <A>& v);
template<class A, size_t S> void read(array <A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vector<A>& x) {
    each(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    each(a, x)
        read(a);
}

const int di[8] = {0 , 0 , 1 , -1 , 1 , 1 , -1 , -1};
const int dj[8] = {1 , -1 , 0 , 0 , 1 , -1 , 1 , -1};

void Suhaib_Sawalha (){

    string s;
    read(s);
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
// int _;cin>>_;for(int i=1;i<=_;++i,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 3652
use text_io::*;
use std::process::exit;

fn main(){
    let mut a:usize = read!();
    let mut b:String = read!();
    let mut v:Vec<char> = b.chars().collect();
    if v.len()<=a {
        println!("{}",b);
    }
    else {
        let mut c:String = String::new();
        for i in 0..a {
            c += &*v[i].to_string();
        }
        println!("{}...",c);
    }
}

Measured memory_bytes: 2152
import java.io.*;
import java.util.*;


public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));       
		try {
			String line;
			while(true){
				/* input */
				line = br.readLine();
				int c = Integer.parseInt(line.split("[ \t]")[0]), r = Integer.parseInt(line.split("[ \t]")[1]);
				if(c==0&&r==0){
					return;
				}
				int[] robot = new int[3];
				
				//first and second index indicates the current position
				robot[0] = 1;
				robot[1] = 1;
				//third index shows direction: 0:north, 1:east, 2:south, 3:west
				robot[2] = 0;
				/* commands */
				while(true){
					line = br.readLine();
					if(line.indexOf("STOP") > -1){
						break;
					} else if(line.indexOf("RIGHT") > -1){
						robot[2] = (robot[2] + 1) % 4; 
					} else if(line.indexOf("LEFT") > -1){
						robot[2] = (robot[2] + 3) % 4; 
					} else {
						String com = line.split(" ")[0];
						int n = Integer.parseInt(line.split("[ \t]")[1]);
						if(com.indexOf("FORWARD") > -1){
							switch(robot[2]){
							case 0:
								robot[1] += n;
								if(robot[1] > r) robot[1] = r;
								break;
							case 1:
								robot[0] += n;
								if(robot[0] > c) robot[0] = c;
								break;
							case 2:
								robot[1] -= n;
								if(robot[1] < 1) robot[1] = 1;
								break;
							case 3:
								robot[0] -= n;
								if(robot[0] < 1) robot[0] = 1;
								break;
							}
						}
						if(com.indexOf("BACKWARD") > -1){
							switch(robot[2]){
							case 0:
								robot[1] -= n;
								if(robot[1] < 1) robot[1] = 1;
								break;
							case 1:
								robot[0] -= n;
								if(robot[0] < 1) robot[0] = 1;
								break;
							case 2:
								robot[1] += n;
								if(robot[1] > r) robot[1] = r;
								break;
							case 3:
								robot[0] += n;
								if(robot[0] > c) robot[0] = c;
								break;
							}
						}
					}
				}
				
				
				/* output */
				System.out.println(robot[0] + " " + robot[1]);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24856
from numpy import *

N = int(input())

l = zeros((10, 10), dtype=int)

for i in range(N):
    a = int( str(i + 1)[0] )
    b = int( str(i + 1)[-1] )
    l[a][b] += 1

count = 0
for i in range(1, 10):
    for j in range(1, 10):
        count += l[i][j] * l[j][i]


print(count)

Measured memory_bytes: 12500
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << max(A, B) + max(min(A, B), max(A, B) - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    string s;
    cin >> s;
    for(int i = s.length() - 2; i >= 0; i-=2){
        string s1 = s.substr(0, i/2), s2 = s.substr(i/2, i/2);
        if(s1 == s2){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   string s,t;
   cin>>s>>t;
   t+=s;
   cout<<t<<endl;
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val graph = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to M) {
    val a, b = in.next().toInt
    graph(a) = b :: graph(a)
  }

  def mkAns(now: Int, lst: List[Int]): List[Int] = {
    lst match {
      case a :: rest =>
        if (a == now)
          List(a)
        else
          a :: mkAns(now, rest)
    }
  }

  //
  val done = new Array[Boolean](N+1)
  var ans: List[Int] = Nil
  breakable {
    for (i <- 1 to N) {
      if (!done(i)) {
        done(i) = true

        val q = new Queue[(Int, List[Int])]
        //val dp = new Array[Boolean](N+1)
        //dp(i) = true
        q.enqueue((i, List()))

        breakable {
          while (!q.isEmpty) {
            val (now, alr) = q.dequeue()
            if (!done(now))
              done(now) = true

            if (alr.contains(now)) {
              ans = mkAns(now, alr)
              break
            }
            else {
              for (e <- graph(now))
                q.enqueue((e, now :: alr))
            }
          }
        }
      }

      if (ans != Nil)
        break
    }
  }

  if (ans == Nil)
    pw.println(-1)
  else {
    pw.println(ans.length)
    ans.foreach { x => pw.println(x) }
  }
  pw.flush()
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 30580
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => { trace!(($($args),*)) }
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut state = vec![0, 0, 0, 0];
    for _ in 0..n {
        let a: usize = sc.cin();
        state[a] += 1;
    }
    trace!(state);

    let mut e = vec![vec![vec![0.0f64; 301]; 301]; 301];  // [c1][c2][c3]
    // e[0][0][0] = 0.0;
    for c3 in 0..(n+1) {
        for c2 in 0..(n+1) {
            for c1 in 0..(n+1) {
                if c1 + c2 + c3 > n || c1 + c2 + c3 == 0 {
                    continue;
                }
                let rhs =
                    n as f64
                    + if c1 > 0 { e[c1-1][c2][c3] * c1 as f64 } else { 0.0 }
                    + if c2 > 0 { e[c1+1][c2-1][c3] * c2 as f64 } else { 0.0 }
                    + if c3 > 0 { e[c1][c2+1][c3-1] * c3 as f64 } else { 0.0 }
                ;
                e[c1][c2][c3] = rhs / (c1 + c2 + c3) as f64;
            }
        }
    }

    put!(e[state[1]][state[2]][state[3]]);

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


Measured memory_bytes: 237820
#include<bits/stdc++.h>
using namespace std;
#define MAXN	200005
#define MAXC	26
#define MAXLOG	105
#define INF	1e18
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
long long cnt[MAXLOG][MAXC];
long long sum[MAXLOG];
long long ans[MAXC], bns[MAXC];
long long n, l, r, m;
char s[MAXN];
void init() {
	static int next[MAXN];
	for (int i = 2; i <= n; i++) {
		int j = next[i - 1];
		while (j && s[j + 1] != s[i]) j = next[j];
		if (s[j + 1] == s[i]) j++;
		next[i] = j;
	}
	for (int i = next[n] + 1; i <= n; i++)
		cnt[1][s[i] - 'a']++;
	m = 1;
	sum[0] = n;
	for (int i = 1; i <= n; i++)
		cnt[0][s[i] - 'a']++;
	sum[1] = n + n - next[n];
	for (int i = 0; i < 26; i++)
		cnt[1][i] += cnt[0][i];
	while (sum[m] + sum[m - 1] <= INF) {
		m++; sum[m] = sum[m - 1] + sum[m - 2];
		for (int i = 0; i < 26; i++)
			cnt[m][i] = cnt[m - 1][i] + cnt[m - 2][i];
	}
}
void calc(long long total, long long *ans) {
	for (int i = m; i >= 0; i--) {
		if (total < sum[i]) continue;
		total -= sum[i];
		for (int j = 0; j < 26; j++)
			ans[j] += cnt[i][j];
	}
	for (int i = 1; i <= total; i++)
		ans[s[i] - 'a']++;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1) / 2;
	read(l), read(r);
	init();
	calc(r, ans);
	calc(l - 1, bns);
	for (int i = 0; i < 26; i++)
		printf("%lld ", ans[i] - bns[i]);
	return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll a,b,k;
	cin >>a >>b >>k;
	
	if(a>=k){
		printf("%lld %lld\n", a-k, b); return 0;
	}
	if(k>= a+b){ printf("%lld %lld\n", 0, 0); return 0; }
		printf("%lld %lld\n", 0, b+a-k); return 0;
	
}



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

int main() {
  int N;
  cin >> N;
  vector<int> K(N);
  
  for ( int i = 0; i < N; i++) {
    cin >> K.at(i);
  }
  
  sort(K.begin(), K.end());
  
  int count = 1;
  for ( int i = 0; i < N-1; i++) {
    if( K.at(i) == K.at(i+1) )
      continue;
    count++;
  }
  
  cout << count << endl;
  
}


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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

int main(void){

    int n, m;
    cin >> n >> m;
    int sum = 0;
    vector<int> a(m);
    rep(i, m){
         cin >> a.at(i);
         sum += a.at(i);
    }
    int ans = n - sum;
    if(ans<0)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
    }


Measured memory_bytes: 3664
#include <stdio.h>
#define MAX 100

int main (){
  int i,j,n,cnt = 0,tmp,minj,A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj = j;
      }
    }
    if(minj!=i)cnt++;
    tmp = A[i];
    A[i] = A[minj];
    A[minj] = tmp;
  }
  
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int n;
vector<int64> a;
map<pair<int, int>, int64> dp;
int64 solve(int pos, int cnt) {
	if (pos >= n) {
		if (cnt == n / 2) return 0;
		else return -1e15;
	}
	if (cnt == n / 2) return 0;
	if ((n - pos + 1) / 2 < (n / 2 - cnt)) return -1e15;
	if (dp.find({pos, cnt}) != dp.end()) return dp[{pos, cnt}];
	return dp[{pos, cnt}] = max(a[pos] + solve(pos + 2, cnt + 1), solve(pos + 1, cnt));
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	a = vector<int64> (n);
	for (int i = 0; i < n; ++ i) {
		cin >> a[i];
	}
	cout << solve(0, 0);
}

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

using namespace std;

const int N=1e5+7;


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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;
int main(){
    fast;
	int n, d, a, b, cnt = 0;
	cin >> n >> d;;
	for(int i = 0; i < n; i++){
        cin >> a >> b;
        double dist = sqrt(pow(a, 2) + pow(b, 2));
        if(dist <= d)
            cnt++;
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string s;
 
  cin >> s;
  
  for (int i = 0; i < s.size(); i++) {
      if ( s.at(i) == ',' ) {
        s.at(i) = ' ';
      }  
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3552
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define show(x) cout << #x << " = " << x << endl;
int cnt[200005];
int main(){
    int n,k;
    cin >> n >> k;
    int l = 0;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
        cnt[a[i]]++;
        if(cnt[a[i]]==1)l++;
    }
    sort(cnt,cnt+200005);
    int ans = 0;
    int hoge = 0;
    int i = 0;
    while(hoge < l-k){
        if(cnt[i] == 0){}
        else{ ans += cnt[i];hoge++;}
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
s=input()
i=len(s)-1
while True:
    if i<0:
        print('YES')
        sys.exit()
    if i>=4:
        if s[i-4:i+1]=='dream':
            i-=5
            continue
        elif s[i-4:i+1]=='erase':
            i-=5
            continue
    if i>=5 and s[i-5:i+1]=='eraser':
        i-=6
        continue
    if i>=6 and s[i-6:i+1]=='dreamer':
        i-=7
        continue
    print('NO')
    sys.exit()

    



Measured memory_bytes: 3188
#include <stdio.h>

int f(int W[][2],int A[][3], int b)
{
	int r, c;
	r = W[0][0] ^ W[1][0];
	if (W[1][1] - (W[0][1] + 1) % 3 != 0) r = !r;
	c = 3 - (W[0][1] + W[1][1]);
	return b ? A[r][c] : A[!r][c];
}

int main()
{
	int A[2][3];
	int B[2][3];
	int W[2][2];
	int i, h, r, c;

	for (i = 0; i < 3; i++) scanf("%d", &A[0][i]);
	for (i = 2; i >= 0; i--) scanf("%d", &A[1][i]);

	for (i = 0; i < 3; i++) scanf("%d", &B[0][i]);
	for (i = 2; i >= 0; i--) scanf("%d", &B[1][i]);

	i = 0;
	h = 1;
	W[0][1] = -1;
	while (i < 2 && h)
	{
		h = 0;
		for (r = 0; r < 2; r++)
		{
			for (c = 0; c < 3; c++)
			{
				if (c == W[0][1]) continue;
				if (A[0][i] == B[r][c] && A[1][i] == B[!r][c])
				{
					W[i][0] = r;
					W[i][1] = c;
					h = 1;
					break;
				}
			}
			if (h) break;
		}
		i++;
	}

	if (h && A[0][2] == f(W, B, 1) && A[1][2] == f(W, B, 0)) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 1820
#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();

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

void solve() {
    ll L, R, D;
    cin >> L >> R >> D;
    ll ans = 0;
    for (ll i = L; i <= R; i++) {
        if (i % D == 0) {
            ++ans;
        }
    }
    cout << ans << "\n";
}

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

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    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
    solve();
    cout << flush;
    return 0;
}

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

g = [[] for _ in range(n)]
for i in range(m):
	x,y,z=map(int,input().split())
	g[x-1].append(y-1)
	g[y-1].append(x-1)

check = [False]*n

cnt=0
import queue
q=queue.Queue()
for i in range(n):
	if check[i]:
		continue
	cnt+=1
	check[i]=True
	q.put(i)

	while not q.empty():
		now=q.get()
		for ne in g[now]:
			if check[ne]:
				continue
			check[ne]=True
			q.put(ne)

print(cnt)

Measured memory_bytes: 83356
a,b = map(int,input().split())

#bin_a = ("000000000000"+bin(a)[2:])[-10:-1]+("000000000000"+bin(a)[2:])[-1]
#bin_b = ("000000000000"+bin(b)[2:])[-10:-1]+("000000000000"+bin(b)[2:])[-1]

#print(bin_a)
#print(bin_b)
ans = []

if a%2 ==1:
  if (b-a+1)%4 ==1:
    ans.append("1") 
  elif (b-a+1)%4 ==2:
    ans.append("1") 
  elif (b-a+1)%4 ==3:
    ans.append("0") 
  elif (b-a+1)%4 ==0:
    ans.append("0") 
else:
  if (b-a+1)%4 ==1:
    ans.append("0") 
  elif (b-a+1)%4 ==2:
    ans.append("1") 
  elif (b-a+1)%4 ==3:
    ans.append("1") 
  elif (b-a+1)%4 ==0:
    ans.append("0") 
    
for i in range(1,100):
    cnt_a=a-(a//(2**i))*(2**i)
    cnt_b=b-(b//(2**i))*(2**i)+1
    
    if (((a//(2**i))*(2**i))//(2**i))%2 ==1 and (((b//(2**i))*(2**i))//(2**i))%2 ==1:
      ans.append(str((cnt_a+cnt_b)%2))

    elif (((a//(2**i))*(2**i))//(2**i))%2 ==0 and (((b//(2**i))*(2**i))//(2**i))%2 ==0:
      ans.append("0") 

    elif (((a//(2**i))*(2**i))//(2**i))%2 ==0 and (((b//(2**i))*(2**i))//(2**i))%2 ==1:
      ans.append(str((cnt_b)%2))

    else:
      ans.append(str((cnt_a)%2))

     
res = 0

for i in range(len(ans)):
  if ans[i]=="1":
    res = res + 2**i
print(res)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

int h, w, k, mn=1e9, d[805][805];
char a[805][805];
queue<pair<int,int>> qu;
int dr[4]={1, 0, -1, 0};
int dc[4]={0, 1, 0, -1};

int main() {
	int i, j, r, c, tr, tc;
	cin >> h >> w >> k;
	for(i=0; i<h; i++) {
		cin >> a[i];
		for(j=0; j<w; j++) {
			d[i][j] = -1;
			if(a[i][j]=='S') {
				d[i][j] = 0;
				qu.push({i, j});
			}
		}
	}
	while(!qu.empty()) {
		r = qu.front().first;
		c = qu.front().second;
		qu.pop();
		mn = min(mn, min(r,c));
		mn = min(mn, min(h-1-r, w-1-c));
		if(0<r && r<h-1 && 0<c && c<w-1 && d[r][c]<k) {
			for(i=0; i<4; i++) {
				tr = r + dr[i];
				tc = c + dc[i];
				if(a[tr][tc]!='#' && d[tr][tc]==-1) {
					d[tr][tc] = d[r][c] + 1;
					qu.push({tr, tc});
				}
			}
		}
	}
	cout << (mn+k-1)/k + 1;
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int n,num[200011];
bool che_up(){
	for(int i=1;i<n;i++)if(num[i]<=num[i-1])return false;
	return true;
}
bool che(int ip){
	map<int,int>m;
	int len=0;
	for(int i=0;i<n;i++){
		if(num[i]>len){len=num[i];continue;}
		while(!m.empty()&&m.rbegin()->first>=num[i])m.erase(m.rbegin()->first);
		m[num[i]-1]++;
		int now=num[i]-1;
		while(m[now]>=ip){
			m.erase(now--),m[now]++;
			if(now<0)return false;
			len=num[i];
		}
	}
	return true;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&num[i]);
	if(che_up()){puts("1");return 0;}
	int l=1,r=n+1;
	while(l+1<r){
		int mid=(l+r)>>1;
		if(che(mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll N;
    cin >> N;

    ll sum = 0;
    ll n   = N;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    bool isYes = N % sum == 0;
    cout << (isYes ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    int k = 0;
    cin >> s;
    if (s.length() == 2)
    {
        if (s[0] != s[1]) cout << "-1 -1";
        else cout << "1 2";
    }
    else
    {
        if (k == 0)
        {
            for (long unsigned i = 0; i < s.length() - 1; ++i)
            {
                if (s[i] == s[i + 1])
                {
                    k++;
                    cout << i + 1 << ' ' << i + 2;
                    break;
                }
            }
        }
        if (k == 0)
        {
            for (long unsigned i = 0; i < s.length() - 2; ++i)
            {
                if (s[i] == s[i + 2])
                {
                    k++;
                    cout << i + 1 << ' ' << i + 3;
                    break;
                }
            }
        }
        if (k == 0)
        {
            for (long unsigned i = s.length() - 1; i > 0; --i)
            {
                if (s[i] == s[i - 1])
                {
                    k++;
                    cout << i << ' ' << i + 1;
                    break;
                }
            }
        }
        if (k == 0)
        {
            for (long unsigned i = s.length() - 2; i > 1; --i)
            {
                if (s[i] == s[i - 2])
                {
                    k++;
                    cout << i - 1 << ' ' << i + 1;
                    break;
                }
            }
        }
        if (k == 0) cout << "-1 -1";
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N; cin >> N;
	set<string> s;
	REP(i, N) {
		string op; cin >> op;
		string target; cin >> target;
		if (op == "insert") {
			s.insert(target);
		}
		else {
			if (s.count(target) > 0) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}
}

Measured memory_bytes: 29004
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll a, b, c, d;
  in(a),in(b),in(c),in(d);
  print(max(0LL, min(b, d)-max(a, c)));
  return 0;
}


Measured memory_bytes: 3536
import itertools

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

cnt = 1
a = 0
b = 0
for tpl in itertools.permutations(range(1,N+1)):
    lst = list(tpl)
    if lst == P:
        a = cnt
    if lst == Q:
        b = cnt
    cnt += 1
            
print(abs(a-b))

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

//和の期待値＝期待値の和(期待値の線形性)
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  rep(i,n) p[i]++;
  int mx=0;
  int s=0;//qに追加されている値の和
  queue<int> q;
  rep(i,n) {
    s+=p[i];
    q.push(p[i]);//列の後ろに追加
    if (q.size()>k){//qに追加されている値の個数>k
      s-=q.front();/*最初の値を取り出す*/ q.pop();/*queueの先頭の削除*/
    }
    if (q.size()==k){
      mx=max(mx,s);
    }
  }
  double ans=mx;
  ans/=2;
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<set>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	int Max = 0;
	int next_max = 0;
	makei(N);
	map<int, int> m;
	rep(N) {
		int a;
		cin >> a;
		++m[a];
	}
	for (pii p : m) {
		if (p.second > 1) {
			if (p.first > Max) {
				next_max = Max;
				Max = p.first;
				if (p.second > 3) {
					next_max = p.first;
				}
			}
			else next_max = max(next_max, p.first);
		}
	}
	say((ll)Max*next_max);
}

Measured memory_bytes: 4992
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;

template<class T1, class T2> inline int chkmin(T1 &x, const T2 &y) {
    if (x > y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T1, class T2> inline int chkmax(T1 &x, const T2 &y) {
    if (x < y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);

template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) {
    while (begin != end) {
        out << (*begin) << " ";
        begin++;
    }
    out << endl;
}

template<class T> void output(const T &x, ostream &out = cerr) {
    output(x.begin(), x.end(), out);
}

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
}



int n;
int x[51], y[51];
map<pair<int, int>, bool> was;


int main() {
    fast_io();
   // read("input");
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    vector<int> vx, vy;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            vx.pb(x[i] - x[j]);
            vy.pb(y[i] - y[j]);
        }
        was[{x[i], y[i]}] = true;
    }
    sort(all(vx));
    vx.resize(distance(vx.begin(), unique(all(vx))));
    sort(all(vy));
    vy.resize(distance(vy.begin(), unique(all(vy))));
    int ans = n;
    for (auto xx: vx) {
        for (auto yy: vy) {
            if (xx == 0 && yy == 0) {
                continue;
            }
            if (xx < 0 || (xx == 0 && yy < 0)) {
                continue;
            }
            int cnt = n;
            for (int i = 0; i < n; i++) {
                if (was.find({x[i] - xx, y[i] - yy}) != was.end())  {
                    cnt--;
                }
            }
            chkmin(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}   


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define M1 (ll)1000000007
#define M2 (ll)998244353
#define Pi 3.141592653
#define exp 2.71828
#define ll long long
#define ull unsigned long long
#define pi pair<int,int>
#define pl pair<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define di deque<int>
#define dl deque<ll>
#define dii deque<pi>
#define dll deque<pl>
#define vvi vector<vi>
#define vvl vector<vl>
#define vii vector<pi>
#define vll vector<pl>
#define pb push_back
#define pp pop_back
#define pf push_front
#define pt pop_front
#define mp make_pair
#define in insert
#define er erase
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rpt(i,a,b,t) for(int i=a;i<b&&t<1;i++)
#define rep(i,n) for(int i = 0 ; i<n ; i++)
#define rept(i,n,t) for(int i = 0 ; i<n&&t<1 ; i++)
#define repr(i,n) for(int i = n-1 ; i>=0 ; i--)
#define reprt(i,n,t) for(int i=n-1;i>=0&&t<1;i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define SORT(v) sort(v.begin(),v.end())
using namespace std;
bool cmp(pair<int,int> i,pair<int,int> j){
    return i.first<j.first;
}
int main() {
    fast
    int n;
    ll w;
    cin>>n>>w;
    int v[n+1][2];
    for(int i=1;i<n+1;++i) cin>>v[i][0]>>v[i][1];
    ll value=0;
    for(int i=1;i<n+1;++i) value += v[i][1];
    // cout<<value<<'\n';
    ll dp[value+1][n+1];
    int flag[value+1][n+1];
    for(int i=0;i<value+1;++i) for(int j=0;j<n+1;++j) dp[i][j]=INT_MAX,flag[i][j]=0;
    // flag[0][0] = 1;
    for(int i=0;i<n+1;++i) flag[0][i]=1,dp[0][i]=0;
    for(int i=1;i<value+1;++i){
        for(int j=1;j<n+1;++j){
            if(flag[i][j-1]==1){
                //  if(i==30 && j==1) cout<<"gotcha1"<<'\n'; 
                dp[i][j] = dp[i][j-1],flag[i][j]=1;
            }
            if(i-v[j][1]>=0 && flag[i-v[j][1]][j-1]==1){
                //  if(i==30 && j==1) cout<<"gotcha2"<<'\n'; 
                dp[i][j] = min(dp[i][j],dp[i-v[j][1]][j-1]+v[j][0]),flag[i][j]=1;
            }
            // if(i==30 && j==1) cout<<dp[i][j]<<'\n';  80 2 30 1
        }
    }
    int result = 0;
    for(int i=1;i<value+1;++i){
        for(int j=1;j<n+1;++j){
            if(flag[i][j]==1 && dp[i][j]<=w) result = max(result,i);
        }
    }
    // for(int i=0;i<value+1;++i){
    //     for(int j=0;j<n+1;++j){
    //         cout<<flag[i][j]<<" ";
    //     }
    //     cout<<'\n';
    // }
    // cout<<'\n';
    // cout<<flag[30][1]<<" "<<dp[30][1];
    cout<<result;
}


Measured memory_bytes: 121912
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

using namespace std;
using ll=long long;

int num;
void dfs(vector<vector<int>> adj,int index,vector<bool>& th){
  th[index]=true;
  for(int i=0;i<adj[index].size();i++){
    if(th[adj[index][i]])continue;
    dfs(adj,adj[index][i],th);
  }
}

void solve(){
  int m;
  cin >> num >> m;
  vector<vector<int>> ab(m,vector<int>(2));int res=0;
  for(int i=0;i<m;i++)
    cin >> ab[i][0] >> ab[i][1];
  for(int i=0;i<m;i++){
    vector<vector<int>> adj(num,vector<int>(num));
    for(int j=0;j<m;j++){
      if(i==j)continue;
      adj[ab[j][0]-1].push_back(ab[j][1]-1);
      adj[ab[j][1]-1].push_back(ab[j][0]-1);
    }
    bool b=true;
    vector<bool> th(num);
    dfs(adj,0,th);
    for(int i=0;i<th.size();i++)
      b&=th[i];
    if(!b)res++;
  }
  std::cout << res << '\n';
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 920