akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
  while (true) {
    int m, f, r;
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) break;

    if (m == -1 || f == -1 || m + f < 30) {
      cout << "F" << "\n";
    } else if (m + f >= 80) {
      cout << "A" << "\n";
    } else if (m + f >= 65) {
      cout << "B" << "\n";
    } else if (m + f >= 50 || r >= 50) {
      cout << "C" << "\n";
    } else {
      cout << "D" << "\n";
    }
  }
}



Measured memory_bytes: 3012
#include <bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v)    \
  {                          \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
#define ddump(v)                     \
  cerr << #v ":" << endl;            \
  for (auto macro_row : v)           \
  {                                  \
    cerr << "[";                     \
    for (auto macro__vi : macro_row) \
    {                                \
      cerr << macro__vi << " ";      \
    }                                \
    cerr << "]" << endl;             \
  }
#define damp(m)                                                   \
  for (auto macro_pair : m)                                       \
  {                                                               \
    cerr << macro_pair.first << ":" << macro_pair.second << endl; \
  }
#define dpair(p) cerr << #p ":" \
                      << "(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define itr(macro_v, i) macro_v.begin() + i
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  string sigma = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  d(sigma.length());
  for (int i = 0; i < s.size(); i++)
  {
    int num = s[i] - 'A';
    d(num);
    int j = (num + n) % 26;
    d(j);
    s[i] = sigma[(num + n) % 26];
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
N,L = map(int, input().split())

sum_n = 0
min_abs = 20000
for i in range(N):
    sum_n+=L+i
    min_abs=min(min_abs, abs(L+i))
if sum_n>0:
    print(sum_n-min_abs)
else:
    print(sum_n+min_abs)


Measured memory_bytes: 2940
import java.util.*;

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

    int P = sc.nextInt();
    int Q = sc.nextInt();
    int R = sc.nextInt();

    int min = Math.min(P+Q,Math.min(Q+R,R+P));

    System.out.println(min);
  }
}


Measured memory_bytes: 22996
m,d = map(int,input().split())

ans=0
for i in range(1,m+1):
    for j in range(1,d+1):
        if j >= 10:
            d10=int(str(j)[0])
            d1=int(str(j)[1])
            if d1 >= 2 and d10 >= 2 and d1*d10==i:
                ans+=1

