akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int N, M;
	cin >> N;
	string s[N];
	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
	}
	cin >> M;
	string t[M];
	for (int i = 0; i < M; i++)
	{
		cin >> t[i];
	}
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		string tmp = s[i];
		int N_tmp = 0, M_tmp = 0;
		for (int j = 0; j < N; j++)
		{
			if (tmp == s[j])
			{
				N_tmp++;
			}
		}
		for (int k = 0; k < M; k++)
		{
			if (tmp == t[k])
			{
				M_tmp++;
			}
		}
		ans = max(ans, N_tmp - M_tmp);
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int a[1000];
int b[1000];
int c[1000];

int main(){
	int n, m;
	
	cin >> n >> m;
	
	REP(i,n){
		scanf("%d", &a[i]);
	}
	
	REP(i,m){
		scanf("%d", &b[i]);
	}
	
	REP(i,m){
		REP(j,n){
			if (a[j] <= b[i]){
				c[j]++;
				break;
			}
		}
	}
	
	int ma = 0;
	int ans;
	
	REP(i,n){
		if (c[i] > ma){
			ma = c[i];
			ans = i+1;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	set<int>s;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;

		if(s.find(x)!=s.end())
			s.erase(x);
		else
			s.insert(x);
	}

	int count=s.size();

	cout<<count<<endl;
	return 0;
}


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

using namespace std;

int main() {
	string s;
	long k;
	cin >> s >> k;
	int i = 0;
	for (; i < s.length() && i < k; i++)
		if (s[i] != '1')
			goto pnz;
	i--;
pnz:
	cout << s[i] << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

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

type d struct {
	a, b int
}

type ds []d

func (d ds) Len() int {
	return len(d)
}
func (d ds) Less(i, j int) bool {
	return d[i].a+d[i].b < d[j].a+d[j].b // Ai+Biの順にソートする
}
func (d ds) Swap(i, j int) {
	d[i], d[j] = d[j], d[i]
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt(sc)
	dishes := make([]d, N)
	for i := range dishes {
		dishes[i].a = nextInt(sc)
		dishes[i].b = nextInt(sc)
	}
	sort.Sort(sort.Reverse(ds(dishes)))
	// fmt.Println("dishes", dishes)
	t, a := 0, 0
	for i := range dishes {
		if i%2 == 0 {
			t += dishes[i].a
		} else {
			a += dishes[i].b
		}
	}
	fmt.Println(t - a)
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define r0 return 0

/* typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
*/
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
using namespace std;

int main()
{
	fast
    int k,x;
    cin>>k>>x;
    for(int i=x+1-k;i!=x;i++){
        if(i<-1000000) i=-1000000;
        if (i>=-1000000 && i<=1000000) cout<<i<<" ";
    }
    for(int i=x;i!=x+k;i++){
        if(i>1000000) break;
        if (i>=-1000000 && i<=1000000) cout<<i<<" ";
    }


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
#define what(x) cerr << #x << " is " << x << endl;

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

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  ll N, X; cin >> N >> X;
  vector<ll> x(N); rep(i,N) cin >> x[i];
  vector<ll> d;
  rep(i,N){
    d.pb(abs(x[i] - X));
  }
  ll ans = d[0];
  rep(i,(int)d.size()){
    ans = gcd(ans, d[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
N = int(input())
TA = [[int(i) for i in input().split()] for _ in range(N)]
ans = [i for i in TA[0]]
for ta in TA[1:]:
    t, a = ta
    if t == a == 1:
        m = max(ans)
        ans = [m, m]
        continue
    si = 0
    sn = t
    ln = a
    if t > a:
        si = 1
        sn = a
        ln = t
    if ans[si] % sn:
        ans[si] = ans[si] // sn * sn + sn
    n = ans[si] // sn * ln
    if ans[si ^ 1] <= n:
        ans[si ^ 1] = n
    else:
        if ans[si ^ 1] % ln:
            ans[si ^ 1] = ans[si ^ 1] // ln * ln + ln
        ans[si] = ans[si ^ 1] // ln * sn
print(sum(ans))

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

typedef long long ll;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans=0;
    char prev = '?';
    for (int i=0; i<n; i++) {
        if (s[i] == prev) {
            continue;
        }
        ans++;
        prev = s[i];
    }
    cout << ans;
    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 4e5 + 5;

int N,M,C,B[maxn];

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

  cin>>N>>M>>C;
  for (int i=0; i<M; i++) {
    cin>>B[i];
  }
  int ans=0;
  for (int i=0; i<N; i++) {
    int cur=C;
    for (int j=0; j<M; j++) {
      int A; cin>>A;
      cur += A*B[j];
    }
    if (cur>0) ans++;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, ans = -1;
  cin >> a >> b >> c >> d;
  int i = 2;
  while(a > 0){
    if(i % 2 == 0){
    	c-=b;
    } else a-=d;
    i++;
    if(a <= 0) {
    	ans = 1;
      	break;
    } else if(c <= 0) {
    	ans = 0;
      	break;
    }
  }
  cout << (ans?"No\n":"Yes\n");
}

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

using namespace std;

constexpr int MOD = 1000000007;

using Long = long long;
template<typename T>
using V = vector<T>;
template<typename T>
using Vv = V<V<T>>;
using Vb = V<bool>;
using Vvb = V<Vb>;
using Vi = V<int>;
using Vvi = V<Vi>;
using Vl = V<Long>;
using Vvl = V<Vl>;
using Vd = V<double>;
using Vvd = V<Vd>;
using Vs = V<string>;

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v);

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

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v) {
    is >> v.first >> v.second;
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (const auto& x : v) {
        os << x << ' ';
    }
    return os;
}

// *** SOLUTION BEGIN ***

int h, w;
Vs mat;

void gen(int n, bitset<12> used, vector<int>& cur, vector<vector<int>>& res) {
    for (int i = 0; i < n; ++i) {
        if (!used.test(i)) {
            used.set(i);
            for (int j = i + 1; j < n; ++j) {
                if (!used.test(j)) {
                    used.set(j);
                    cur[i] = j;
                    cur[j] = i;
                    gen(n, used, cur, res);
                    used.reset(j);
                }
            }
            used.reset(i);
            return;
        }
    }
    res.push_back(cur);
}

void solve() {
    cin >> h >> w;
    mat.resize(h);
    cin >> mat;
    vector<vector<int>> a, b;
    if (h % 2 == 1) {
        for (int i = 0; i < h; ++i) {
            vector<int> cur(h);
            cur[i] = i;
            bitset<12> used;
            used.set(i);
            gen(h, used, cur, a);
        }
    } else {
        vector<int> cur(h);
        bitset<12> used;
        gen(h, used, cur, a);
    }
    if (w % 2 == 1) {
        for (int i = 0; i < w; ++i) {
            vector<int> cur(w);
            cur[i] = i;
            bitset<12> used;
            used.set(i);
            gen(w, used, cur, b);
        }
    } else {
        vector<int> cur(w);
        bitset<12> used;
        gen(w, used, cur, b);
    }
    for (const auto& x : a) {
        for (const auto& y : b) {
            bool ok = true;
            for (int i = 0; i < h && ok; ++i) {
                for (int j = 0; j < w && ok; ++j) {
                    int k = x[i];
                    int l = y[j];
                    if (mat[i][j] != mat[k][l]) {
                        ok = false;
                    }
                }
            }
            if (ok) {
                cout << "YES";
                return;
            }
        }
    }
    cout << "NO";
}

// *** SOLUTION END ***

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    solve();
    return 0;
}


Measured memory_bytes: 2108
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,k=mii()

arr = [i for i in range(0,n+1)]
lenarr = len(arr)

S = [0]
for i in range(0, lenarr):
    S.append(S[i] + arr[i])
#print(S)
ans=0
for i in range(k,n+2):
    a = S[-1]-S[-1-i] - S[i]
    ans+=a+1

print(ans%mod)

Measured memory_bytes: 100016
import java.util.Scanner;

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

        int area = a*b;
        int around = (a+b)*2;

        System.out.println(area + " " + around);
    }
}


Measured memory_bytes: 26140
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var S = line[0];
        var C = line[1];
        var ans = 0L;
        var c = C / 2;
        if (S < c)
        {
            C -= S * 2;
            ans += (S+(C / 4));
        }
        else ans = c;
        Console.WriteLine(ans);
    }
}

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


vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
            }
    }
    sort(begin(ret), end(ret));
//  sort(ret.begin(), ret.end(), greater<ll>());
    return (ret);
}


int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> vec = divisor(m);
    rep (i, vec.size()){
        if (vec[i] >= n){
            cout << m/vec[i] << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
block = list(map(int, input().split()))
num = 1
times = 0
j = 0
while j < N:
  if block[j] != num:
    times += 1
  else:
    num += 1
  j += 1
if num != 1:
  print(times)
else:
  print("-1")


Measured memory_bytes: 26140
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int a, b;
	int a_score, b_score;

	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}

		a_score = b_score = 0;

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

			if (a > b){
				a_score += a + b;
			}
			else if (a < b){
				b_score += a + b;
			}
			else {
				a_score += a;
				b_score += b;
			}
		}

		printf("%d %d\n", a_score, b_score);
	}

	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	string s = "ACL";
	cin >> num;
	rep(i, num)
		cout << s;
	printf("\n");
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 110
using namespace std;

ll n, m, l, k, ans;
bool v[N];

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), k = read();
	REP(i, 1, k){
		m = read();
		REP(i, 1, m) l = read(), v[l] = 1;
	}
	REP(i, 1, n)
		if (!v[i]) ans++;
	printf("%lld\n", ans);
}

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

