akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int MX = 10000;

int a[MX], b[MX];

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0; i < n; i++) ignore = scanf("%d", a + i);
	for (int i = 0; i < n; i++) ignore = scanf("%d", b + i);
	
	long long as = 0, bs = 0;
	for (int i = 0; i < n; i++) as += a[i], bs += b[i];
	
	long long cnt = bs - as;
	if (cnt < 0) {
		printf("No\n");
		return 0;
	}
	
	as = bs = cnt;
	for (int i = 0; i < n; i++) {
		if (b[i] < a[i]) bs -= a[i] - b[i];
		else if (a[i] < b[i]) {
			as -= (b[i] - a[i] + 1) / 2;
			bs -= (b[i] - a[i]) % 2;
		}
	}
	
	if (as < 0 || bs < 0) printf("No\n");
	else printf("Yes\n");
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long n,a,b,c,d,e,t,ans;
cin >> n >> a >> b >> c >> d >> e;
t=min(a,b);t=min(t,c);t=min(t,d);
t=min(t,e);
if (n%t==0) ans=4+n/t;
else ans=5+n/t;
cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define trav(it, a) for(auto& it : a)
#define allin(it, a) for(auto it : a)
#define read(v, a, b) for(int i=(a); i<(b); i++) scanf("%d", &v[i]);
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define db(x) cerr << #x << " == " << x << endl

const int maxn = 1e5 + 100, MOD = 1e9 + 7;

inline int mod(int a, int b){ a %= b; if (a < 0) a += b; return a;} 