print(ans)

Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    int data[4][3][10];
    for(int i = 0;i < 4;i++)
        for(int j = 0;j < 3;j++)
            for(int k = 0;k < 10;k++)
                data[i][j][k] = 0;
    cin >> n;
    for(int i = 0;i < n;i++) {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        data[a - 1][b - 1][c - 1] += d;
    }
    
    for(int i = 0;i < 4;i++) {
        for(int j = 0;j < 3;j++) {
            for(int k = 0;k < 10;k++) {
                cout << " " <<  data[i][j][k];
            }
            cout << endl;
        }
        if(i != 3)
        cout << "####################" << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define repe(a, b) for (auto&(a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define mp(a, b) make_pair((a), (b))
#define Push_back(a, b) push_back( mp( (a), (b) ) )

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;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

const int inf = 0x3fffffff;
const int64_t INF = 0x3fffffffffffffff;
const int64_t MOD = 1e9+7;

int64_t enum_div(int64_t n) {
    vector<int64_t> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if ( i*i != n ) {
                ret.push_back(n/i);
            }
        }
    }
    return ret.size();
}

int64_t enum_div2 (int64_t n) {
    vector<int64_t> ret;
    rep2(i, n-1) {
        for(int j = 1; j*j <= i; ++j){
            if(i%j == 0){
                ret.push_back(j);
                if ( j*j != i ) {
                    ret.push_back(i/j);
                }
            }
        }
        // ans += ret.size();
    }
    return ret.size();
}

int main() {
    int64_t n;
    cin >> n;
    // std::vector<int64_t> v;
    /*
    int64_t ans = 0;
    rep2(i, n-1) {
        ans += enum_div(i);
    }
    cout << ans << endl;
    */

    // cout << enum_div2(n) << endl;
    int64_t ans = 0;
    rep2(i, n-1) {
        ans += (n-1)/i;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<P> lr(m);
    rep(i,m) {
        cin >> lr[i].first >> lr[i].second;
    }

    int maxl = 0;
    int minr = n;

    rep(i, m) {
        int l = lr[i].first;
        int r = lr[i].second;
        if(l > minr || r < maxl) {
            cout << 0 <<endl;;
            return 0;
        }
        maxl = max(maxl, l);
        minr = min(minr, r);
    }

    int ans = minr - maxl + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
def main():
    N = int(input())
    ans = 1
    if N < 105:
        print(0)
    elif N == 105:
        print(1)
    else:
        for i in range(106, N+1):
            temp = 0
            if i % 2 == 0:
                continue
            for j in range(1, N+1):
                if i % j == 0:
                    temp += 1
            if temp == 8:
                ans += 1
        print(ans)
main()  

Measured memory_bytes: 9040
use std::collections::HashMap;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn comb(n: i64, r: i64) -> i64 {
    match (n, r) {
        (0, _) | (_, 0) => 1,
        _ => comb(n, r - 1) * (n - r + 1) / r
    }
}


fn main() {
    input!{
        n: usize,
        m: i64,
        v: [i64; n],
    }
    let mut sum: Vec<i64> = Vec::new();
    sum.push(v[0] % m);
    let mut temp = v[0] % m ;
    for i in 0..n-1 {
        temp += v[i+1];
        sum.push(temp % m);
    }
    let mut map: HashMap<i64, i64>  = HashMap::new();

    for x in sum.iter() {
        if !map.contains_key(&x) {
            map.insert(*x, 1);
        } else {
            *map.get_mut(&x).unwrap() += 1;
        }
    }
    let mut res: i64= 0;
    for (key, val) in map.iter() {
        if  *val > 1 {
            res += comb(*val, 2_i64)
        }
    }
    res += *map.get(&0).unwrap_or(&0);
    println!("{}", res);

}

Measured memory_bytes: 14588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min((b / a), c) << endl;
    return 0;
}

Measured memory_bytes: 256
c = Hash.new(0)
gets.to_i.times do
    h = gets.to_f
    g = [[(h * 10).to_i / 50 - 31, 1].max, 6].min
    c[g] += 1
end

(1..6).each do |g|
    puts "#{g}:#{?* * c[g]}"
end

Measured memory_bytes: 8528
// 全探索
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    map<ll, ll> mp;
    rep(i, N) {
        ll a;
        cin >> a;
        mp[a] += 1;
    }

    for (auto m : mp) {
        if (m.second > 1) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "\n[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "\n[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]\n";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", 6 - a - b);
    return 0;
}



Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    s = c
    for i in range(m):
        s += a[i] * b[i]
    if s > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
import java.util.*;

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

        char[] charArray = s.toCharArray();
        Set<Character> set =   new HashSet<Character>();

        for (char c : charArray){
           set.add(c);
        }

        if(s.length() == set.size()){
            System.out.print("yes");
        }else{
            System.out.print("no");
        }
    }
}

Measured memory_bytes: 22996
n,t = map(int, input().split())
tl = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    if tl[i]-tl[i-1] <= t:
        ans += tl[i]-tl[i-1]
    else:
        ans += t
ans += t
print(ans)


Measured memory_bytes: 85712
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

const int INF = 1e9;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

pair<int,int> BAD = {+INF, -INF};

int n;
Graph g;
int k;

int num[100010];

bool pality_check(int u, int p, int x){
    if(num[u] != -1 && num[u]%2 != x){
        return false;
    }

    for(auto &e : g[u]){
        int v = e.dst;
        if(v == p) continue;
        if(!pality_check(v, u, 1-x)){
            return false;
        }
    }

    return true;
}

int lb[100010], ub[100010];

