akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 

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

    int sufR[n];
    int sufG[n];
    int sufB[n];
    MEM(sufR,0);MEM(sufG,0);MEM(sufB,0);
    if(s[n-1] == 'R')sufR[n-1] = 1;
    if(s[n-1] == 'G')sufG[n-1] = 1;
    if(s[n-1] == 'B')sufB[n-1] = 1;
    
    for(int i=n-2;i>=0;i--){
        sufR[i] += sufR[i+1];sufG[i] += sufG[i+1];sufB[i] += sufB[i+1];
        if(s[i] == 'R')sufR[i] += 1;
        if(s[i] == 'G')sufG[i] += 1;
        if(s[i] == 'B')sufB[i] += 1;
    }

    ll ans = 0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(s[i] == s[j])continue;
            ll tmp=0;
            if(s[i] == 'R'){
                if(s[j] == 'G'){
                    tmp = sufB[j+1];
                    if(j*2-i < n && s[j*2-i] == 'B')tmp--;
                }
                else if(s[j] == 'B'){
                    tmp = sufG[j+1];
                    if(j*2-i < n &&  s[j*2-i] == 'G')tmp--;
                }
            }
            else if(s[i] == 'G'){
                if(s[j] == 'R'){
                    tmp = sufB[j+1];
                    if(j*2-i < n &&  s[j*2-i] == 'B')tmp--;
                }
                else if(s[j] == 'B'){
                    tmp = sufR[j+1];
                    if(j*2-i < n &&  s[j*2-i] == 'R')tmp--;
                }
            }
            else if(s[i] == 'B'){
                if(s[j] == 'R'){
                    tmp = sufG[j+1];
                    if(j*2-i < n &&  s[j*2-i] == 'G')tmp--;
                }
                else if(s[j] == 'G'){
                    tmp = sufR[j+1];
                    if(j*2-i < n &&  s[j*2-i] == 'R')tmp--;
                }
            }
            ans += tmp;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int G[105][105];
ll dis[105][105];
int n,m;
void floyd(){
    fore(k,0,n)
        fore(i,0,n)
            fore(j,0,n)
                dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);

}
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    cin >> n >> m;
    int u,v,w;
    fore(i,0,105)
        fore(j,0,105)
            dis[i][j] = INF;
    fore(i,0,m){
        cin >> u >> v >> w;
        u--;
        v--;
        G[u][v] = G[v][u] = w;
        dis[u][v] = dis[v][u] = w;
    }
    
    floyd();
    ll par = 0;
    fore(i,0,n)
        fore(j,0,n)
            par = max(par,dis[i][j]);
    int ans = 0;
    fore(i,0,n)
        fore(j,0,n)
            if(G[i][j] && G[i][j] > dis[i][j])
                ans++;
        
        
    cout << ans / 2 << '\n';
    return 0;   
}

Measured memory_bytes: 384
import numpy as np

N = int(input())
p = list(map(int, input().split()))
Jud = 0

for i in range(N - 1):
  for j in range(N - i):
    p[i], p[i + j] = p[i + j], p[i]
    if sorted(p) == p:
      Jud = 1
      break
      
    p[i], p[i + j] = p[i + j], p[i]
    
  else:
    continue  
  break
  
if Jud == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 12508
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections
import operator
import numpy

def check_cycle(i_pair):
    i_orig_sorted_dict = {i_orig: i_sort for i_orig, i_sort in i_pair}
    cycle_dict = {}
    for i_orig, i_sort in i_pair:
        i_current = i_orig
        while True:
            if not i_current in cycle_dict:
                cycle_dict[i_current] = i_orig
            else:
                break
            i_current = i_orig_sorted_dict[i_current]
    return len(numpy.unique(list(cycle_dict.values())))


N, = map(int, sys.stdin.readline().rstrip().split(" "))
As = list(map(int, sys.stdin.readline().rstrip().split(" ")))
Bs = list(map(int, sys.stdin.readline().rstrip().split(" ")))
AB_sorted = list(sorted(zip(As, Bs), key=operator.itemgetter(1)))
Bs = list(map(operator.itemgetter(1), AB_sorted))
As_original = list(map(operator.itemgetter(0), AB_sorted))
A_i_pair = [(i_orig, i_sort) for i_sort, (i_orig, value) in enumerate(sorted(enumerate(As_original), key=operator.itemgetter(1)))]
As.sort()

# print(Bs)
# print(As_original)
# print(As)