int main(){
	int n;
	scanf("%d", &n);
	vector<int> dp(n+1), pref(n+1);
	dp[1] = pref[1] = 1;
	for (int i = 2; i <= n; i++) {
		char last;
		cin >> last;
		if(last == '<') { //that means the item now is in front of the last (pref[j-1])
			for (int j = i; j >= 1; j--) { //calculate the values based on the sum of all the next ones
				dp[j] = mod(pref[j-1],MOD);
			}
			//recalculate the prefix sum of values
			for (int j = 1; j <= i; j++) {
				pref[j] = mod(pref[j-1] + dp[j],MOD);
			}
		}
		else { //that means the item is behind the last one (pref[i] - pref[j-1])
			for (int j = i; j >= 1; j--) { //calculate the values based on the sum of all the next ones
				dp[j] = mod(pref[i-1] - pref[j-1],MOD); //in this case we consider i-1 instead of i because in the last iteration when
														//we calculated the prefix sum i was what now is i-1
			}
			//recalculate the prefix sum of values
			for (int j = 1; j <= i; j++) {
				pref[j] = mod(pref[j-1] + dp[j],MOD);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = mod(ans + dp[i],MOD);
	printf("%d\n", ans);
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void Main()
{
    int n;cin>>n;

    map<string,map<int, int, greater<int>>> mp;


    REP(i,n){
        string s;cin>>s;
        int p;cin>>p;
        mp[s][p] = i+1;
    }
    for(auto x : mp){
        for(auto y : x.second){
            cout<<y.second<<endl;
        }
    }
    
	return;
}

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

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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    cout << (n==m ? "Yes":"No");

        return 0;
}



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

using namespace std;

const int MAX_N = 100000, INDEX = 1;

struct Component {
    int numberOfVertices = 0;

    bool isOddCycle, isAlone;

    Component() {
        numberOfVertices = 0;

        isOddCycle = false, isAlone = true;
    }
};

int n, m;

list<int> edge[MAX_N + INDEX];

bool isUsed[MAX_N + INDEX];

int parity[MAX_N + INDEX];

Component components[MAX_N + INDEX];

void DFS(int c, int v, int parityv) {
    isUsed[v] = true;

    parity[v] = parityv;

    components[c].numberOfVertices++;

    for (auto u: edge[v]) {
        components[c].isAlone = false;

        if (!isUsed[u]) {
            DFS(c, u, (parityv + 1) % 2);
        } else {
            if (parity[u] == parity[v]) {
                components[c].isOddCycle = true;
            }
        }
    }
}

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

    cin >> n >> m;

    for (int i = 1; i <= m; i++) {
        int u, v;

        cin >> u >> v;

        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    int numberOfComponents = 0;
    for (int i = 1; i <= n; i++) {
        if (!isUsed[i]) {
            components[++numberOfComponents] = Component();

            DFS(numberOfComponents, i, 0);
        }
    }

    int numberOfOddComponents = 0, numberOfAloneComponents = 0;
    for (int i = 1; i <= numberOfComponents; i++) {
        if (components[i].isAlone) {
            numberOfAloneComponents++;
        }

        if (components[i].isOddCycle) {
            numberOfOddComponents++;
        }
    }

//    int ans = 0;
//    for (int i = 1; i <= numberOfComponents; i++) {
//        for (int j = 1; j <= numberOfComponents; j++) {
//            if (components[i].isAlone || components[j].isAlone) {
//                ans += components[i].numberOfVertices * components[j].numberOfVertices;
//            } else {
//                if (components[i].isOddCycle || components[j].isOddCycle) {
//                    ans += 1;
//                } else {
//                    ans += 2;
//                }
//            }
//        }
//    }

    long long ans = 0;
    for (int i = 1; i <= numberOfComponents; i++) {
        if (components[i].isAlone) {
            ans += n;
        }

        if (components[i].isOddCycle) {
            ans += numberOfComponents + (components[i].numberOfVertices - 1) * numberOfAloneComponents;
        }

        if (!(components[i].isAlone || components[i].isOddCycle)) {
            ans += (numberOfComponents - numberOfAloneComponents) + (numberOfComponents - numberOfOddComponents) + (components[i].numberOfVertices - 1) * numberOfAloneComponents;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 19328
#include<stdio.h>

int main(void){
  long long x , y;
  scanf("%lld %lld",&x ,&y);

  long long ans = 0;
  long long k = x;
  while(k <= y){
    k *= 2;
    ans ++;
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    vector<int> v(n);
    for(int i = 0; i < n; i++) v[i] = i;
    double sum = 0;
    do
    {
        double dis = 0;
        for(int i = 0; i < n-1; i++)
        {
            //v[i] to v[i+1]
            int pre = v[i];
            int nx = v[i+1];
            dis += sqrt((x[pre] - x[nx]) * (x[pre] - x[nx]) + (y[pre] - y[nx]) * (y[pre] - y[nx]));
        }
        sum += dis;
    }
    while(next_permutation(v.begin(), v.end()));
    for(int i = 2; i <= n; i++) sum /= i;
    printf("%.10f\n", sum);
}



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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)

bool comp(string s, bool f = true) {
    cout << "? " << s;
    if(f) {
        rep(i, 13 - s.size()) {
            cout << "9";
        }
    }
    cout << endl;
    string a;
    cin >> a;
    if(a == "Y") {
        return true;
    }
    else {
        return false;
    }
}

signed main() {
    string s;
    rep(_, 12) {
        int b = -1;
        if(s.empty()) {
            b = 0;
        }
        int e = 9;
        while(b < e - 1) {
            int m = (b + e) / 2;
            s.push_back('0' + m);
            if(comp(s)) {
                e = m;
            }
            else {
                b = m;
            }
            s.pop_back();
        }
        s += '0' + e;
    }
    string s2;
    rep(i, s.size()) {
        s2.push_back('9');
        if(s[i + 1] == '0' && comp(s2, false)) {
            cout << "! " << s.substr(0, i + 1) << endl;
            break;
        }
    }
}


Measured memory_bytes: 676
a = int(input())

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

b = digitSum(a)

if b % 9 ==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 80072
c=[[0 for i in range(3)] for j in range(3)]
a=[0]*3
b=[0]*3

for i in range(3):
  c[i]=list(map(int,input().split()))

for i in range(-500,500):
  a[0]=i
  b[0]=c[0][0]-a[0]
  b[1]=c[0][1]-a[0]
  b[2]=c[0][2]-a[0]
  a[1]=c[1][0]-b[0]
  a[2]=c[2][0]-b[0]
  
  if c[1][1]==a[1]+b[1] and c[1][2]==a[1]+b[2] and c[2][1]==a[2]+b[1] and (c[2][2]==a[2]+b[2]):
    print("Yes")
   
    break
    
  if c[1][1]!=a[1]+b[1] or c[1][2]!=a[1]+b[2] or c[2][1]!=a[2]+b[1] or (c[2][2]!=a[2]+b[2]):
    if i==499:
      print("No")

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  int a[3],cnt5=0,cnt7=0;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(int i=0;i<3;i++){
    if(a[i]==5){
      cnt5++;
    }
    if(a[i]==7){
      cnt7++;
    }
  }
  if(cnt5==2&&cnt7==1){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 30 + 10;
ll bmm(ll a, ll b){
	if(b > a) swap(a, b);
	return (!b ? a : bmm(b, a % b));
}
ll n, np, x, ans;
set<ll> st;
bool check(ll xx){
    if(xx == 1) return 0;
    ll npp = n;
    while(npp % xx == 0) npp /= xx;
    npp %= xx;
    return (npp == 1);
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n;
    x = 1, np = n - 1;
    while(x * x <= np){
        if(x * x == np){
            if(check(x)) st.insert(x);
        }
        else if(np % x == 0){
            if(check(np / x)){st.insert(np / x);}
            if(check(x)){st.insert(x);}
        }
        x ++;
    }
    x = 1;
    while(x * x <= n){
        if(x * x == n){
            if(check(x)){
                    st.insert(x);
            }
        }
        else if(n % x == 0){
            if(check(x)) {st.insert(x);}
            if(check(n / x)) {st.insert(n / x);}
        }
        x ++;
    }
    cout << st.size();
    return 0;
}
/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/
//! N.N


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	if(a>b){
		swap(a,b);
	}
	ll A=b;
	ll cnt=1;
	for(ll i=2;i<=1000000;i++){
		if(a%i==0&&b%i==0){
			cnt++;
		}
			while(a%i==0){
				a/=i;
			}
			while(b%i==0){
				b/=i;
			}		
	}
	if(a>b){
		if(a%b==0&&b!=1){
			cnt++;
		}
	}
	else{
		if(b%a==0&&a!=1){
			cnt++;
		}
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll max3(ll a, ll b, ll c){
    if(a > b){
        if(b > c) return a;
        else{
            if(a > c) return a;
            else return c;
        }
    }else{
        if(b > c) return b;
        else return c;
    }
}

int main(){
    ll a,b; cin >> a >> b;
    ll ans = max3(a+b, a-b, a*b);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		boolean[][] T = new boolean[4][13];
		for(int i = 0; i < 4; i++) T[i] = new boolean[13];
		String[] mm = {"S", "H", "C", "D"};
		
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			String m = sc.next();
			int num = sc.nextInt();
			if(m.equals("S")) T[0][num-1] = true;
			if(m.equals("H")) T[1][num-1] = true;
			if(m.equals("C")) T[2][num-1] = true;
			if(m.equals("D")) T[3][num-1] = true;
		}
		
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 13; j++){
				if(!T[i][j]){
					System.out.println(mm[i] + " " + (j+1));
				}
			}
		}
	}
}


Measured memory_bytes: 26268
[N,A,B] = list(map(int,input().split()))
if A%2==B%2:
    output = int(abs(A-B)//2)
else:
    if A-1<=N-B:
        output = A-1+1
        B = B-(A-1+1)
        output += int(abs(1-B)//2)
    else:
        output = N-B+1
        A =  A+(N-B+1)
        output += int(abs(A-N)//2)
print(output)


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int a, b;
    cin >> a >> b;
    int sum = 1, cnt = 0;
    while (sum < b){
	   sum += a - 1;
	   cnt++;	
	}
	cout << cnt << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
<?php
list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));

for ($i = $a; $i <= $b * $a; $i += $a) {
    if ($i % $b == $c) {
        echo 'YES'.PHP_EOL;
        exit;
    }
}
echo 'NO'.PHP_EOL;


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define   vpll   vector<pll >
#define   all(x) x.begin(),x.end()
#define   present(c,x)    ((c).find(x) != (c).end())
#define   dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#define   sz(a)  a.size()
#define   vll vector<int>
#define   pll pair<int,int>
#define   ff  first
#define   ss  second
#define   br  cout<<"\n";
#define   ld  long double
#define   int  long long int
const int  INF = 1e18+7;
const int  MAX = 1234567;
const int  MOD = 1000000007;



void solve(){
    int n ;
    cin >> n ;
    multiset < ld > S ;
    for ( int i = 0 ; i < n ; i++ ){
    	ld temp ;
    	cin >> temp ;
    	S.insert(temp);
    }
    cout << setprecision(10) << fixed ;
    while ( (int)sz(S) > 1 ){
    	auto iter = S.begin();
    	ld val = *iter + *(++iter);
    	val /= 2 ;
    	S.erase(iter);
    	S.erase(--iter);
    	S.insert(val); 
    }
    cout << *S.begin();
}
int32_t main(){
    int t;
    t=1;

    cin.sync_with_stdio(0), cin.tie(0);
    //cin>>t;
    while(t--){
        solve();
        br;
    }
    return 0;
}
 
 
 
 
 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
#ifdef LOCAL_DEFINE
    freopen("test.in","r",stdin);
#else
    cin.sync_with_stdio(0); cin.tie(0);
#endif
	int n, a, b, n1 = 0, n2 = 0, n3 = 0;
	cin >> n >> a >> b;
	rep(i,0,n){
		int x;
		cin >> x;
		if(x <= a) n1++;
		else if(x > a && x <= b) n2++;
		else n3++;
	}
	cout << min({n1, n2, n3}) << '\n';
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * (double) clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


Measured memory_bytes: 256
def main():
    n, m, x = map(int, input().split(" "))
    ca =[]
    a = []
    c = []
    ans = 1e9
    for i in range(n):
        ca.append(list(map(int, input().split(" "))))
    for i in range(n):
        c.append(ca[i][0])
        a.append(ca[i][1:])
    for i in range(1<<n):
        a_sum = [0]*m
        c_sum = 0
        for j in range(n):
            if i >> j & 1 == 1:
                for k in range(m):
                    a_sum[k] += a[j][k]
                c_sum += c[j]
        if min(a_sum) >= x and c_sum < ans:
            ans = c_sum
    if ans == 1e9:
        print(-1)
    else:
        print(ans)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
program main
   
  implicit none
  character(10) :: s,a
  integer :: i,j

  
  read(*,*) s
  a = ""  
  j = 1
  do i = 1, len_trim( s )
    if( s(i:i) == "0" ) then
      a(j:j) = "0"
      j = j + 1
    else if( s(i:i) == "1" ) then
      a(j:j) = "1"
      j = j + 1
    else if( s(i:i) == "B" ) then
      if ( j > 1 ) then
        j = j - 1
        a(j:j) = ""
      end if
    end if
  end do
  
  print*, trim( a )


end program main


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    string s;
    cin >> n;
    vector<bool> flg(n, true);
    cin >> s;
    rep(i, n)
    {

        if (s[i] == '(')
        {
            reps(j, i + 1, n)
            {

                if (s[j] == ')' && flg[i] && flg[j])
                {
                    flg[i] = flg[j] = false;
                }
            }
        }
    }
    rep(i, s.size())
    {
        string tmptmp = ")";

        if (s[i] == '(' && flg[i])
        {
            s = s + tmptmp;
            !flg[i];
        }
    }
    string ans = s;
    repb(i, n - 1)
    {
        string tmp = "(";
        if (s[i] == ')' && flg[i])
        {
            ans = tmp + ans;
            !flg[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int N, d[101]={};
  cin >> N;
  rep(i,N) cin >> d[i];
  int ans = 0;
  rep(i,N){
    for(int j=i+1; j<N; j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
        if(x > y){
            printf("%d %d\n", y, x);
        }else{
            printf("%d %d\n", x, y);
        }
    }
    return 0;
}



Measured memory_bytes: 1976
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    REP(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};

int main(){
  ll n,m,s,t;
  cin >> n >> m >> s >> t;
  graph g1(n);
  graph g2(n);
  REP(i,m){
    ll u,v,a,b;
    cin >> u >> v >> a >> b;
    g1.add_edge(u-1,v-1,a);
    g1.add_edge(v-1,u-1,a);
    g2.add_edge(u-1,v-1,b);
    g2.add_edge(v-1,u-1,b);
  }
  g1.dijkstra(s-1);
  g2.dijkstra(t-1);

  ll cost[n];
  REP(i,n){
    cost[i] = g1.d[i] + g2.d[i];
  }
  ll min_cost[n];
  for(ll i = n-1; i >= 0; i--){
    if(i==n-1){
      min_cost[i] = cost[i];
    }else{
      min_cost[i] = min(min_cost[i+1],cost[i]);
    }
  }
  REP(i,n){
    cout << 1000000000000000-min_cost[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 19836
#include <iostream>
using namespace std;
int main() {
  int m, n_min, n_max, ans, d;
  while (cin >> m >> n_min >> n_max, m) {
    int P[m];
    ans = 0;
    for (int i = 0; i < m; ++i) cin >> P[i];
    d = 0;
    for (int i = n_min-1; i < n_max; ++i) {
      if (P[i] - P[i+1] >= d) {
	ans = i+1;
	d = P[i] - P[i+1];
      }
    }
    cout << ans << endl;
  }
}

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


int countMatchCharacter(string left, string right)
{
    map<char, int> mapleft;
    map<char, int> mapright;
    
    for(int i=0; i<left.size(); i++){
        mapleft[left[i]]++;
    }
    
    for(int i=0; i<right.size(); i++){
        mapright[right[i]]++;
    }
    
    int count=0;
    for(std::map<char,int>::iterator it=mapleft.begin(); it!=mapleft.end(); ++it)
    {
        int numChar_left = it->second;
        int numChar_right = mapright[it->first];
        if(numChar_left>0 && numChar_right>0) count++;
    }
    
    return count;
};

int main(int argc, const char * argv[])
{
    int n;
    string s;
    cin >> n >> s;

    int score;
    int max_score=0;
    string left, right;
    for(int i=1; i<n; i++)
    {
        left = s.substr(0, i);
        right = s.substr(i, n-i);
        score = countMatchCharacter(left, right);
        max_score = max(score, max_score);
    }

    cout <<  max_score << endl;
    
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    
    int A[N];
    int B[N];
    int C[N-1];

    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];

          
    int ans = 0;
    int i;
    int buff = A[0];
    
    for(i =0; i < N; i++){
        ans += B[i];
        if(A[i] - buff == 1 && i > 0){
            ans += C[A[i]-2];
            }
        buff = A[i];
    }
    
    
    cout <<  ans << endl;

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
void main()
{
  while(1){
    auto n = readln.chomp.to!int;
    if(n==0) break;
    int s=1;
    int max=50000001;
    for(int i=2;i<n/2;++i){
      if(n%i==0){
	if(i<max){
	  s+=(i+n/i);
	  max = n/i;
	  if(i==max)
	    s -= i;
	}else break;
      }else if(i>max) break;
    }
    if(s<n || n==1) writeln("deficient number");
    else if(s==n) writeln("perfect number");
    else writeln("abundant number");
  }
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int k,x;
    cin >> k >> x;
    for(int i=x-(k-1);i<=x+(k-1);i++){
    	cout << i;
    	if(i<x+(k-1)) cout << " ";
	}
	cout << endl;
    
	return 0;
}


Measured memory_bytes: 256
#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[i];
	}
	int max_index=0;
	for (int i = 1; i < n; i++) {
		if (abs(a[i])>abs(a[max_index])) {
			max_index=i;
		}
	}
	cout<<2*n-1<<endl;
	for (int i = 0; i < n; i++) {
		cout<<max_index+1<<" "<<i+1<<endl;
	}
	if (a[max_index]>=0) {
		for (int i = 0; i < n-1; i++) {
			cout<<i+1<<" "<<i+2<<endl;
		}
	}else {
		for (int i = n; i > 1; i--) {
			cout<<i<<" "<<i-1<<endl;
		}
	}
}

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

namespace ConsoleApp3
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            
            Console.WriteLine((1 + n) * n / 2 - n);
        }
    }
}

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

int main(){
    string s;
    cin >> s;
    int ans = 700;
    for(int i=0; i < 3; i++){
        if(s[i] == 'o')
        ans += 100;
    }

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


Measured memory_bytes: 256
import heapq

x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a = sorted(a, key=lambda x: x * -1)
b = sorted(b, key=lambda x: x * -1)
c = sorted(c, key=lambda x: x * -1)

counter = 0
a_idx = 0
b_idx = 0
c_idx = 0
pque = []
heapq.heappush(pque, (-1 * (a[a_idx] + b[b_idx] + c[c_idx]), (a_idx, b_idx, c_idx)))

while counter < k:
    counter += 1
    output = heapq.heappop(pque)
    print(output[0] * -1)
    a_idx, b_idx, c_idx = output[1]
    if a_idx < len(a) - 1:
        current = a[a_idx + 1] + b[b_idx] + c[c_idx]
        cand = (a_idx + 1, b_idx, c_idx)
        if (-1 * current, cand) not in pque:
            heapq.heappush(pque, (-1 * current, cand))
    if b_idx < len(b) - 1:
        current = a[a_idx] + b[b_idx + 1] + c[c_idx]
        cand = (a_idx, b_idx + 1, c_idx)
        if (-1 * current, cand) not in pque:
            heapq.heappush(pque, (-1 * current, cand))
    if c_idx < len(c) - 1:
        current = a[a_idx] + b[b_idx] + c[c_idx + 1]
        cand = (a_idx, b_idx, c_idx + 1)
        if (-1 * current, cand) not in pque:
            heapq.heappush(pque, (-1 * current, cand))

Measured memory_bytes: 4084
package main

import "fmt"

func main() {
	k, s := 0, 0
	_, _ = fmt.Scan(&k, &s)
	count := 0
	for i := 0; i <= k; i++ {
		for j := 0; j <= k; j++ {
			z := s - i - j
			if z >= 0 && z <= k {
				count++
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
import numpy as np
import random
import time 

random.seed(1111)
start=time.time()
D=int(input())
C=np.array(list(map(int,input().split())))
last_day=np.array([-1 for _ in range(26)])
score=np.array([list(map(int,input().split())) for _ in range(D)])
output=[1 for _ in range(D)]

def score_cal(output):
    ans=0
    memo=np.array([-1 for _ in range(26)])
    for day in range(D):
        t=output[day]-1
        memo[t]=day
        tmp=C*(memo-day)
        ans=ans+score[day][t]+sum(tmp)
    return ans

  
random_day=[i for i in range(D)]
random_con=[i+1 for i in range(26)]

cnt=0
while time.time()-start<1.85:
    tmp_output=output[:]
    cnt+=1
    d=random.choice(random_day)
    con=random.choice(random_con)
    tmp_output[d]=con
    
    if score_cal(tmp_output)>score_cal(output):
        output[d]=con
      
print(*output,sep="\n")

Measured memory_bytes: 27424
use std::collections::HashMap;

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
        buffer.clear();
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.trim().parse().ok().expect("Can't Parse"));
        buffer.clear();
    }
    vec
}
macro_rules! assign {
    () => {};
    ($($token:tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        assign_iter!(iter, $($token)*);
    };
}
macro_rules! assign_iter {
    ($iter:expr) =>{};
    ($iter:expr,) =>{};
    ($iter:expr, $id:ident:$t:tt $($tail:tt)*) => {
        let $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*);
    };
    ($iter:expr, mut $id:ident:$t:tt $($tail:tt)*) => {
        let mut $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*)
    };
}
macro_rules! freeze {
    ($($id:ident), *) => {
        $(let $id = $id;)*
    };
}
fn main() {
    assign! {
        height: usize
        width: usize
        k: usize
    }
    let state = read_lines(height, |s| s.trim().chars().collect::<Vec<_>>());
    //println!("{:?}", state);
    let mut count = 0usize;
    for h in 0 .. (1 << height) {
        let mut y = Vec::new();
        for i in 0 .. height {
            if (h & (1 << i)) != 0 {
                y.push(i);
            }
        }
        for w in 0 .. (1 << width) {
            let mut is_red = vec![vec![false; width]; height];
            for &i in &y {
                for j in 0 .. width {
                    is_red[i][j] = true;
                }
            }
            for j in 0 .. width {
                if (w & (1 << j)) != 0 {
                    for i in 0 .. height {
                        is_red[i][j] = true;
                    }
                }
            }
            let mut black = 0usize;
            for i in 0 .. height {
                for j in 0 .. width {
                    if !is_red[i][j] && state[i][j] == '#' {
                        black += 1;
                    }
                }
            }
            if black == k {
                count += 1;
            }
        }
    }
    println!("{}", count);
}

Measured memory_bytes: 2152
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


 int main(){
	 
	 int h;
	 while(1){
		 int p=0;
		 int flag=1;
		 int x;
		cin >> h;
		if(h == 0) break;
		vector<vector<int> > A(5);
		for(int j = h-1; j >= 0; j--){
			for(int i = 0; i< 5; i++){
				cin >> x;
				A[i].push_back(x);
			}
		}
		for(int i = 0; i< 5; i++){
			reverse(A[i].begin(), A[i].end());
			}


		while(1){
			int flag=0;
		for(int i = 0; i < h; i++){
			int count=0;
			int mem=-1;
			//一行の処理開始
			for(int j=0; j< 5;j++){
				if(mem==A[j][i]) count++;
				else {
					mem =A[j][i];
					count = 0;
				}
				if(count > 1) {
					A[j-2][i] +=10;
					A[j-1][i] +=10;
					A[j][i] +=10;
					if(mem!=0) flag =1;
				}
			}
			for(int k = 0; k < 5 ; k++){
				if(A[k][i] >=10){
					p += A[k][i]%10;
					A[k][i]=0;
				}
			}//一行の処理終了
		}
		for(int i= 0; i < 5 ; i++){
			vector<int> B(A[i]);
			int counter=0;
			for(int j = 0 ; j < h ; j++){
				if(B[j] !=0){
					A[i][counter] = B[j];
					counter+=1;
				}
			}
			for(;counter<h; counter++){
				A[i][counter] = 0;
			}
		} 
		if(flag == 0) break;
		}
		cout <<p <<endl;
	 }
		 



	return 0;
 }

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if ((abs(b - a) <= d && abs(c - b) <= d) || abs(c - a) <= d) printf ("Yes");
    else printf ("No");
    return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n,a[105];
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<endl;
  return(0);
}


Measured memory_bytes: 256
class Maximum
  def initialize
    @result = []
 
    while(@n = $stdin.gets.chomp.to_i)
      @max = -1000000
      if @n != 0
        calc  
      else
        break
      end
    end
    render
  end
 
  def calc
    sum = 0
    @n.times do
      val = $stdin.gets.chomp.to_i
      if val < 0
        sum += val
        if @max < sum
          @max = sum
        end
        if sum <= 0
          sum = 0
        end
      else
        sum += val
        if @max < sum
          @max = sum
        end
      end
    end
    @result.push(@max)
  end
 
  def render
    @result.each do |val|
      puts val
    end
  end
end
 
m = Maximum.new

Measured memory_bytes: 6088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   int ans = 0;
   for (int num = 1; num <= n; num++) {
      int div = 0;
      for (int j = 1; j <= num; j++) {
         if (num % j == 0)
            div++;
      }
      if (div == 8 && num % 2)
         ans++;
   }
   cout << ans << endl;
   return 0;
}

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

int main(){
  int a[4],b[2];
  for(int i=0;i<4;i++)cin>>a[i];
  for(int i=0;i<2;i++)cin>>b[i];

  sort(a,a+4);
  sort(b,b+2);
  int ans=0;
  for(int i=3;i>=1;i--) ans+=a[i];
  ans+=b[1];
  cout << ans<<endl;
  return 0;
}

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

int main() {
  int n,y; cin >> n >> y;
  int c10000 = -1;
  int c5000 = -1;
  int c1000 = -1;
  bool breaking = false;
  for ( int i = 0; i <= n; i++){
    for ( int j = 0; j+i <= n; j++){
      int k = n - i - j;
      int money = 10000*i + 5000*j + 1000*k;
      if (money == y){
        c10000 = i;
        c5000 = j;
        c1000 = k;
        breaking = true;
        break;
      }
    }
    if(breaking) break;
  }
  cout << c10000 << " " << c5000 << " " << c1000 << endl;
}
        
          
        

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int SZ = 5e7;

// エラトステネスの篩
template <int N> struct Prime {
    bitset<N + 1> b;
    Prime() : b() {
        b.flip();
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
auto prime = Prime<SZ>();

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        // 同じ数が重複するケースを考慮
        D[x]++;
    }
    // trueなら "pairwise coprime"
    bool pc = true;

    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            for (int now = i; now <= SZ; now += i) {
                cnt += D[now];
            }
            // 共通の素数を含むのでgcd(ALL) >= i
            if (cnt >= 2) {
                pc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
        }
        if (g == 1)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 407896
// AOJ 1210: Die Game
// 2017.10.15

#include <stdio.h>

//char t[7] = { 0, 's', 'w', 'e', 'n' };
char tr['z'];

int rot[5][7] = { { 0,1,2,3,4,5,6 },
{ 0,2,6,3,4,1,5 },{ 0,4,2,1,6,5,3 },{ 0,3,2,6,1,5,4 },{ 0,5,1,3,4,6,2 } };
	
int main()
{
	int n, i, j, k1, k2;
	int dice[2][7];
	char b[10];

	tr['s'] = 1, tr['w'] = 2, tr['e'] = 3, tr['n'] = 4;
	while (scanf("%d", &n) && n > 0) {
		for (i = 1; i <= 6; i++) dice[0][i] = i;
		for (k1 = 0, k2 = 1; n-- > 0; k1 = k2, k2 = !k2) {
			scanf("%s", b); j = tr[*b];
			for (i = 1; i <= 6; i++) dice[k2][i] = dice[k1][rot[j][i]];
		}
		printf("%d\n", dice[k1][1]);
	}
	return 0;
}

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

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

int main(){
  vector<string> u;
  int N, M;
  cin>>N;
  rep(i,N){
    string tmp;
    cin>>tmp;
    u.push_back(tmp);
  }
  cin>>M;
  bool open=false;
  rep(i,M){
    string t;
    cin>>t;
    bool known=false;
    rep(j,N)if(u[j]==t){known=true; break;}
    if(!known)cout<<"Unknown "<<t<<endl;
    else if(open){cout<<"Closed by "<<t<<endl; open=false;}
    else{cout<<"Opened by "<<t<<endl; open=true;}
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <iterator>
using namespace std;
int main(void){
    string s;
    cin>>s;
    for(auto c:s){
        if(s.find(c)!=s.rfind(c)){
            cout<<"no";
            return 0;
        }
    }
    cout<<"yes";
}


Measured memory_bytes: 256
n, y = map(int, input().split())

for i in range(y//10000 + 1):
    for j in range((y-i*10000)//5000 + 1):
        k = (y-i*10000-j*5000) // 1000
        if i + j + k == n:
            print(i, j, k)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
// AT2150 AtCoder Contest.cpp: 定义控制台应用程序的入口点。
//

//#include "stdafx.h"
#include<iostream>
#include<string>

using namespace std;
string a, b, c;
int main()
{
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0]<<endl;
	//system("pause");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;


ll N, K, A[101],ans;
string S;


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

	cin >> N >> K;
	FOR(i, 0, K) {
		int d;
		cin >> d;
		FOR(i, 0, d) {
			int h; cin >> h;
			h--;
			A[h]++;
		}
	}
	FOR(i, 0, N) {
		if (A[i] == 0)ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

const int MAX_N = 1e5 + 10;
int N;
int v[MAX_N];

using Pair = std::pair<int, int>;

std::unordered_map<int, int> mpo, mpe;
std::vector<Pair> veco, vece;

int main(int argc, char **argv) {
    std::cin >> N;
    
    for (int i = 1; i <= N; i++) {
        std::cin >> v[i];
    }

    for (int i = 1; i <= N; i++) {
        if (i % 2 == 0) {
            mpe[v[i]]++;
        } else {
            mpo[v[i]]++;
        }
    }

    for (auto p : mpe) {
        vece.push_back(Pair({p.first, p.second}));
    }
    for (auto p : mpo) {
        veco.push_back(Pair({p.first, p.second}));
    }

    std::sort(vece.begin(), vece.end(), [&](const Pair& a, const Pair& b){
        return a.second > b.second;
    });

    std::sort(veco.begin(), veco.end(), [&](const Pair& a, const Pair& b){
        return a.second > b.second;
    });

    if (vece[0].first != veco[0].first) {
        std::cout << N - vece[0].second - veco[0].second << std::endl;
    } else if (vece.size() == 1 && veco.size() == 1) {
        std::cout << N/2 << std::endl;
    } else if (vece.size() == 1) {
        std::cout << N/2 - veco[1].second << std::endl;
    } else if (veco.size() == 1) {
        std::cout << N/2 - vece[1].second << std::endl;
    } else {
        std::cout << std::min(N - veco[0].second - vece[1].second, N - vece[0].second - veco[1].second) << std::endl;
    }

    return 0;

}


Measured memory_bytes: 5908
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result}

const main = ()=>{
  out(nin()*nin()/2);
}
main();

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int n,d,i,j,h,x[15][15],ans,dis;
int main() {
	scanf("%d%d",&n,&d);
	for(i=1; i<=n; i++)
		for(j=1; j<=d; j++)
			scanf("%d",&x[i][j]);
	for(i=1; i<n; i++)
		for(j=i+1; j<=n; j++) {
			for(dis=0,h=1; h<=d; h++)
				dis+=(x[i][h]-x[j][h])*(x[i][h]-x[j][h]);
			h=sqrt(dis),ans+=(h*h==dis);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

fn solve(num: i64, hs: &Vec<i64>, a: i64, b: i64) -> bool {
    let mut rem = num;
    let damage = num * b;
    for h in hs {
        if h > &damage {
            rem -= (h - damage + a - b - 1) / (a - b);
        } else {
            break;
        }
        if rem < 0 { return false; }
    }
    true
}

fn main() {
    let input = readv();
    let (n, a, b) = (input[0], input[1], input[2]);
    let mut hs: Vec<i64> = (0..n).map(|_| { read() }).collect();
    hs.sort_by(|a, b| b.cmp(a));
    let mut l = 0;
    let mut r = 1e9 as i64;
    while l < r {
        let piv = (l + r) / 2;
        if solve(piv, &hs, a, b) {
            r = piv;
        } else {
            l = piv + 1;
        }
    }
    println!("{}", l);
}


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

int dp[110][10010];

int main(){
  int n, w;
  cin >> n >> w;
  int value[n + 1];
  int weight[n + 1];
  for(int i = 0; i < n; ++i){
    cin >> value[i] >> weight[i];
  }

  for(int i = 0; i < n; ++i){
    dp[i][0] = 0;
  }

  for(int i = 0; i < n; ++i){
    for(int j = 0; j <= w; ++j){
      if(j >= weight[i])dp[i + 1][j] = max(dp[i + 1][j - weight[i]] + value[i], dp[i][j]);
      else dp[i + 1][j] = dp[i][j];
    }
  }

  cout << dp[n][w] << endl;
}



Measured memory_bytes: 7028