pair<int,int> get_range(int u, int p){
    int mi = -INF;
    int ma = INF;
    for(auto &e : g[u]){
        int v = e.dst;
        if(v == p) continue;
        int tmi, tma;
        tie(tmi, tma) = get_range(v, u);
        mi = max(mi, tmi);
        ma = min(ma, tma);
    }

    --mi;
    ++ma;

    pair<int,int> res;
    if(mi > ma){
        res = BAD;
    } else {
        if(num[u] != -1){
            if(mi <= num[u] && num[u] <= ma){
                res = make_pair(num[u], num[u]);
            } else {
                res = BAD;
            }
        } else {
            res = make_pair(mi, ma);
        }
    }

    tie(lb[u], ub[u]) = res;
    return res;
}

void paint(int u, int p, int pc){
    int c = lb[u] <= pc-1 && pc-1 <= ub[u] ? pc-1 : pc+1;
    num[u] = c;
    for(auto &e : g[u]){
        int v = e.dst;
        if(v == p) continue;
        paint(v, u, c);
    }
}

int main(){
    while(cin >> n){
        memset(num, -1, sizeof num);
        g.assign(n, {});
        rep(i,n-1){
            int x,y;
            cin >> x >> y;
            --x; --y;
            g[x].emplace_back(x,y,1);
            g[y].emplace_back(y,x,1);
        }
        cin >> k;
        rep(i,k){
            int v,p;
            cin >> v >> p;
            --v;
            num[v] = p;
        }

        bool yes = true;
        rep(i,n){
            if(num[i] != -1){
                if(!pality_check(i, -1, num[i]%2)){
                    yes = false;
                    break;
                }
                
                pair<int,int> res = get_range(i, -1);

                // dump(i);
                // rep(i,n) dump(lb[i]);
                // rep(i,n) dump(ub[i]);
                
                if(res == BAD){
                    yes = false;
                    break;
                }

                paint(i, -1, lb[i]-1);
                break;
            }
        }

        if(!yes){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
            rep(i,n) cout << num[i] << '\n';
        }
    }
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl a;
/******* define variable end *******/
typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) { return a.first < b.first; }