A_reserve_dict = {}
last_reserve = None
for i in range(len(As)):
    if As[i] > Bs[i]:
        print("No")
        break
else:
    # for i in range(len(As)):
    #     if As[i] == As_original[i]:  # すでに一致してる = 1回減らせる
    #         print("Yes")
    #         break
    if check_cycle(A_i_pair) >= 2:
        print("Yes")
    else:
        for i in range(len(As) - 1):
            if As[i + 1] <= Bs[i]:  # i と i+1はどちらでもいい = 1回減らせる
                print("Yes")
                break
        else:
            print("No")
exit(0)

# Fails
# 1 2 3
# 2 3 1

# Fails
# 1 2 3 4
# 3 4 2 1


Measured memory_bytes: 66264
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	while (true) {
		int w, d;

		cin >> w >> d;

		if (w == 0 && d == 0) {
			break;
		}

		vector<int> front(w);
		vector<int> side(d);

		rep(i, w) {
			cin >> front[i];
		}

		rep(i, d) {
			cin >> side[i];
		}

		rep(i, w) {
			rep(j, d) {
				if (front[i] == side[j]) {
					side[j] = 0;
					break;
				}
			}
		}

		int sum = 0;

		rep(i, w) {
			sum += front[i];
		}

		rep(i, d) {
			sum += side[i];
		}

		cout << sum << endl;
	}

	return 0;
}

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

using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
#define vvi vector<vector<int>>
//#define FILE_A_IN

void solve() {
    int n;
    cin >> n;
    vector<int> in(n);
    for (int i = 0; i < n; ++i) {
        cin >> in[i];
    }
    sort(in.begin(), in.end());
    for (int i = in[1]; i >= 1; --i) {
        int c = 0;
        for (int j = 0; j < n; ++j) {
            if(in[j] % i != 0) ++c;
            if(c > 1 ) break;
        }
        if( c  <= 1) {
            cout << i << endl;
            return;
        }
    }
    cout << 1 << endl;
}
int main() {
#ifdef FILE_A_IN
    freopen("a.in", "r", stdin);
#endif
    fio;
        solve();
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    priority_queue<ll> q;
    rep(i, 3) {
        ll a;
        cin >> a;
        q.push(a);
    }

    ll k;
    cin >> k;

    rep(i, k) {
        ll temp = q.top();
        q.pop();
        q.push(temp * 2);
    }

    ll ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

using namespace std;

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

	int count = 0;
	int ansers = 0;
	for(size_t i = 0; i< input.length(); ++i){
		if(input[i] == 'R'){
			count++;
		}
		else{
			count = 0;
		}

		ansers = max(ansers, count);
	}
	cout<< ansers;
}


Measured memory_bytes: 3624
class UnionFind:
    def __init__(self, n=1):
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.parent[y] = x
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y)


from collections import Counter
N, M = map(int, input().split())
uf = UnionFind(N)
s = set()
for i in range(M):
    a, b = sorted(map(int, input().split()))
    a -= 1; b -= 1
    if (a, b) in s:
        continue
    s.add((a, b))
    uf.union(a, b)

for i in range(N):
    uf.find(i)

g = [uf.find(i) for i in range(N)]
ans = max(Counter(g).values())
print(ans)

Measured memory_bytes: 47420
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int K;
  cin >> K;
  int cnt = 0;
  set<string> moji;
  for(int i=0; i<26; i++){
    for(int j=0; j<S.size(); j++){
      if(S.at(j) == 'a'+i){
        cnt += S.size() - j;
        string z = string() + S.at(j);
        moji.insert(z);
      }
    }
    if(moji.size() >= 3){
      break;
    }
    if(cnt >= 15){
      break;
    }
  }
  
  set<string> ans;
  
  for(auto itr = moji.begin(); itr != moji.end(); itr++){
    string x = *itr;
    for(int i=0; i<S.size(); i++){
      if(S.at(i) + string() == x){
        string T = x;
        ans.insert(T);
        for(int j=i+1; j<S.size(); j++){
          T += S.at(j);
          ans.insert(T);
          if(j >= i+6){
            break;
          }
        }
      }
    }
  }

  auto itr = ans.begin();
  for(int i=0; i<K-1; i++){
    itr++;
  }
  cout << *itr << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
void Exponential() {
	int X;
	cin >> X;
	int m = 1;
	for (size_t i = 2; i <= X; i++)
	{
		int ti = i;
		while (ti * i <= X)
		{
			ti *= i;
			m = max(m, ti);
		}
	}
	cout << m;
}
int main() {
	Exponential();
	return 0;
}