Measured memory_bytes: 3764
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

char data[2048][2048];
int danger[2048][2048];
struct Pt{int w, h;};
//int stk[2048];
int biggest[2048];
Pt stk[2048];
void handle(int& top, int& ans, int a, int b, int h)
{
  while (top > 1 && h < stk[top-1].h)
  {
    int w = a - stk[top-2].w;
    int h = stk[top-1].h;
    int s = w * h;
    if (s > ans) ans = s;
    --top;
  }
  stk[top++] = {b, h};
}
int main()
{
  int h, w; scanf("%d %d", &h, &w);
  for (int i = 0; i < h; ++i) scanf("%s", data[i]);
  for (int i = 1; i < h; ++i)
    for (int j = 1; j < w; ++j)
    {
      int c = 0;
      c ^= data[i-1][j-1] == '#';
      c ^= data[i-1][j] == '#';
      c ^= data[i][j-1] == '#';
      c ^= data[i][j] == '#';
      danger[i][j] = c;
    }
  int ans = max(h, w);
  for (int i = 1; i < h; ++i)
  {
    for (int j = 1; j < w; ++j)
    if (danger[i][j]) biggest[j] = i;
    int top = 0;
    int total = 0;
    stk[top++] = {0, 0};
    for (int j = 0; j < w; ++j)
    {
      if (biggest[j] > 0) handle(top, ans, j, j, i - biggest[j] + 1);
      handle(top, ans, j, j + 1, i + 1);
    }
    while (top > 1)
    {
      --top;
      int s = stk[top].h * (w - stk[top-1].w);
      if (s > ans) ans = s;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    vector<bool> used(n,false);
    vector<vector<int>> t(n);
    rep(i,m){
        int a,b;cin>>a>>b;a--;b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    ll res=0;
    
    rep(i,n){
        bool jud=true;
        rep(j,t[i].size()){
            int y=t[i][j];
            if(h[y]>=h[i]){
                jud=false;
                break;
            }
        }
        if(jud) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    int tmp=0;
    int ans=0;
    int keta=0;
    for(int i=1;i<=N;i++){
        tmp=i;
        while(1){
            keta++;
            tmp/=10;
            if(tmp==0){
                break;
            }else{
                continue;
            }
        }
        if(keta%2==1){
            ans++;
        }
        keta=0;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int a[m],sum=0;
  for(int i=0;i<m;i++){  cin>>a[i];
    sum+=a[i];
  }
  if(sum>n) cout<<-1;
  else cout<<n-sum;
  return 0;
}


Measured memory_bytes: 3632
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <array>
#include <algorithm>
using namespace std;

#define MAXN 600

typedef array<short,4> tile;

int n;
tile a[MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++)
		for (int j=0; j<4; j++)
			scanf("%hd", &a[i][j]);
	return 1;
}

void init() {
}

tile rotate(const tile &x, int k=1) {
	tile y;
	for (int i=0; i<4; i++) y[(i+k) % 4] = x[i];
	return y;
}

tile normalize(const tile &x) {
	tile z=x;
	for (int i=1; i<4; i++) {
		tile y=rotate(x, i);
		if (y<z) z=y;
	}
	return z;
}

int mirror(const tile &x) {
	int r = 1;
	for (int i=1; i<4; i++) {
		tile y=rotate(x, i);
		if (y==x) r++;
	}
	return r;
}

tile get_face(const tile &u, const tile &d, int x, int y) {
	return normalize({u[x], u[y], d[3-y], d[3-x]});
}

long solve() {
	map<tile,long> ct;
	map<tile,long> mi;
	for (int i=0; i<n; i++) {
		a[i] = normalize(a[i]);
		ct[a[i]]++;
		mi[a[i]] = mirror(a[i]);
	}
	long ans = 0;
	for (int i=0; i<n; i++) {
		ct[a[i]]--;
		for (int j=i+1; j<n; j++) {
			ct[a[j]]--;
			for (int k=0; k<4; k++) {
				tile d=a[i], u=rotate(a[j], k);
				tile f[4];
				long r = 1;
				for (int t=0; t<4; t++) {
					f[t] = get_face(u, d, t, (t+3)%4);
					r *= mi[f[t]] * ct[f[t]]--;
				}
				//printf("* %d %d %d: %ld\n", i, j, k, r);
				ans += r;
				for (int t=0; t<4; t++) ct[f[t]]++;
			}
			ct[a[j]]++;
		}
		ct[a[i]]++;
	}
	return ans/3;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 159872
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int main(){
	int n, p1, p2;
	while(scanf("%d%d%d", &n, &p1, &p2), n || p1 || p2){
		vector<vector<int> > G(p1 + p2 + 1);
		for(int i = 0; i < n; ++i){
			int x, y;
			char c;
			scanf("%d%d %c%*s", &x, &y, &c);
			G[x].push_back(y << 1 | (c != 'y'));
			G[y].push_back(x << 1 | (c != 'y'));
		}

		queue<int> q;
		vector<char> vis(p1 + p2 + 1);
		vector<vector<int> > c[2];
		for(int i = 1; i <= p1 + p2; ++i){
			if(!vis[i]){
				c[0].push_back(vector<int>());
				c[1].push_back(vector<int>());
				q.push(i << 1);
				vis[i] = 1;
				while(!q.empty()){
					int u = q.front() >> 1;
					int a = q.front() & 1;
					q.pop();
					c[a].back().push_back(u);
					for(size_t j = 0; j < G[u].size(); ++j){
						if(!vis[G[u][j] >> 1]){
							vis[G[u][j] >> 1] = 1;
							q.push(G[u][j] ^ a);
						}
					}
				}
			}
		}

		vector<vector<int> > dp(c[0].size() + 1, vector<int>(p1 + 1));
		vector<vector<int> > from(c[0].size() + 1, vector<int>(p1 + 1));
		dp[0][0] = 1;
		for(size_t i = 0; i < c[0].size(); ++i){
			for(int j = p1; j >= 0; --j){
				for(int k = 0; k <= 1; ++k){
					int t = j - (int)c[k][i].size();
					if(t >= 0 && dp[i][t]){
						dp[i + 1][j] += dp[i][t];
						from[i + 1][j] = k;
					}
				}
				if(dp[i + 1][j] > 1){
					dp[i + 1][j] = 2;
				}
			}
		}

		if(dp.back()[p1] != 1){
			puts("no");
		}
		else{
			vector<int> ans;
			int s = p1;
			for(int i = c[0].size(); i > 0; --i){
				vector<int> &t = c[from[i][s]][i - 1];
				ans.insert(ans.end(), t.begin(), t.end());
				s -= t.size();
			}
			sort(ans.begin(), ans.end());
			for(size_t i = 0; i < ans.size(); ++i){
				printf("%d\n", ans[i]);
			}
			puts("end");
		}
	}
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
//const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair

const ll MOD = 998244353;

const int MAXN = 3010;


int main() {
  int n;
  cin >> n;
  vi p(n);
  rep (i, n) {
    cin >> p[i];
  }
  vi dp(n + 1, -inf);
  dp[0] = 0;
  int ma = -inf;
  rep (i, n) {
    if (dp[p[i] - 1] < 0) {
      dp[p[i]] = 1;
    }
    else {
      dp[p[i]] = dp[p[i] - 1] + 1;
    }
    chmax(ma, dp[p[i]]);
  }
  
  cout << n - ma << endl;
}


Measured memory_bytes: 1792
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [[String]] -> [Int]
solve = iter 0 0 where
    iter l r [] = [l, r]
    iter l r ([lw,rw]:ws)
        | lw > rw = iter (l+3) r ws
        | lw < rw = iter l (r+3) ws
        | otherwise = iter (l+1) (r+1) ws

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[String]]
readLines 0 = return []
readLines n = getLine >>= (\a -> fmap (words a:) (readLines (pred n)))
            
main :: IO() 
main = do
    [n] <- readLine
    l  <- readLines n
    putStrLn $ init $ foldl (\b n -> b++show n++" ") [] (solve l)



Measured memory_bytes: 4472
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

#define type pair<int,pair<int,int>>
#define x first
#define y second

int n,m;
int ch,cw,dh,dw;
char arr[1006][1006];
int vis[1006][1006];
int32_t main()
{
    IOS;
    cin>>n>>m;
    cin>>ch>>cw>>dh>>dw;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        for(int j=1;j<=m;j++)
            arr[i][j]=s[j-1];
    }
    priority_queue<type,vector<type>,greater<type>> pq;
    for(int i=0;i<1004;i++)
        for(int j=0;j<1004;j++)
            vis[i][j]=1e18;
    pq.push({0,{ch,cw}});
    int move1[]={1,0,-1,0};
    int move2[]={0,1,0,-1};
    while(pq.size())
    {
        auto a=pq.top();
        pq.pop();
        if(vis[a.y.x][a.y.y]<=a.x)
            continue;
        vis[a.y.x][a.y.y]=a.x;
        for(int i=0;i<4;i++)
            if(arr[a.y.x+move1[i]][a.y.y+move2[i]]=='.')
                if(vis[a.y.x+move1[i]][a.y.y+move2[i]]>a.x)
                    pq.push({a.x,{a.y.x+move1[i],a.y.y+move2[i]}});
        for(int i=a.y.x-2;i<=a.y.x+2;i++)
            for(int j=a.y.y-2;j<=a.y.y+2;j++)
                if(i>0 && i<n+1 && j>0 && j<m+1)
                {
                    if(arr[i][j]=='.')
                        if(vis[i][j]>a.x+1)
                            pq.push({a.x+1,{i,j}});
                }
    }
    if(vis[dh][dw]>1e17)
        print(-1);
    else
        print(vis[dh][dw]);
}

Measured memory_bytes: 15264
#include<bits/stdc++.h>
#define M 100005
#define ll long long
using namespace std;
const int mod=1e9+7;
int cnt[30],n;
ll ans=1;
char str[M];
int main(){
	scanf("%d%s",&n,str+1);
	for(int i=1;i<=n;++i)
		cnt[str[i]-'a']++;
	for(int i=0;i<26;++i)
		ans=ans*(cnt[i]+1)%mod;
	printf("%lld\n",(ans-1+mod)%mod);
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		String n =sc.next();
		int m = Integer.parseInt(n);
		String k = sc.next();
		int l = Integer.parseInt(k);
		int cnt =0;
		for (int i=1; i<=m ;i++) {
			String hi = sc.next();
			int hii = Integer.parseInt(hi);
			if(hii >= l) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


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

int main() {
  int n, k;
  string S;
  cin >> n >> k >> S;

  char tmp = S[0];
  int count = 1;
  for(int i = 1; i < n; ++i) {
    if (S[i] == tmp) continue;
    count++;
    tmp = S[i];
  }
  
  count -= k*2;
  if (count < 1) count = 1;
  cout << n - count << endl;
  return 0;
}

Measured memory_bytes: 512
from collections import deque

n,LIMIT = map(int,input().split())

Q = deque()

class Info:
    def __init__(self,arg_name,arg_rest_time):
        self.name = arg_name
        self.rest_time = arg_rest_time

for i in range(n):
    tmp = input().split()
    Q.append(Info(tmp[0],int(tmp[1])))

current_time = 0

while len(Q)>0:
    info = Q.popleft()
    if info.rest_time > LIMIT:
        info.rest_time -= LIMIT
        current_time += LIMIT
        Q.append(info)
    else:
        current_time += info.rest_time
        print("%s %d"%(info.name,current_time))


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

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

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    vector<ll> x(5);
    REP(i, 5) cin >> x[i];

    REP(i, 5){
        if(x[i] == 0) cout << i+1 << endl;
    }   

    return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys
import collections

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


N = I()
A = LI()
A.sort()
cnt = collections.Counter(A)
end = A[-1] + 1

for a in A:
    if cnt[a] >= 2:
        del cnt[a]
    for i in range(a * 2, end, a):
        del cnt[i]

print(sum(cnt.values()))


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

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

    
    
    if(a == b && b == c && a == c){
        cout << 1 << endl;
    } else if(a == b || b == c || c == a) {
        cout << 2 << endl;
    }
    else {
        cout << 3 << endl;
    }
}

Measured memory_bytes: 256
#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(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

vector<string> e(string s)
{
    int S = s.size();
    vector<string> ret;

    int st = 0;
    while(st<S)
    {
        int idx = st;
        while(idx<S && s[idx]!='|') ++idx;
        ret.pb(s.substr(st,idx-st));
        st = idx+1;
    }
    return ret;
}

int cv(char c)
{
    if('a'<=c && c<='z') return c-'a';
    return 26+c-'A';
}

bool c(string s)
{
    s = s.substr(1,s.size()-2);
    int S = s.size();

    vector<string> v;
    int st = 0;
    while(st<S)
    {
        int idx = st;
        while(idx<S && s[idx]!='&') ++idx;
        v.pb(s.substr(st,idx-st));
        st = idx+1;
    }

    bool t[52]={}, f[52]={};
    for(string a:v)
    {
        if(a[0]=='~') f[cv(a[1])] = true;
        else t[cv(a[0])] = true;
    }

    rep(i,52)if(t[i]&&f[i]) return false;
    return true;
}

string solve(string s)
{
    for(string a:e(s))if(c(a)) return "yes";
    return "no";
}

int main()
{
    string s;
    while(cin >>s,s!="#") cout << solve(s) << endl;
    return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

/* -- template -- */
const int MAX_H = 21;
int H, W;

string S[MAX_H];

int vec[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

int main() {
    cin >> H >> W;
    rep(i, H) cin >> S[i];
    int ans = 0;
    rep(h, H) {
        rep(w, W) {
            if(S[h][w] == '#')continue;
            vector<vector<int>>dist(H, vector<int>(W, INF));
            dist[h][w] = 0;
            queue<P> Q;
            Q.push(mp(h, w));
            while(!Q.empty()) {
                P q = Q.front();Q.pop();
                rep(i, 4) {
                    int h_next = q.first + vec[i][0], w_next = q.second + vec[i][1];
                    if(h_next < 0 || h_next >= H || w_next < 0 || w_next >= W)continue;
                    if(S[h_next][w_next] == '#')continue;
                    if(dist[h_next][w_next] == INF) Q.push(mp(h_next, w_next));
                    dist[h_next][w_next] = min(dist[h_next][w_next], dist[q.first][q.second] + 1);
                }
            }
            rep(i, H){
                rep(j, W){
                    if(dist[i][j] != INF)ans = max(ans, dist[i][j]);}}
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    
    //計算
    d = a/b;
    r = a%b;
    f = (a*1.0)/(b*1.0);
    printf("%d %d %lf\n", d, r, f);
    
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a.at(i);
	}
	int cost = 4000000;
	for(int i = -100; i <= 100; i++){
		int sum = 0;
		for(int j = 0; j < n; j++){
			sum += pow(a.at(j) - i, 2);
		}
		cost = min(cost, sum);
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
H,W,M=map(int,input().split())
L=[0 for _ in range(H)]
C=[0 for _ in range(W)]
B={}
for _ in range(M):
    a,b=map(int,input().split())
    B[str(a)+","+str(b)]=0
    L[a-1]+=1
    C[b-1]+=1

LM=max(L)
CM=max(C)

l=[]
c=[]
for j in range(H):
    if L[j]==LM:
        l.append(j)

for k in range(W):
    if C[k]==CM:
        c.append(k)

ans=LM+CM-1

for a in l:
    for b in c:
        if str(a+1)+","+str(b+1) not in B:
            ans=LM+CM
            break
    if ans==LM+CM:
        break
print(ans)


Measured memory_bytes: 67132
n = gets.to_i
a = gets.split.map(&:to_i).sort

x = a.pop
y = a.shift
ans = []
a.each{|z|
  if z >= 0
    ans << [y,z]
    y -= z
  else
    ans << [x,z]
    x -= z
  end
}
ans << [x, y]

p x-y
ans.each{|t| puts t*" "}


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

int main(void){
   
   int a,b,c;
   cin >> a >> b >> c;
   map<int,int> m{};
   m[a] = 1;
   m[b] = 1;
   m[c] = 1;
   cout << m.size() <<endl;
}

Measured memory_bytes: 3624
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	aa := makeInts(n, m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			aa[i][j] = getNextInt(scanner) - 1
		}
	}

	ans := n
	ii := make([]int, n)

	zero := make([]int, m)
	counter := make([]int, m)
	delete := make([]int, m)

	for d := 0; d < m-1; d++ {
		copy(counter, zero)
		for i := 0; i < n; i++ {
			for delete[aa[i][ii[i]]] == 1 {
				ii[i]++
			}
			counter[aa[i][ii[i]]]++
		}
		mx := 0
		mi := 0
		for i := 0; i < m; i++ {
			if mx < counter[i] {
				mx = counter[i]
				mi = i
			}
		}
		if ans > mx {
			ans = mx
		}
		delete[mi] = 1
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}
func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


Measured memory_bytes: 2048
#include <cmath>
#include <cstdio>
 
int main() {
  int a, b, C;
  scanf("%d%d%d", &a, &b, &C);
 
  const double PI = 3.141592653589;
  double S = a * b * sin(C * PI / 180) / 2;
  double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * PI / 180));
  double h = S * 2 / a;
 
  printf("%f %f %f\n", S, L, h);
 
  return 0;
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<"\n";
    else cout<<"ABC"<<"\n";
}

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

int main() {
	int n,k,h;
	int count=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h;
		if(h>=k){
			count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    int n;
    string s,buf,ans;
    cin>>n>>s;
    for(int i=0;i<s.length();i++){
        s[i]+=n;
        if((int)s[i]>90){
            s[i]-=26;
        }
    }
    cout<<s;
    //cout<<(int)'Z';
}


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

int main(){
  int n,s;
  cin>>n;
  s = 0;
  
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    s += b-a+1;
  }
  
  cout<<s<<endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int N, M;
vector<int> A,B;
void input(){
    fast_io();
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b;
        a--, b--;
        A.push_back(a);
        B.push_back(b);
    }
    
}

int solve(){
    UnionFind uf(N);
    for (int i = 0; i < M; i++)
    {
        uf.unite(A[i], B[i]);
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 5932
A, B, M = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
coupons = []
for _ in range(M):
    coupons.append(list(map(int, input().split())))

a_min = min(As)
b_min = min(Bs)

best_sum = a_min+b_min
coupons_sums = []
for l in coupons:
    coupons_sums.append(As[l[0]-1] + Bs[l[1]-1] - l[2])
    
for coupons_sum in coupons_sums:
    if best_sum > coupons_sum:
        best_sum = coupons_sum

print(best_sum)

Measured memory_bytes: 42404
#include <stdio.h>
int main(){

  int x,alph[26]={0},i;
  char ch;

  for(i = 0; i < 1200; i++){

      scanf("%c",&ch);
      
      if (ch >= 'A' && ch <= 'Z'){
	
	x=ch-'A';
	
	alph[x]++;
	
      } else if (ch >= 'a' && ch <= 'z'){
	
	x=ch-'a';
	
	alph[x]++;
	
      }
      
  }

  for(i = 0; i < 26; i++){

    printf("%c : %d\n",'a'+i,alph[i]);

  }

  return 0;

}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if (K <= A) {
    cout << K << endl;
  } else if (K <=  A+ B) {
    cout << A << endl;
  } else {
    cout << A - (K - A - B) << endl;
  }
  
  
  
  
  
  
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n;
    cin >> n;
    int A[100005],dp[100005];

    FORN(i,1,n)
        cin >> A[i];

    dp[n]=0;
    dp[n-1]=abs(A[n]-A[n-1]);

    FORRN(i,n-2,1)
        dp[i]=min(dp[i+1]+abs(A[i]-A[i+1]),dp[i+2]+abs(abs(A[i]-A[i+2])));

    cout << dp[1] << endl;

    return 0;
}


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

map<string,int> res;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    cin >> t;
    for(int i=0;i<t;i++){
        string line;
        cin >> line;
        res[line]++;
    }
    cout<< "AC x " << res["AC"] << "\n";
    cout<< "WA x " <<  res["WA"] << "\n";
    cout<< "TLE x " << res["TLE"] << "\n";
    cout<< "RE x " << res["RE"] << "\n";
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class BIT:

    def __init__(self, n):
        # 0-indexed
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def get(self, l, r=None):
        """ 区間和の取得 [l, r) """
        # 引数が1つなら一点の値を取得
        if r is None: r = l + 1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res

    def bisearch_left(self, l, r, x):
        """ 区間l,rで左からx番目の値がある位置 """
        l_val = self.sum(l)
        ok = r
        ng = l
        while ng+1 < ok:
            mid = (ok+ng) // 2
            if self.sum(mid) - l_val >= x:
                ok = mid
            else:
                ng = mid
        return ok

    def bisearch_right(self, l, r, x):
        """ 区間l,rで右からx番目の値がある位置 """
        r_val = self.sum(r)
        ok = r
        ng = l
        while ng+1 < ok:
            mid = (ok+ng) // 2
            if r_val - self.sum(mid) < x:
                ok = mid
            else:
                ng = mid
        return ok

N = INT()
A = LIST()
# aの昇順に処理できるようにindexで並べておく
idxs = [0] * (N+1)
for i, a in enumerate(A):
    idxs[a] = i + 1

bit = BIT(N+2)
# 先頭と末尾に番兵を仕込む
bit.add(0, 2)
bit.add(N+1, 2)
ans = [0] * (N+1)
# 大きいaから見ていく
for a in range(N, 0, -1):
    # a(N~1)が格納されているindex
    idx = idxs[a]
    # 自分より小さいindexで2回目に自分より大きい値がある直前の場所
    p = bit.bisearch_right(-1, idx, 2) + 1
    # 自分より小さいindexで最初に自分より大きい値がある直前の場所
    q = bit.bisearch_right(-1, idx, 1) + 1
    # 自分より大きいindexで最初に自分より大きい値がある直前の場所
    r = bit.bisearch_left(idx, N+1, 1) - 1
    # 自分より大きいindexで2回目に自分より大きい値がある直前の場所
    s = bit.bisearch_left(idx, N+1, 2) - 1
    # aを使う回数 * a = (左に自分より大きい値がある時の通り数 + 右に自分より大きい値がある時の通り数) * a
    ans[a] = ((q-p)*(r-idx+1) + (idx-q+1)*(s-r)) * a
    # aを出現済とする
    bit.add(idx, 1)
# 全てのaについての合計
print(sum(ans))


Measured memory_bytes: 59244
# -*- coding: utf-8 -*-

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input()) - 1
print(A[k])

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include <iosfwd>
#include <sstream>
#include<stdio.h>
using namespace std;
#define _dg cout << "debug" << endl;
int main(){
    int n,m;

    int fin=0;
    cin >> n >> m;
    vector<int> like(m, 0);
    int k;
    for(int i=0; i< n; i++){
        cin >> k;
        for(int j=0; j<k; j++){
            int a;
            cin >> a;
            like[a-1]++;
            // for(int d:like){
            //     cout << d;
            // } cout << endl;
            
            if(like[a-1]==n){
                fin++;
            }
        }
    }
    cout << fin <<endl;

}

Measured memory_bytes: 256
N,M,X,Y=[int(s) for s in input().split()]
lsx=[int(s) for s in input().split()]
lsy=[int(s) for s in input().split()]
lsx.append(X)
lsy.append(Y)
x=max(lsx)
y=min(lsy)
if x<y:
  print("No War")
else:
  print("War")


Measured memory_bytes: 3060
from collections import Counter
N= int(input())
a = list(map(int, input().split()))

b = a[:]
c = a[:]
for i in range(N):
    b[i] += i
    c[i] -= i

cnt1 = Counter(b)
cnt2 = Counter(c)

lst = list(cnt1.keys())
lst.sort()

ans = 0

for i in range(len(lst)):
    ans += cnt1[lst[i]] * cnt2[-lst[i]]

print(ans)

Measured memory_bytes: 63636