void sort2vectors(
	vector<ll> &av,
	vector<ll> &bv) { // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
  ll n = av.size();
  vector<pair_t> p(n);
  vector<ll> av2(n), bv2(n);
  for (ll i = 0; i < n; i++)
	p[i] = make_pair(av[i], bv[i]);
  sort(p.begin(), p.end(), comp);
  for (ll i = 0; i < n; i++) {
	av2[i] = p[i].first;
	bv2[i] = p[i].second;
  }
  av = av2;
  bv = bv2;
}
int solve() {
	cin >> n;
	a.resize(n);
	vl it(n);
	REP(i, n){
		cin >> a[i];
		it[i] = i+1;
	}
	sort2vectors(a, it);
	ll count = 0;
	REP(i, n){
		if(i % 2 == 0 && it[i] % 2 == 0){
			count++;
		}
		if(i % 2 == 1 && it[i] % 2 == 1){
			count++;
		}
	}
	cout << count/2 << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 4992
// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sc scanf
#define pr printf

#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sqr(x) ((x) * (x))

#define sci(n) sc("%d", &n);
#define sci2(n, m) sc("%d%d", &n, &m);
#define scl(n) sc("%I64d", &n);
#define scl2(n, m) sc("%I64d%I64d", &n, &m);

#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1000000000;
const ull mx = 1000000000000000000ll;

int main() {
	TEZ;

	int n;
	cin >> n;

	ll t, p = 1;
	ld k = 1;
	while (n--) {
		cin >> t;

		k *= t;
		p *= t;
	}
	xatop(k);
	if (k > 1e18)
		cout << -1 << endl;
	else
		cout << p << endl;

	return 0;
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define N 111111
int n,i,j;
double pw,w[N],f[N],v[N],t[N],l,r,p,q,a,e;
double c(double x){
  for(e=pw*x,j=0;j<n;j++) e+=max(0.0,(t[j]-w[j]*x)*f[j]/v[j]);
  a=min(a,e);
  return e;
}
int main(){
  while(cin>>n,n){
    for(cin>>pw,i=0;i<n;i++) scanf("%lf%lf%lf%lf",w+i,f+i,v+i,t+i);
    for(i=0,l=0,r=1e9,a=c(0);i<100;i++) p=l+(r-l)/3,q=l+(r-l)*2/3,(c(p)>c(q))?l=p:r=q;
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 6460
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,total=0,ans=0,a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        total+=a;
        ans-=a*a;
    }
    ans=(ans+total*total)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

string s;

const int N=5e3+100;
const ll mod=1e9+7;
const ll bas=101;

ll __hash[N][N];

void brute_hash(){
	int n=sz(s);
	roF(i,n-1,0)For(j,i,n){
		__hash[i][j]=((s[i]-'a'+1)+__hash[i+1][j]*bas)%mod;
	}
}



int main(){	
	int n;cin>>n;
	cin>>s;
	brute_hash();
	int mx=0;
	For(i,0,sz(s)){
		int lo=0,hi=n-i;
		while(lo+1<hi){
			int mid=(lo+hi)>>1;
			bool _find=false;
			For(j,i+mid,n){
				if(__hash[i][i+mid-1]==__hash[j][j+mid-1]){
					_find=true;
					break;
				}
			}
			if(_find)lo=mid;
			else hi=mid;
		}
		mx=max(mx,lo);
	}
	cout<<mx<<endl;

	return 0;
}


Measured memory_bytes: 120572
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  n--;
  int64_t maximum     = a + n * d;
  int64_t minimum     = a - n * d;
  int64_t true_range  = 1 + (d - c) * n;
  int64_t range       = (maximum - minimum + 1);
  int64_t false_range = (range - true_range * (n + 1)) / n;
  //   cerr << "\033[93m" << maximum << " " << minimum << " " << true_range << "
  //   "
  //    << range << " " << false_range << "\033[m" << endl;
  if (false_range <= 0) {
    if (maximum >= b && b >= minimum) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    return 0;
  }
  int64_t top = maximum, bottom = maximum - true_range + 1;
  while (bottom >= minimum) {
    // cerr << "\033[93m" << top << " " << bottom << "\033[m" << endl;
    if (bottom <= b && b <= top) {
      cout << "YES" << endl;
      return 0;
    } else if (bottom <= b && top < b) {
      cout << "NO" << endl;
      return 0;
    }
    bottom -= (true_range + false_range);
    top -= (true_range + false_range);
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <functional>
#include <vector>


using namespace std;

int main(void) {
	int N, K;
	cin >> N >> K;
	vector<long long int> vs;
	for(int i = 0; i < N; i++) {
		long long int h;
		cin >> h;
		vs.push_back(h);
	}
	sort(vs.begin(), vs.end());
	//for(auto v:vs) cout << "::" <<  v << endl;
	int ans = 1000000000;
	for (int i = 0; i <= N-K; i++) {
//		cout << i+K-1 << ":" << i << endl;
		int score = vs.at(i+K-1) - vs.at(i);
//		cout << score << endl;
		ans = min(ans, score);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
inline 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<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
inline void write(int x)
{
    if(x<0){
    	putchar('-');
		x=-x;
	}
    if(x>9) 
		write(x/10);
    putchar(x%10+'0');
}
int n,s1,s2;
string s;
int main(){
	n=read();
	cin>>s;
	for (int i=0;i<n;i++){
		if (s[i]=='I'){
			s2++;
			s1=max(s2,s1);
		}
		else if (s[i]=='D'){
			s2--;
			s1=max(s1,s2);
		}
	}
	write(s1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string input;
  int flag = 0;
  int tmpans = 0;
  cin >> input;
  int count = 0;
  for (int i = 0; i < input.size(); i++) {
    if (input.at(i) == 'A') {
      count++; flag = 1;
    } else if (input.at(i) == 'T') {
      count++; flag = 1;
    } else if (input.at(i) == 'G') {
      count++; flag = 1;
    } else if (input.at(i) == 'C') {
      count++; flag = 1;
    } else {
      if (tmpans < count){
        tmpans = count;
      }
      count = 0;
    }
  }
        if (tmpans < count){
        tmpans = count;
      }
  cout << tmpans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.regex.*;

public class Main {
    
    private static PrintWriter out;
    
    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }
    
    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close(); 
    }
    
//  Global Variables  
    
    private static void getAns(MyScanner sc){
        int n = sc.ni();
        int[][] ar = new int[n][2];
        for(int i = 0; i < n; i++) ar[i] = sc.niArr0(2);
        Arrays.sort(ar, (int[] a, int[] b) -> a[1] - b[1]);
        int cur = 0;
//        out.println(Arrays.deepToString(ar));
        for(int i = 0; i < n; i++){
            cur += ar[i][0];
            if(cur > ar[i][1]){
                out.println("No");
                return;
            }
        }
        
        out.println("Yes");
    }
    
    static class MyScanner{
        BufferedReader br;
	StringTokenizer st;

	MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
	}

	MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
	}

	String nn(){
            while(st == null || !st.hasMoreElements()){
		try{
                    st = new StringTokenizer(br.readLine());
		}catch(IOException e){
                    e.printStackTrace();
		}
            }
            return st.nextToken();
	}
        
        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

	char nc(){
            return nn().charAt(0);
	}

	int ni(){
            return Integer.parseInt(nn());
	}

	long nl(){
            return Long.parseLong(nn());
	}

	double nd(){
            return Double.parseDouble(nn());
	}

	int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
	}

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
	}

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

Measured memory_bytes: 62192
s = gets.chomp.reverse
divide = ["dream", "dreamer", "erase", "eraser"]
divide.map!(&:reverse)

jadge = true
while jadge
  break if s.empty?
  jadge2 = false
  divide.each{|d|
    size = d.length
    if d == s[0..size-1]
      s.slice!(0,size)
      jadge2 = true
    end
  }
  jadge = false unless jadge2
end

puts jadge ? "YES" : "NO"

Measured memory_bytes: 75772
#include<stdio.h>
int main(void)
{
	int r,g,b,s;
	scanf("%d",&r);
	scanf("%d",&g);
	scanf("%d",&b);
	s=r*100+g*10+b;
	if(s%4==0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
A.sort()
acc = [0] * (N + 1)
for i in range(N):
    acc[i + 1] = acc[i] + A[i]
result = 1
for i in range(N - 2, -1, -1):
    if 2 * acc[i + 1] >= A[i + 1]:
        result += 1
    else:
        break
print(result)

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

void solve3(vector<LL>& ans, vector<LL>& a, vector<LL>& tri){
    for(LL i = 0; i < 3; ++i){
        for(LL j = 0; j < 3; ++j){
            for(LL k = 0; k < 3; ++k){
                if(i == j || j == k || k == i) continue;
                if(ans.size() > 0 && a[ans[ans.size()-1]] == tri[i]) continue;
                if(a[tri[i]] != tri[j] && a[tri[j]] != tri[k]){
                    ans.push_back(tri[i]);
                    ans.push_back(tri[j]);
                    ans.push_back(tri[k]);
                    return;
                }
            }
        }
    }
}


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

    set<pair<LL,LL>> ordered;
    set<LL> rest;
    for(LL i = 0; i < n; ++i){
        rest.insert(i);
        ordered.insert(pair<LL,LL>(indegree[i], i));
    }
    vector<LL> used(n);
    vector<LL> ans;
    for(LL i = 0; i+3 < n; ++i){
        while(!ordered.empty()){
            LL val = ordered.rbegin()->first;
            LL key = ordered.rbegin()->second;
            if(used[key]){
                ordered.erase(--ordered.end());
                continue;
            }
            if(val != indegree[key]){
                ordered.erase(--ordered.end());
                ordered.insert(pair<LL,LL>(indegree[key], key));
                continue;
            }
            break;
        }
        if(!ordered.empty()){
            LL val = ordered.rbegin()->first;
            LL key = ordered.rbegin()->second;
            if(val == n-1-i){
                ans.push_back(key);
                used[key] = 1;
                indegree[a[key]] -= 1;
                rest.erase(key);
                continue;
            }
        }
        for(LL cur: rest){
            if(i > 0 && a[ans[ans.size()-1]] == cur){
                continue;
            }
            ans.push_back(cur);
            used[cur] = 1;
            indegree[a[cur]] -= 1;
            rest.erase(cur);
            break;
        }
    }
    assert(rest.size() == 3);
    vector<LL> tri(rest.begin(), rest.end());
    solve3(ans, a, tri);
    for(LL i = 0; i < n; ++i){
        cout << ans[i]+1 << ((i+1==n)?"\n":" ");
    }
    return 0;
}



Measured memory_bytes: 15092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int N=1000005;
const long long INF=4557430888798830399;
int n,m;
int a[N],b[N],c[N];
int fa[N];
int getf(int v)
{
	if(v==fa[v]) return v;
	fa[v]=getf(fa[v]);
	return fa[v];
}
void merge(int u,int v)
{
	int f1=getf(u),f2=getf(v);
	if(f1!=f2) fa[f2]=f1;
	return;
}
int in[N],siz[N];
bool circle[N];
vector<int>pos[4];
long long s2[N],s0[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		fa[i]=i;
	long long ans=0;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		if(a[i]!=b[i]) ans++;
		merge(a[i],b[i]);
		in[a[i]]++;
	}
	memset(circle,true,sizeof(circle));
	for(int i=1;i<=n;i++)
	{
		siz[getf(i)]++;
		if(in[i]>1) circle[getf(i)]=false;
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(getf(i)==i)
		{
			if(circle[i]&&siz[i]>1) cnt++;
		}
	if(cnt==0)
	{
		printf("%lld",ans);
		return 0;
	}
	ans+=cnt;
	for(int i=1;i<=m;i++)
		if(c[i]>=2)
		{
			int u=getf(a[i]);
			if(circle[u])
			{
				if(siz[u]==1) pos[0].push_back(c[i]-2);
				else if(siz[u]>1) pos[1].push_back(c[i]-1);
			}
			else
			{
				if(a[i]==b[i]) pos[2].push_back(c[i]-1);
				else pos[3].push_back(c[i]-1);
			}
		}
	for(int p=0;p<=3;p++)
		sort(pos[p].begin(),pos[p].end(),greater<int>());
	long long sum=0;
	for(int p=0;p<=3;p++)
		for(int c:pos[p])
			sum+=c;
	if(sum<cnt)
	{
		printf("-1");
		return 0;
	}
	if(pos[2].empty()&&pos[3].empty())
	{
		printf("-1");
		return 0;
	}
	if(pos[3].empty()) ans++,cnt-=pos[2].front(),pos[2].erase(pos[2].begin());
	else cnt-=pos[3].front(),pos[3].erase(pos[3].begin());
	for(int c:pos[3])
		cnt-=c;
	for(int c:pos[1])
		cnt-=c;
	pos[3].clear();
	pos[1].clear();
	if(cnt<=0)
	{
		printf("%lld",ans);
		return 0;
	}
	for(int i=1;i<=pos[0].size();i++)
		s0[i]=s0[i-1]+pos[0][i-1];
	for(int i=1;i<=pos[2].size();i++)
		s2[i]=s2[i-1]+pos[2][i-1];
	long long res=INF;
	for(int i=pos[0].size(),j=0;i>=0;i--)
	{
		while(j<=pos[2].size()&&s0[i]+s2[j]<cnt) j++;
		if(j<=pos[2].size()) res=min(res,2LL*i+j);
	}
	printf("%lld",ans+res);
	return 0;
}


Measured memory_bytes: 7432
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

u64 nCr(u64 n, u64 r) {
    u64 a = 1, b = 1;
    for (u64 i = 1; i <= r; i++) {
        a *= (n - i + 1); b *= i;
    }
    return a / b;
}

void Main() {
    u32 N;
    cin >> N;
    Vec<u32> a(N);
    map<u32, u32> c;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        c[a[i]]++;
    }
    u64 sum = 0;
    for(auto x: c) {
        u64 key = x.first;
        u64 value = x.second;
        sum += nCr(value, 2);
    }
    for (int i = 0; i < N; i++) {
        u64 sub = nCr(c[a[i]], 2) - nCr(c[a[i]] - 1, 2);
        cout << sum - sub<< endl;
    }
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < S.size(); i++)
        if (S[i] != T[i]) ans++;
    cout << ans << '\n';
}


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

int main() {
	// your code goes here
	int n;cin>>n;	string s;
	cin>>s;
	long long int sum=0;//r,g,b
	int dp[n][3];
	for(int i=0;i<n;i++) {dp[i][0]=0;dp[i][1]=0;dp[i][2]=0;}
	for(int i=0;i<n;i++)
	 {
	 	if(s.at(i) == 'R')
	 	 {dp[i][0] = 1;
	 	}
	 	else if(s.at(i) == 'G')
	 	  {
	 	dp[i][1] = 1;}
	 	else if(s.at(i) == 'B')
	 	 {dp[i][2] = 1;
	 	} 
	 }
	 

	 for(int i=n-2;i>=0;i--)
	 {
	 	 dp[i][0]+=dp[i+1][0];
	 	dp[i][1]+=dp[i+1][1];dp[i][2]+=dp[i+1][2]; 
	 }
	 for(int i=0;i<n-2;i++)
	 {
	 	for(int j=i+1;j<n-1;j++)
	 	 {
           if(s.at(i)=='R')
            {
            	if(s.at(j)=='G')
            	 {
            	 	sum+=dp[j+1][2];
            	 	if(2*j -i <n && s.at(2*j-i)=='B') sum--;
            	 }
            	else if(s.at(j)=='B')
            	{
            		sum+=dp[j+1][1];
            			if(2*j -i <n && s.at(2*j-i)=='G') sum--;
            	}
            }
           
            if(s.at(i)=='G')
            {
            	if(s.at(j)=='R')
            	 {
            	 	sum+=dp[j+1][2];
            	 	if(2*j -i <n && s.at(2*j-i)=='B') sum--;
            	 }
            	else if(s.at(j)=='B')
            	{
            		sum+=dp[j+1][0];
            			if(2*j -i <n && s.at(2*j-i)=='R') sum--;
            	}
            }
            
            if(s.at(i)=='B')
            {
            	if(s.at(j)=='G')
            	 {
            	 	sum+=dp[j+1][0];
            	 	if(2*j -i <n && s.at(2*j-i)=='R') sum--;
            	 }
            	else if(s.at(j)=='R')
            	{
            		sum+=dp[j+1][1];
            			if(2*j -i <n && s.at(2*j-i)=='G') sum--;
            	}
            }
	 	 }
	 }
	 cout<<sum<<endl;
	return 0;
}

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll pos=1;
    string s;
    cin>>s;
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
    pos=0;
    if(pos)
    cout<<"Good";
    else
    cout<<"Bad";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))
 
using namespace std;
 
typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;
 
template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
 
int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
 
  int n;
  while (cin >> n) {
    vector<int> a(n);
    each (i, a) cin >> i;
    list<int> x;
    int cnt = 0;
    each (i, a) {
      if (cnt++ % 2) x.push_front(i);
      else x.push_back(i);
    }
    if (n % 2) reverse(x.begin(), x.end());
    bool f = false;
    each (i, x) {
      if (f) cout << ' ';
      f = true;
      cout << i;
    }
    cout << endl;
  }
  
  return 0;
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

class UnionFind{
public:

    vector<int> root;
    vector<int> rank;
    vector<int> sizev;

    UnionFind();

    //1-indexでアクセスすること想定
    UnionFind(int n){

        for(int i = 0; i <= n; i++){
            root.push_back(i);
            rank.push_back(1);
            sizev.push_back(1);
        }
    }

    int find(int n){

        vector<int> update;
        int count = 0;

        while(n != root[n]){
            
            update.push_back(n);
            n = root[n];
            count++;
        }

        for(int i = 0; i < count; i++){
            root[update[i]] = n;
        }

        return n;
    }

    int size(int n){
        return sizev[find(n)];
    }

    void merge(int a, int b){

        a = find(a);
        b = find(b);

        if(a != b){

            if(rank[a] < rank[b]){
                root[a] = b;
                sizev[b] += sizev[a];
            }else{
                root[b] = a;
                sizev[a] += sizev[b];

                if(rank[a] == rank[b]){
                    rank[a]++;
                }
            }
        
        }
    }
};

int main(){

    int n, m;
    cin >> n >> m;

    UnionFind uf(n); // 1-index

    rep(i, m){
        int a, b;
        cin >> a >> b;

        uf.merge(a, b);
    }

    int ans = 0;
    vector<int> root(n + 1);

    rep(i, n){
        root[uf.find(i + 1)]++;
    }

    rep(i, n){
        if(root[i + 1] > ans){
            ans = root[i + 1];
        }
    }

    cout << ans << endl;
    
    return 0;

}


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

//#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
	setc;

	string s;cin>>s;
	s[5]=' ';s[13]=' ';
	co(s);
	gc();
}

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