Measured memory_bytes: 256
//ABC090B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int count = 0;
	for(int i=a;i<=b;i++){
		int num = i;
		vector<int> x(5);
		int j = 0;
		while(num > 0){
			x.at(j) = num%10;
			num /= 10;
			j++;
		}
		if(x.at(0) == x.at(4) && x.at(1) == x.at(3)){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli power(lli a,lli b,lli m){if(b==0)	return 1;if(b==1)	return a%m;lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n >> d;
    while(n--){
    	cin >> aa >> bb;
    	aa*=aa;
    	bb*=bb;
    	cc=aa+bb;
    	dd=sqrt(cc);
    	if(dd<=d)	ans++;
    }
    cout << ans;
    
    
}















int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

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

typedef long long               ll;
typedef unsigned long long      ull;

const int N = 100 * 1000 + 20;

vector <ll> adj[N];
bool vis[N];
ll d[N], outD[N];

void dfs(ll v) {
    vis[v] = true;
    for (auto u: adj[v]) {
        if (!vis[u]) {
            d[u] = d[v] + 1;
            dfs(u);
        }
        if (d[u] > d[v]) {
            if (!(outD[u] & 1)) {
                outD[v]++;
                cout << v << " " << u << endl;
            }
            else {
                outD[u]++;
                cout << u << ' '  << v << endl;
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    if (m & 1)
        return cout << -1 << endl, 0;
    for (int i = 0, u, v; i < m; i++) {
        cin >> v >> u;
        adj[v].push_back(u);
        adj[u].push_back(v);
    }
    dfs(1);
    return 0;
}


Measured memory_bytes: 14848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 100000000;
const int MAX_N = 100;
int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0 && m == 0)break;
		int t[MAX_N + 1][MAX_N + 1];
		int yen[MAX_N + 1][MAX_N + 1];
		for (int i = 0; i < MAX_N; i++) {
			for (int j = 0; j < MAX_N; j++) {
				if (i == j) t[i][j] = 0, yen[i][j] = 0;
				else t[i][j] = INF, yen[i][j] = INF;
			}
		}
		for (int i = 0; i < n; i++) {
			int a, b, cost, time;
			cin >> a >> b >> cost >> time;
			a--, b--;
			t[a][b] = time, t[b][a] = time;
			yen[a][b] = cost, yen[b][a] = cost;

		}
		for (int k = 0; k < m; k++) {
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < m; j++) {
					t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
					yen[i][j] = min(yen[i][j], yen[i][k] + yen[k][j]);
				}
			}
		}
		int k;
		cin >> k;
		for (int i = 0; i < k; i++) {
			int p, q, r;
			cin >> p >> q >> r;
			if (r == 0) cout << yen[p-1][q-1] << endl;
			else cout << t[p-1][q-1] << endl;
		}
	}
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  int i=0,ans=0;
  while(i<n){
    if(a[i]==a[i+1])
      i+=2;
    else{
      ans++;
      i++;
      }
    }
  cout<<ans<<endl;
  return 0;
  }


Measured memory_bytes: 640
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    int count=0;
    for(int i=0;i<n-2;i++) {
        if(s.charAt(i)=='A' && s.charAt(i+1)== 'B' && s.charAt(i+2)=='C') {
            count++;
        }
    }
    System.out.println(count);
}
}


Measured memory_bytes: 21844
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
int main(){
  ll int a,b,n,k,x,max=0,ans=0;
  scanf("%lld %lld %lld",&a,&b,&n);
  if(n>=b){
   for(x=b-1;x<=n;x++){
    ans=(a*x)/b -a*(x/b);
     if(max<ans){
       max=ans;
     }
     else{
       goto lavel;
     }
   }
  }
  else{
    max=(a*n)/b;
  }
  lavel: printf("%lld",max);
  return 0;
}

Measured memory_bytes: 1696
#include<stdio.h>
#define N 101000
int a[N],b[N];
int main(){
  int n;
  scanf("%d",&n);
  for (int i=1;i<=n;i++)scanf("%d%d",a+i,b+i);
  long long ans=0;
  for (int i=n;i>=1;i--){
    a[i]=(ans+a[i])%b[i];
    if (a[i]!=0) ans+=b[i]-a[i];
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define MAX std::numeric_limits<lld>::max();
#define MIN std::numeric_limits<lld>::min();
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
lld lvl[2001][2001];
void dfs(vector<lld> V[], lld s, lld i){
	set <lld> visit;
	queue <lld> que;
	lld y, j;
	lvl[s][i]  =  0;
	visit.insert(i);
		que.push(i);
		while (!que.empty()){
			y = que.front();
				que.pop();
				for(j = 0; j<V[y].size(); j++){
					if (!visit.count(V[y][j])){
						visit.insert(V[y][j]);
							que.push(V[y][j]);
							lvl[s][V[y][j]] = lvl[s][y] + 1;
					}
				}
		}
}
int main (){
    FastIO
    lld n, x;
    lld y, i;
    cin >> n;
    cin >> x;
    cin >> y;
    lld j;
    vector <lld> V[n + 1];
    for(i = 2; i<=n; i++){
    	lld j = i-1;
    	V[i].push_back(j);
    	V[j].push_back(i);
    }
    	V[x].push_back(y);
    	V[y].push_back(x);
    for(i = 1; i<=n; i++){
    	dfs(V, i,i);
    }
    set<lld>dist[n];
    for(i = 1; i<=n; i++){
    for(j = 1; j<=n; j++){
    	dist[lvl[i][j]].insert(((i+j) * (i+j+1)) / 2 + j);
    }
    }
    for(i = 1; i< n; i++){
    cout <<dist[i].size() / 2;
    cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 219264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
    ll a, v, b, w;
    cin >> a >> v >> b >> w;
    ll t;
    cin >> t;
    ll length = abs(a-b);
    string ans = "YES";
    if(v<=w) ans = "NO";
    if(length > t*(v-w)) ans = "NO";
    if(a==b) ans = "YES";

    cout << ans << endl;    
}

Measured memory_bytes: 3628
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var nk = lines[0].split(' ');
 var n = Number(nk[0]);
 var k = Number(nk[1]);
 var ans = new Set();
 for(i=2; i<=k*2; i+=2){
   var a = lines[i].split(' ');
   if(a.length > 1){
     for(j=0; j<a.length; j++){
        ans.add(a[j]);
     }
   }else{
   a = a.join('');
   ans.add(a);
 }
 }
 console.log(n - ans.size);
});


Measured memory_bytes: 30064
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
#define pb push_back
using namespace std;
const int S = 1;
const int INF = 0x3f3f3f3f;
const int N = 300010;
int n, s, t, tot;
vector<int> hv[N];
int cnt = 1, cur[N * 4], hed[N * 4], to[N * 4], nxt[N * 4], val[N * 4];
int dep[N], bl[N];
int ax[N], ay[N], la, fr[N], id[N]; bool vis[N];

inline void add(int x, int y, int z) {
	to[++cnt] = y, nxt[cnt] = hed[x], hed[x] = cnt, val[cnt] = z;
	to[++cnt] = x, nxt[cnt] = hed[y], hed[y] = cnt, val[cnt] = 0;
}
bool bfs() {
	queue<int> q; rep(i, s, t) dep[i] = 0; dep[s] = 1, q.push(s);
	for(int u; !q.empty();) {
		u = q.front(), q.pop();
		for(int i = cur[u], ii = cur[u];;) {
			if(val[i] && !dep[to[i]]) dep[to[i]] = dep[u] + 1, q.push(to[i]);
			i = nxt[i]; if(!i) i = hed[u]; if(i == ii) break;
		}
	}
	return dep[t];
}
int dfs(int u, int flow) {
	if(u == t) return flow;
	for(int i = cur[u], ii = cur[u];;) {
		if(dep[to[i]] == dep[u] + 1 && val[i]) {
			int w = dfs(to[i], min(flow, val[i]));
			if(w) { cur[u] = i, val[i] -= w, val[i ^ 1] += w; return w; }
		}
		i = nxt[i]; if(!i) i = hed[u]; if(i == ii) break;
	}
	dep[u] = 0; return 0;
}
int Dinic() {
	int flow = 0; rep(i, s, t) cur[i] = hed[i];
	for(; bfs();) for(int ad = dfs(s, INF); ad; flow += ad, ad = dfs(s, INF));
	return flow;
}
inline bool cmp(const int &x, const int &y) { return fr[x] < fr[y]; }
int main() {
	scanf("%d", &n), s = 0, t = n + n; rep(i, 2, n) add(n - 1 + i, t, 1);
	rep(i, 1, n - 1) {
		add(s, i, 1); int k; scanf("%d", &k);
		for(int x; k; --k) {
			scanf("%d", &x), hv[x].pb(i); if(x != S) add(i, n - 1 + x, 1);
		}
	}
	int Flow = Dinic(); if(Flow != n - 1) { puts("-1"); return 0; }
	queue<int> q; q.push(S);
	for(int i = 2; i <= cnt; i += 2) if(!val[i]) {
		int y = to[i] - n + 1, x = to[i ^ 1];
		if(x == s || x >= n || y <= 1 || y > n) continue;
		bl[x] = y;
	}
	for(int u; !q.empty();) {
		u = q.front(), q.pop(), ++tot;
		for(auto v : hv[u]) if(!vis[v]) {
			vis[v] = 1, q.push(bl[v]), ++la, ax[la] = u, ay[la] = bl[v], fr[la] = v, id[la] = la;
		}
	}
	if(tot != n) { puts("-1"); return 0; }
	sort(id + 1, id + la + 1, cmp);
	rep(i, 1, n - 1) printf("%d %d\n", ax[id[i]], ay[id[i]]);
	return 0;
}

Measured memory_bytes: 38036
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }

bool sol(string s, ll x, ll y)
{
    ll dp[s.size()+5]; mem(dp, 0);
    dp[x] = 1;
    for(ll i = x; i <= y; i++){
        if(dp[i] == 0) continue;
        if(s[i+1] != '#') dp[i+1] = 1;
        if(s[i+2] != '#') dp[i+2] = 1;
    }
    return dp[y] == 1;
}

void solve()
{
    ll n, a, b, c, d, f = 0;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s; a--, b--, c-- , d--;

    ll dp[s.size()+5]; mem(dp, 0);
    if(c < d){
        for(ll i = b; i < d; i++){
            if(s[i] == s[i+1] && s[i] == '#') f = 1;
        }
        for(ll i = a; i < c; i++){
            if(s[i] == s[i+1] && s[i] == '#') f = 1;
        }
    }
    else{
        for(ll i = a; i < c; i++){
            if(s[i] == s[i+1] && s[i] == '#') f = 1;
        }
        ll fff = 0;
        for(ll i = b; i <= d; i++){
            if(s[i-1] == s[i+1] && s[i] ==  s[i+1] && s[i] == '.') fff = 1;
        }
        if(fff == 0) f = 1;
    }


    if(!f) ANS("Yes");
    ANS("No");

}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 2128
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<string,int> P;