int main(){
    string s;
    cin >> s;
    int n=s.size();
    string s_1,s_2;
    s_1=s[0];
    int cnt=1;
    for(int i=1; i<n; i++){
        s_2=s[i];
        if(s_1==s_2&&i==n-1)break;
        if(s_1!=s_2)s_1=s_2;
        else{
            i++;
            s_2+=s[i];
            s_1=s_2;
        }
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    vector<int> cnt(4, 0);
    vector<string> T = {"AC", "WA", "TLE", "RE"};
    rep(i, 0, N) {
        cin >> S;
        rep(j, 0, 4) {
            if (S == T[j]) {
                ++cnt[j];
                break;
            }
        }
    }
    rep(i, 0, 4) {
        cout << T[i] << " x " << cnt[i] << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;


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

        ll n;
        cin >> n;
        int lg = log2(n);
        ll ans = (1LL << (lg + 1)) - 1;
        cout << ans << "\n";

}


Measured memory_bytes: 512
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll x;
cin >> x;
if(400 <= x && x < 600)
    cout << 8 << endl;
else if(600 <= x && x < 800)
    cout << 7 << endl;
else if(800 <= x && x < 1000)
    cout << 6 << endl;
else if(1000 <= x && x < 1200)
    cout << 5 << endl;
else if(1200 <= x && x < 1400)
    cout << 4 << endl;
else if(1400 <= x && x < 1600)
    cout << 3 << endl;
else if(1600 <= x && x <1800)
    cout << 2 << endl;
else 
    cout << 1 << endl;
}

Measured memory_bytes: 3648
import qualified Data.Map as M

main :: IO ()
main = do
  n <- readLn
  ss <- sequence $ replicate n getLine
  m <- readLn
  ts <- sequence $ replicate m getLine
  print $ solve ss ts

solve :: [String] -> [String] -> Int
solve ss ts = go (M.singleton "" 0) ss ts
  where
    go dict [] []     = maximum $ M.elems dict
    go dict (s:ss) ts = go (M.insertWith (+) s 1 dict) ss ts
    go dict [] (t:ts) = go (M.insertWith (+) t (-1) dict) [] ts

Measured memory_bytes: 636
S = input()[::-1]

words = [w[::-1] for w in ["dream", "dreamer", "erase", "eraser"]]
while True:
    removed = False
    for w in words:
        if S.startswith(w):
            S = S[len(w):]
            removed = True
            break
    if S == "":
        print("YES")
        break
    if not removed:
        print("NO")
        break

Measured memory_bytes: 3188