int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			int stage[9][9];

			int freq_x[9][10];
			int freq_y[9][10];
			int sect[9][10];

			memset(freq_x,0,sizeof(freq_x));
			memset(freq_y,0,sizeof(freq_y));
			memset(sect,0,sizeof(sect));

			for(int y=0;y<9;y++){
				for(int x=0;x<9;x++){
					scanf("%d",&stage[y][x]);
				}
			}

			for(int y=0;y<9;y++){
				for(int x=0;x<9;x++){
					freq_x[y][stage[y][x]]++;
				}
			}

			for(int x=0;x<9;x++){
				for(int y=0;y<9;y++){
					freq_y[x][stage[y][x]]++;
				}
			}

			for(int sx=0;sx<9;sx+=3){
				for(int sy=0;sy<9;sy+=3){
					for(int y=sy,i=0;i<3;y++,i++){
						for(int x=sx,j=0;j<3;x++,j++){
							sect[sy+sx/3][stage[y][x]]++;
						}
					}			
				}
			}

			for(int y=0;y<9;y++){
				for(int x=0;x<9;x++){
					printf("%s%d%s",(freq_x[y][stage[y][x]] > 1 
						|| freq_y[x][stage[y][x]] > 1
						|| sect[(y/3)*3+x/3][stage[y][x]] > 1) ? "*" : " ",stage[y][x],x == 9-1 ? "\n" : "");
				}
			}

			printf("%s",i!=n-1 ? "\n" : "");
		}
	}
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    string S;
    string T="NSWE";
    int count=0;
    cin>>S;
    int sum=0;
    int L=S.length();
    for(int i=0;i<L;i++){
       if(S[i]==T[0]){
           for(int j=0;j<L;j++){
               if(S[j]==T[1]){
                   count++;
                   break;
               }
           }
       }
       if(S[i]==T[1]){
           for(int j=0;j<L;j++){
               if(S[j]==T[0]){
                   count++;
                   break;
               }
           }
       }
       if(S[i]==T[3]){
           for(int j=0;j<L;j++){
               if(S[j]==T[2]){
                   count++;
                   break;
               }
           }
       }
       if(S[i]==T[2]){
           for(int j=0;j<L;j++){
               if(S[j]==T[3]){
                   count++;
                   break;
               }
           }
       }
    }
    if(count==L){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3488
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int n;
vi stones;
int memo[100010];

int dp(int at)
{
    if (at >= n) return INF;
    if (at == n - 1) return 0;
    if (memo[at] != -1) return memo[at];
    int ans = dp(at + 1) + abs(stones[at] - stones[at + 1]);
    if (at + 2 < n) ans = min(ans, dp(at + 2) + abs(stones[at] - stones[at + 2]));
    return memo[at] = ans;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    memset(memo, -1, sizeof(memo));
    cin >> n;
    stones.resize(n + 2);
    for (int i = 0; i < n; i++) {
        cin >> stones[i];
    }
    cout << dp(0) << endl;

    return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    vector<long long int> v[26];
    for(int i=0;i<(int)s.length();i++)v[(int)(s[i]-'a')].push_back(i);
    long long int ans=0;
    long long int tmp=0;
    int start=0;
    if(s[0]==t[0])start=1;
    for(int i=start;i<(int)t.length();i++){
        if(v[(int)(t[i]-'a')].size()==0){
            cout << -1;
            return 0;
        }
        int flag=0;
        int u = upper_bound(v[(int)(t[i]-'a')].begin(),v[(int)(t[i]-'a')].end(),tmp)-v[(int)(t[i]-'a')].begin();
        if(u<(int)v[(int)(t[i]-'a')].size()){
            ans+=v[(int)(t[i]-'a')].at(u)-tmp;
            tmp=v[(int)(t[i]-'a')].at(u);
            flag++;
        }
        if(flag==0){
            ans+=(long long int)s.length()-tmp+v[(int)(t[i]-'a')].at(0);
            tmp=v[(int)(t[i]-'a')].at(0);
        }
    }
    cout << ans+1;
}

Measured memory_bytes: 4644
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define rep(i,s,e)  for(int i=s;i<e;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set

const int mxn=3000;
const double pi=acos(-1.0);
int n;

double p[mxn];
double dp[mxn][mxn];
bool vis[mxn][mxn];

double func(int heads,int tails){
	if(heads+tails==n) return (heads>tails);

	if(vis[heads][tails]) return dp[heads][tails];

	vis[heads][tails]=1;
	double ans=(p[heads+tails]*func(heads+1,tails))+(1-p[heads+tails])*func(heads,tails+1);

	return dp[heads][tails]=ans;

}

void solve(){
	cin>>n;

	for(int i=0;i<n;i++){
		cin>>p[i];
	}

	memset(vis,0,sizeof(vis));

	double ans=func(0,0);
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
// #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;

    ll ans = 0;
    for(ll i=1;i<=sqrt(n);++i){
        if(n % i == 0){
            ans = i + n/i - 2;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
int a,b,c,X,Y,n;
cin>>n;
vector<int> s(n),t(n),A(n);
for(int i=0;i<n;i++){
cin>>s.at(i);}
for(int i=0;i<n;i++){
cin>>t.at(i);}
for(int i=0;i<n;i++){
if(s.at(i)>t.at(i)){
X+=s.at(i);
Y+=t.at(i);}}
cout<<X-Y<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

#define ll int

int main () {
    to_pray();

    int n;
    cin >> n;
    
    int sum = 0;
    
    
    for (int i = 1; i <= n; ++ i) {
   		int x;
   		cin >> x;
   		sum += x; 
    }
    
    cout << sum - n;
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);
    cout << '\n';
    return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

const int MAX_N=80;
const int MAX_C=25000000;

int N;
int A[MAX_N+1];
int dp[MAX_N+1];
int ans;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>A[i];
    dp[0]=1000;
    for(int i=0;i<N;++i){
        chmax(dp[i+1],dp[i]);
        for(int j=0;j<=i;++j){
            int pl=(dp[j]/A[j])*A[i];
            int mn=(dp[j]/A[j])*A[j];
            chmax(dp[i+1],dp[j]-mn+pl);
        }
    }
    for(int i=0;i<=N;++i)chmax(ans,dp[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    sort(A, A+N);
    reverse(A, A+N);
    int t = 0;
    while (t+1 < N && A[t+1] > t+1) t++;
    int a = A[t] - t - 1;
    int b = 0;
    while (t+b+1 < N && A[t+b+1] > t) b++;
//    printf("%d %d\n", a, b);
    bool f = (a % 2 == 1 || b % 2 == 1);
    puts(f? "First": "Second");

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int d,i,j,k;
  cin >> d;
  double a[1000]={},b[1000]={};
  for(i=0;i<d;i++) cin >> a[i];
  for(i=0;i<d;i++) cin >> b[i];
  double o1=0,o2=0,o3=0,oe=0;
  for(i=0;i<d;i++){
    o1+=fabs(a[i]-b[i]);
    o2+=fabs(a[i]-b[i])*fabs(a[i]-b[i]);
    o3+=fabs(a[i]-b[i])*fabs(a[i]-b[i])*fabs(a[i]-b[i]);
    oe=max(oe,fabs(a[i]-b[i]));
  }
  printf("%.6f\n",o1);
  printf("%.6f\n",sqrt(o2));
  printf("%.6f\n",pow(o3,1.0/3.0));
  printf("%.6f\n",oe);
  return 0;
}


Measured memory_bytes: 3360
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f;

typedef long long ll;

int n, a[maxn];

int read()
{
	int x;
	scanf("%d", &x);
	return x;
}

int main()
{
	n = read();
	for(int i = 1; i <= n; i ++)
	{
		a[i] = read();
	}
	sort(a + 1, a + n + 1);
	cout << a[n / 2 + 1] - a[n / 2];
}

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

using namespace std;

#define INF 210000000
#define int long long

signed main() {
		int n;
		cin >> n;
		vector<int> a;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				if(tmp % 4 == 0) a.push_back(2);
				else if(tmp % 2 == 0) a.push_back(1);
				else a.push_back(0);
		}
		int sum = accumulate(a.begin(),a.end(),0);
		if(n % 2 == 1) n--;
		if(sum >= n) cout << "Yes" << endl;
		else cout << "No" << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;
int main()
{
    string s;

    cin >> s;

    if(s == "AAA" ||s == "BBB"){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;;
    }
    return 0;
}

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

using namespace std;

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

	/*ｃ、ｄの最小公倍数を求める*/
	long long tmp;
	long long xx;
	long long cc=c;
	long long dd=d;
	xx = c * d;
	if (c < d) {
		tmp = c;
		c = d;
		d = tmp;
	}

	long long r;
	r = c % d;
	while (r != 0) {
		c = d;
		d = r;
		r = c % d;
	}

	long long koubaisuu;
	koubaisuu = xx / d;
	c = cc;
	d = dd;

	long long st, ed;
	long long numm=0;
	if (a%c != 0) {
		st = c * (long long)(a / c) + c;
	}
	else {
		st = a;
	}
	if (b%c != 0) {
		ed = c * (long long)(b / c);
	}
	else {
		ed = b;
	}
	numm += (ed - st)/c + 1;

	if (a%d != 0) {
		st = d * (long long)(a / d) + d;
	}
	else {
		st = a;
	}
	if (b%d != 0) {
		ed = d * (long long)(b / d);
	}
	else {
		ed = b;
	}
	numm += (ed - st)/d + 1;

	if (a%koubaisuu != 0) {
		st = koubaisuu * (long long)(a / koubaisuu) + koubaisuu;
	}
	else {
		st = a;
	}
	if (b%koubaisuu != 0) {
		ed = koubaisuu * (long long)(b / koubaisuu);
	}
	else {
		ed = b;
	}
	numm =numm-( (ed - st)/koubaisuu + 1);

	cout << b-a+1-numm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

ll n;
ll a[100000];
ll so[100000];

bool cmp(ll left, ll right){
    return a[left] < a[right];
}

int main(){
    L(n);
    rep(i,n) so[i] = i;
    rep(i,n) L(a[i]);
    sort(so,so+n,cmp);
    ll sum = a[so[0]];
    int ans = 1;
    for(int i = 1; i < n; i++){
        if(a[so[i]] > sum*2){
            ans = 1;
            sum += a[so[i]];
        } else{
            ans++;
            sum += a[so[i]];
        }
    }
    cout << ans << endl;
}
































Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

bool ck(ll x,ll m,ll k,ll p,vector<ll> v) {
  vector<ll> a,b;
  rep(i,v.size()) {
    if(v[i]>x) a.pb(v[i]);
    else b.pb(v[i]);
  }
  if(a.size()>=p) return 0;
  ll z=min((ll)a.size(),k);
  k-=z;
  p-=a.size();
  ll sum=m*k;
  P c[b.size()];
  rep(i,b.size()) c[i]=P(0,i);
  rep(i,b.size()) {
    ll d=min(m,x-b[i]);
    d=min(d,sum);
    c[i].F+=d;
    sum-=d;
  }
  sort(c,c+b.size());
  rep(i,b.size()) {
    ll d=m-c[i].F;
    d=min(d,sum);
    b[c[i].S]+=d+c[i].F;
    sum-=d;
    if(b[c[i].S]>x) p--;
  }
  if(!sum&&p>=1) return 1;
  return 0;
}

void Main() {
  ll n,m,k,p;
  cin >> n >> m >> k >> p;
  ll a[n];
  rep(i,n) R a[i];
  sort(a,a+n,greater<ll>());
  ll l=-1,r=n;
  while(l+1<r) {
    ll mm=(l+r)/2;
    vector<ll> v;
    rep(i,n) {
      if(i!=mm) v.pb(a[i]);
    }
    if(ck(a[mm]+m,m,k-1,p,v)) l=mm;
    else r=mm;
  }
  pr(r);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 6268
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

vector<int> w;
ll inf = (ll)(1e15);
int n, k;

bool ok(ll p) {
	int W = 0,pow = 1;
	for (int i = 0; i < n; i++) {
		if (w[i] > p) { pow = k + 1; break; }
		if (W + w[i] <= p) {
			W += w[i];
		}
		else {
			W = w[i];
			pow++;
		}
	}
	return pow <= k ? 1 : 0;
}

int main() {
	cin >> n >> k;
	w.resize(n);

	rep(i, n) cin >> w[i];

	ll l = 0, h = inf;
	while (l+1 < h) {
		int m = (l + h) / 2;
		if (ok(m))h = m;
		else l = m;
	}
	cout << h<< endl;
	return 0;
}

Measured memory_bytes: 3112
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int sosu[50000];

int main() {
	sosu[0]=sosu[1]=1;
	for(int i=0;i<50000;i++){
		if(sosu[i])continue;
		for(int j=i*2;j<50000;j+=i){
			sosu[j]=1;
		}
	}
	int n;
	while(n=in()){
		int i;
		int res=0;
		for(i=0;i<=n/2;i++){
			if(sosu[i]+sosu[n-i]==0){
				res++;
			}
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1080
import sys
from collections import deque
input = sys.stdin.readline
 
N, K = list(map(int, input().split()))
ab = []
for i in range(N-1):
    ab.append(list(map(int, input().split())))
 
ki = []
 
for i in range(N):
    ki.append(dict())
    ki[-1]["eda"] = []
 
for i in range(N-1):
    ki[ab[i][0] - 1]["eda"].append([ab[i][0] - 1, ab[i][1] - 1])
    ki[ab[i][1] - 1]["eda"].append([ab[i][1] - 1, ab[i][0] - 1])
 
def P(m ,n):
    num = 1
    for i in range(n):
        num = num * (m-i) % 1000000007
    return num
 
 
 
total_num = K
judge = [False]*N
if len(ki[0]["eda"]) != 0:
    total_num *= P(K-1, len(ki[0]["eda"]))
    judge[0] = True
    node = deque([])
    for edge in ki[0]["eda"]:
        node.append(edge[1])
    while len(node) != 0:
        i = node.popleft()
        judge[i] = True
        if len(ki[i]["eda"]) > 1:
            for edge in ki[i]["eda"]:
                if not judge[edge[1]]:
                    node.append(edge[1])
        total_num *= P(K-2, len(ki[i]["eda"])-1)
        total_num = total_num % 1000000007
        if total_num == 0:
            break
 
print(total_num)

Measured memory_bytes: 119132
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<size_t> P(N);
  for (size_t i=0; i<N; ++i) {
    scanf("%zu", &P[i]);
    --P[i];
  }

  if (std::is_sorted(P.begin(), P.end()))
    return !printf("0\n");

  std::vector<size_t> A(N);
  for (size_t i=0; i<N; ++i) {
    A[P[i]] = i;
  }

  size_t res=0, cur=0, last=0;
  for (size_t i=0; i<N; ++i) {
    if (A[i] > last) {
      ++cur;
    } else {
      res = std::max(res, cur);
      cur = 1;
    }
    last = A[i];
  }
  res = std::max(res, cur);
  printf("%zu\n", N-res);
}


Measured memory_bytes: 3328