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

using ll = long long;
const int N = 3005;
ll dp[N][N], s[N], a[N];

template <class X, class Y>
bool chkmax(X &a, const Y &b){
	return a < b ? a = b, 1 : 0;
}

ll sum(int i, int j){
	return s[j] - s[i - 1];
} 

ll calc(int i, int j){
	if (dp[i][j] != -1) return dp[i][j];
	if (i == j) return dp[i][j] = a[i];
	dp[i][j] = a[i] + sum(i + 1, j) - calc(i + 1, j);
	chkmax(dp[i][j], a[j] + sum(i, j - 1) - calc(i, j - 1));
	return dp[i][j];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i]; s[i] = s[i - 1] + a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << calc(1, n) * 2 - s[n] << '\n';
}

Measured memory_bytes: 71040
# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int, input().split()))
ans = []
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0

ans.append(cnt)
print(max(ans))



Measured memory_bytes: 63984
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    string a, b, c; cin >> a >> b >> c;
    string res = "NO";
    reverse(all(a));
    if(a[0] == b[0]){
        reverse(all(b));
        if(b[0] == c[0]){
            res = "YES";
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//Ashikur Rahman Asif , CSE 18
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+n);
    int total;
    int new_ar[n],ind=0;
    for(int i=0;i<n;i++)
    {
        new_ar[i]=0;
    }
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            new_ar[ind]++;
            continue;
        }
        if(ar[i]==ar[i-1])
        {
            new_ar[ind]++;
        }
        else {
            ind++;
            new_ar[ind]++;
        }

    }
    int one,two;
    one=two=0;

    for(int i=0;i<=ind;i++)
    {
        while(new_ar[i]>2)
        {
            new_ar[i]=(new_ar[i]/3)+(new_ar[i]%3);
        }
        if(new_ar[i]==2)
        {
            two++;
        }
        else if(new_ar[i]==1)
        {
            one++;
        }
    }
    int res;
    if(two%2!=0)
    {
        two--;
    }
    res=two+one;


    cout<<res<<endl;
    return 0;
}


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

char a[22][22];
//char s[10]="China";   
//s=['C','h',i,n,a,\0,\0,\0,\0,\0]

int n,m;

struct pos{
	int x;
	int y;
	int step;
};

pos make_pos(int a,int b,int c){
	pos ret;
	
	ret.x=a;
	ret.y=b;
	ret.step=c;
	
	return ret;
}

int bfs(int sx,int sy,int ex,int ey){
	bool vis[n+2][m+2];
	
	for(int i=0;i<=n+1;++i)
		for(int j=0;j<=m+1;++j)
			if(a[i][j]=='#')
				vis[i][j]=true;
			else
				vis[i][j]=false;
	
	queue<pos> q;
	q.push(make_pos(sx,sy,0));
	vis[sx][sy]=true;
	int move[2][4]={{0,0,-1,1},{-1,1,0,0}};
	
	while(!q.empty()){
		pos fr=q.front();
		q.pop();
		if(fr.x==ex&&fr.y==ey)
			return fr.step;
			
		pos newpo;
		for(int i=0;i<4;++i){
			int nx=fr.x+move[0][i];
			int ny=fr.y+move[1][i];
			if(vis[nx][ny])
				continue;
			vis[nx][ny]=true;
			newpo=make_pos(nx,ny,fr.step+1);
			q.push(newpo);
		}
	}
	return 0;
}

int main(){
	for(int i=0;i<22;++i)
		for(int j=0;j<22;++j)
			a[i][j]='#';
	
	cin>>n>>m;
	
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			cin>>a[i][j];
	
	int maxv=0;
	
	for(int i1=1;i1<=n;++i1)
		for(int j1=1;j1<=m;++j1){
			if(a[i1][j1]=='#')
				continue;
			for(int i2=1;i2<=n;++i2)
				for(int j2=1;j2<=m;++j2){
					if(a[i2][j2]=='#')
						continue;
					if(i1==i2&&j1==j2)
						continue;
					
					maxv=max(maxv,bfs(i1,j1,i2,j2));
				}
		}
	
	cout<<maxv<<endl;
	return 0;
}

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

int main() {
  long n,a,b=0,ans=0;
  long d[210000];
  cin >> n;
  for(int i=0 ;i<n ;i++){
    cin >> a;
    d[i] = a-(i+1);
  }
  sort(d,d+n);
  b = n/2;
  for(int i=0 ;i<n ;i++){
    ans += abs(d[i] - d[b]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void B_task();

int main()
{
	B_task();
	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N;
	get1int(N);

	int A[20] = { 0 };
	int B[20] = { 0 };
	int C[20] = { 0 };
	for (int i = 0; i < N; i++) {
		get1int(A[i]); A[i]--;
	}
	for (int i = 0; i < N; i++) {
		get1int(B[i]);
	}
	for (int i = 0; i < N - 1; i++) {
		get1int(C[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += B[A[i]];
		if ((i > 0) && ((A[i] - A[i - 1]) == 1)) {
			ans += C[A[i] - 1];
		}
	}
	printf("%d\n", ans);
}


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

const int N =1e7+5;

ll arr[N];

int main()
{
    for(int i=1;i<=N;i++)
    {
        for(int j=i;j<=N;j+=i)
        {
            arr[j]++;
        }
    }
    ll k;
    cin>>k;
    ll sum=0;
    for(int i=1;i<=k;i++)
    {
        sum+=(i*arr[i]);
    }
    cout<<sum<<endl;
}


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

int main(){
    
    int n;
    string str1, str2;
    int a = 0, b = 0;
    
    cin >> n;
    for ( int i = 0; i < n; i++){
        cin >> str1 >> str2;
        if ( str1 == str2 ){
            a++;
            b++;
        }
        else if ( str1 > str2 ) a += 3;
        else b += 3;
    }
    cout << a << " " << b << endl;
    return 0;
}


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

int main(){
	int n;
	int num[200][3];
	int ans[200];
	bool check[101];

	for(int i=0; i < 200; i++) ans[i] = 0;

	cin >> n;

	for(int i=0; i < n; i++){
		for(int j=0; j < 3; j++){
			cin >> num[i][j];
		}
	}
	for(int k=0; k < 3; k++){
		fill(check,  check+101,  true);
		for(int i=0; i < n; i++){
			if(!check[num[i][k]]) continue;
			for(int j=0; j < n; j++){
				if(i == j) continue;
				if(num[i][k] == num[j][k]) check[num[i][k]] = false;
			}
		}

		for(int i=0; i < n; i++){
			if(check[num[i][k]]) ans[i] += num[i][k];
		}
	}

	for(int i=0; i < n; i++){
		cout << ans[i] << endl;
	}

}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false;
string s, t;
ll a, b, c;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*vll v(5);
	rep(i, 5) {
		cin >> v[i];
		//cout << v[i] << endl;
	}
	cin >> k;
	if (v[4] - v[0] > k) cout << ":(" << endl;
	else cout << "Yey!\n";*/
	cin >> n;
	vll v(5);
	rep(i, 5) {
		cin >> v[i];
		ret = min(ret, v[i]);
	}
	if (n % ret != 0) cout << n / ret + 5 << endl;
	else cout << n / ret + 4;
	return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
ld pi=acos(-1.0);

bool kai(int n) {
	string st(to_string(n));
	for (int i = 0; i < st.size(); ++i) {
		if (st[i] != st[st.size() - 1 - i]) {
			return false;
		}
	}
	return true;
}

int main() {
	int N;cin>>N;
	int num=0;
	bool ok=true;
	for (int i = 0; i < N; ++i) {
		char ch;cin>>ch;
		int k;cin>>k;
		if(ch=='(')num+=k;
		else num-=k;

		if(num<0)ok=false;
	}
	if(num!=0)ok=false;

	if(ok)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


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

//see answer
int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> X(N), Y(N);
	for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
	long long ans = 5 * powl(10, 18);
	for (int p1 = 0; p1 < N; p1++) {
		for (int p2 = 0; p2 < N; p2++) {
			for (int p3 = 0; p3 < N; p3++) {
				for (int p4 = 0; p4 < N; p4++) {
					long long xl = min({ X[p1],X[p2],X[p3],X[p4] });
					long long xr = max({ X[p1],X[p2],X[p3],X[p4] });
					long long yu = min({ Y[p1],Y[p2],Y[p3],Y[p4] });
					long long yd = max({ Y[p1],Y[p2],Y[p3],Y[p4] });
					int num = 0;
					for (int i = 0; i < N; i++) num += (X[i] >= xl && X[i] <= xr && Y[i] >= yu && Y[i] <= yd);
					if (num >= K) ans = min(ans, (xr - xl) * (yd - yu));
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvp g;
	public:
	vi DIJ(int s){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
};

int n;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	Graph g(n*n);
	vi d(n*n);
	for(int i=0;i<2*n*n-2*n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g.add_edge(u,v,1);
		d[u]++;d[v]++;
	}
	int x,y;
	for(int i=0;i<n*n;i++) if(d[i]==2) x=i;
	vi a=g.DIJ(x);
	for(int i=0;i<n*n;i++) if(d[i]==2&&a[i]==n-1) y=i;
	vvi c(n,vi(n));
	vi b=g.DIJ(y);
	for(int i=0;i<n*n;i++){
		int p=a[i],q=b[i];
		c[(p+q-n+1)/2][p-(p+q-n+1)/2]=i;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) cout<<c[i][j]+1<<" \n"[j==n-1];
	}
}


Measured memory_bytes: 4024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n,m;
  cin >> n >> m;
  vs a(n);
  vs b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  rep(i,n-m+1)rep(j,n-m+1){
    bool ok = true;
    rep(k,m)rep(l,m){
      if(a[k+i][l+j]!=b[k][l]) ok = false;
    }
    if(ok){
      cout << "Yes" << endl;
      return 0 ;
    }
  }
  cout << "No" << endl;
}




Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a, b;

	while( scanf("%d %d", &a, &b ) != EOF ){
		a += b;
		b = 0;
		while( a != 0 ){
			a /= 10;
			b++;
		}
		printf("%d\n", b);
	}

	return 0;
}



Measured memory_bytes: 2676
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD 1000000007ll

using namespace std;
ll ans = 1;
int n, k;

void bfs(map<int, vector<int>> &g, map<int, bool> &visited, int now, int pcost)
{
    visited[now] = true;

    ans = (ans * (k - pcost)) % MOD;

    int nowcost = 1;
    if (now != 1)
        nowcost++;
    for (auto x : g[now])
    {
        if (visited[x] == true)
        {
            continue;
        }

        bfs(g, visited, x, nowcost);
        nowcost++;
    }
}

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

    map<int, vector<int>> g;
    map<int, bool> visited;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    bfs(g, visited, 1, 0);
    cout << ans << endl;

    return 0;
}


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

if a % 2 == b % 2:
  print((b - a) // 2)
else:
  distA = a - 1
  distB = n - b
  if distA < distB:
    ans = distA + (b - distA - 1) // 2
    if b - distA % 2 == 1:
      print(ans)
    else:
      print(ans + 1)
  else:
    ans = distB + (n - (a + distB)) // 2
    if a + distB % 2 == n % 2:
      print(ans)
    else:
      print(ans + 1)
      


Measured memory_bytes: 3060
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	long long k,a,b;
	scanf("%lld%lld%lld",&k,&a,&b);
	if(k<=a){
		printf("1\n");return 0;
	}
	if(a<=b){
		printf("-1\n");return 0;
	}
	long long t=(k-a+(a-b)-1)/(a-b);
	printf("%lld\n",t*2+1);
}

Measured memory_bytes: 128
s = input()
m = [i for i in range(1, 13)]
if int(s[2:]) in m and int(s[0:2]) in m:
  print("AMBIGUOUS")
elif int(s[2:]) in m:
  print("YYMM")
elif int(s[0:2]) in m:
  print("MMYY")
else:
  print("NA")

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

int n, mx[222];
vector<int>G[222];
ll anc=1e9, ans, rec, res;

void dfs(int x,int fff,int dep){
    rec=max(rec,dep+1ll>>1);
    for (auto y:G[x])
        if (y!=fff)
            dfs(y,x,dep+1);
    mx[dep]=max(mx[dep],(int)G[x].size()-(!!fff));
}

int main(){
    cin>>n;
    for (int i=1;i<n;++i){
        int x, y; cin>>x>>y;
        G[x].push_back(n+i);
        G[n+i].push_back(x);
        G[y].push_back(n+i);
        G[n+i].push_back(y);
    }
    for (int i=1;i<n*2;++i){
        rec=0; res=1;
        for (int j=1;j<=n*2;++j) mx[j]=1;
        dfs(i,0,1);
        for (int j=1;j<=n*2;++j) res*=mx[j];
        if (rec<anc||rec==anc&&res<ans) anc=rec, ans=res;
    }
    cout<<anc<<' '<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    vector<int> ans(n,0);
    for(int i = n-1; i >= 1; i--){
        int tmp = 0;
        for(int j = i+(i+1); j < n;j+=i+1){
            tmp += ans[j];
        }
        if(v[i]!=tmp%2)ans[i]=1;
    }
    int s = acc(ans);
    if(s%2!=v[0])ans[0]=1;
    cout << s+ans[0] << endl;
    rep(i,n){
        if(ans[i]){
            cout << i + 1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			 System.out.println(a<10 && b<10 ? a*b : -1);
		}
	}
}

Measured memory_bytes: 25372
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define MAX_V 500000
using namespace std;
struct node{
  int id,key;
  node *parent,*left,*right;
  node():key(0),parent(NULL),left(NULL),right(NULL){}
};
node nodes[MAX_V]{};
int id=0;
node* make_binary_tuple(int key){
  nodes[id].key=key;
  return &nodes[id++];
}

void printPreorder(node* n){
  cout<<" "<<n->key;
  if(n->left!=NULL) printPreorder(n->left);
  if(n->right!=NULL) printPreorder(n->right);
}
void printInorder(node* n){
  if(n->left!=NULL) printInorder(n->left);
  cout<<" "<<n->key;
  if(n->right!=NULL) printInorder(n->right);
}

node* tree_insert(node* root, int key){
  node* z=make_binary_tuple(key);
  node* y=NULL;
  node* x=root;
  while(x!=NULL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
  if(y==NULL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
  return root;
}

int main(){
  node* root=NULL;
  int n; cin>>n;
  REP(i,n){
    string s; cin>>s;
    if(s=="insert"){
      int key; cin>>key;
      root = tree_insert(root,key);
    } else if(s=="print"){
      printInorder(root); cout<<"\n";
      printPreorder(root); cout<<"\n";
    }
  }
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int count = 0;
	for(int i=1;i<n;i++){
		if (s[i-1] != s[i]) count++;
	}
	cout << count+1 << endl;
}
			

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int ans=0;
	int cnt=0;
	for(int i=0; i<3; i++){
		if(s[i]=='R'){
			cnt++;
		}
		else{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	ans=max(ans,cnt);
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define ford(i, n) for (int i = n; i > 0; i--)
#define forin(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define yn {puts("YES");}else{puts("NO");}
#define maxs(x,y) (x = max(x,y))
#define sz(x) (int)(x).size()
#define mins(x,y) (x = min(x,y))
#define newline cout<<"\n"
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
 
ll dp[200005] = {};
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	ll n,W,w,v;
	cin >> n >> W;
	forn(i,n){
		cin >> w >> v;
		forr(j,W-w+1){
			 maxs(dp[j+w],dp[j]+v);
		}
	}
	cout << dp[W];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,x;
vector<int> v;
void solve(){
	ll ans = 0;
	sort(all(v));
	for(int i = 0;i < n;i++){
		int a = v[i];
		for(int j = i + 1;j < n;j++){
			int b = v[j];
			int l = b - a,r = a + b;
			int p1 = upper_bound(all(v),l) - v.begin();
			int p2 = lower_bound(all(v),r) - v.begin();
			p2--;
			ans += (p2 - p1 + 1);
			if(i >= p1 && i <= p2) ans--;
			if(j >= p1 && j <= p2) ans--;
		}
	}
	cout << ans / 3 << endl;
} 
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	v.resize(n);
	rep(i,0,n-1){
		cin >> x;
		v[i] = x;
	}
	solve();	
	return 0;
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()


typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

#ifdef TESTING
#define DEBUG fprintf(stderr,"====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG 
#define VALUE(x)
#define debug(...)
#endif
/*
inline string IntToString(ll a) {
	char x[100];
	sprintf_s(x, "%lld", a); string s = x;
	return s;
}

inline ll StringToInt(string a) {
	char x[100]; ll res;
	strcpy_s(x, a.c_str()); sscanf_s(x, "%lld", &res);
	return res;
}
*/

inline string uppercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
	return s;
}

inline string lowercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
	return s;
}


int main()
{
	int n;
	cin >> n;
	map<ll, ll> count;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (count[x] == 0) {
			count[x]++;
			ans++;
		}
		else {
			count[x]--;
			ans--;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>


int main() {
    char str[2000000];
    scanf("%s", str);

    int i, a, z;
    for(i=0; i<strlen(str); i++) {
        if(str[i]=='A') {
            a = i;
            break;
        }
    }

    for(i=strlen(str)+1; i>-1; i--) {
        if(str[i]=='Z') {
            z = i;
            break;
        }
    }

    printf("%d\n", z-a+1);

    return 0;

}

Measured memory_bytes: 384
a,b,c=map(int, input().split())
k=int(input())
ans="No"
d=0
for i in range(k+1):
    b2=b*(2**(k-d))
    c2=c*(2**(d))
    if(a<b2<c2):
        ans="Yes"
    d+=1
print(ans)

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

//temp
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

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


int main() {
  int i,num;
  VI a;
  REP(i, 3) {
    in(num);
    a.pb(num);
  }
  co(a[0]+a[1]+a[2]+MAX(a)*9);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
 
		int[] a = new int[N + 1];
		int[] b = new int[N + 1];
		
		for (int i = 1; i <= N; i++)
			a[i] = sc.nextInt();
		
		int M = 0;
		for (int i = N; i >= 1; i--) {
			int x = 0;
			for (int j = i; j <= N; j += i)
				x ^= b[j];
			if (x != a[i]) {
				b[i] = 1;
				M++;
			}
		}
		System.out.println(M);
		for (int i = 1; i <= N; i++) {
			if (b[i] == 1)
				System.out.println(i);
		}
	}
}


Measured memory_bytes: 66164
#include <iostream>
using namespace std;
int main()
{
    long long int i, n, sum, input, min, max;
   
    cin >> n;
    cin >> input;
    max = input;
    min = input;
    sum = 0;
    for(i=1; i<=n; i++)
    {
        
        sum = sum + input;
        if(input < min)
            min = input;
        if(input > max)
            max = input;
        cin >> input;
    }
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n,x,t;
  cin >> n >> x >> t;

 cout << t*((n-1)/x+1) << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3644
#include<stdio.h>
int main (void)
{
  int X,A,B,rest=0,i,sum=0;
  
  scanf("%d\n%d\n%d",&X,&A,&B);
  
  rest=X-A;
  
  printf("%d\n",rest%B);
  
  return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
    cout << endl;
    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) {
    int A;
    cin >> A;
    vec.at(A - 1) = i + 1;
  }
  for(int i = 0; i < N; i++) {
    if(i != N - 1) {
      cout << vec.at(i) << " ";
    }
    else {
      cout << vec.at(N - 1) << endl;
    }
  }
}

Measured memory_bytes: 3764
#include <stdio.h>
int main(void){
    int dice[6]={};
    int i, tmp1, tmp2, tmp3, tmp4;
    char x;
     
    for(i=1; i<=6; i++){
        scanf("%d", &dice[i]);
    }
     
    while(scanf("%c", &x)!=EOF){
        if(x=='S'){
            tmp1=dice[1];
            tmp2=dice[2];
            tmp3=dice[5];
            tmp4=dice[6];
            dice[1]=tmp3;
            dice[2]=tmp1;
            dice[5]=tmp4;
            dice[6]=tmp2;
        }
        else if(x=='W'){
            tmp1=dice[1];
            tmp2=dice[3];
            tmp3=dice[4];
            tmp4=dice[6];
            dice[1]=tmp2;
            dice[3]=tmp4;
            dice[4]=tmp1;
            dice[6]=tmp3;
        }
        else if(x=='N'){
            tmp1=dice[1];
            tmp2=dice[2];
            tmp3=dice[5];
            tmp4=dice[6];
            dice[1]=tmp2;
            dice[2]=tmp4;
            dice[5]=tmp1;
            dice[6]=tmp3;
        }
        else if(x=='E'){
            tmp1=dice[1];
            tmp2=dice[3];
            tmp3=dice[4];
            tmp4=dice[6];
            dice[1]=tmp3;
            dice[3]=tmp1;
            dice[4]=tmp4;
            dice[6]=tmp2;
        }
    }
    printf("%d\n", dice[1]);
    return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    long int sum = 0;
    long int before = 0;

    cin>>before;

    for(int i=0; i<n-1; i++){
        long int a;
        cin>>a;
        
        if(before > a)
            sum += before - a;
        else
        {
            before = a;
        }
        
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3628
def print_list(lst) :
    a = ' '.join(list(map(str, lst)))
    print(" " + a)


lst = [[[0 for q in range(10)] for w in range(3)] for e in range(4)]

n = int(input())
for _ in range(n):
	b,f,r,v = list(map(int, input().split()))
	lst[b-1][f-1][r-1] += v

for i in range(4):
	if (i != 0):
		print("#"*20)
	for j in range(3):
		print_list(lst[i][j])

Measured memory_bytes: 7780
import math
from fractions import gcd

def lcm(a):
	
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = int(input())

nums = input().split()
nums = [int(x) for x in nums]

saisho = lcm(nums)

B = []

for num in nums:
    B.append(saisho//num)

print(sum(B)%(10**9 + 7))


Measured memory_bytes: 264668
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::string s;
  std::cin >> s;
  std::string t = s;

  std::map< char, bool > mc;
  for (std::string::iterator it = s.begin(); it != s.end(); it++) {
    mc[*it] = true;
  }

  if (s.size() == 26) {
    bool judge = std::next_permutation(s.begin(), s.end());
    if (judge == false) {
      print(-1);
      return 0;
    }
    std::string x;
    for (int i = 0; i < (ll)s.size(); i++) {
      x += s[i];
      if (s[i] != t[i]) {
	break;
      }
    }
    s = x;
  } else {
    for (char c = 'a'; c <= 'z'; c++) {
      if (mc[c] == true) {
	continue;
      } else {
	s += c;
	break;
      }
    }
  }

  print(s);
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, k; cin >> n >> k;
    vector<int> cnt(n, 0);
    rep(i, k) {
        int d; cin >> d;
        rep(j, d) {
            int a; cin >> a; --a;
            cnt[a] ++;
        }
    }
    int ans = 0;
    rep(i, n) {
        if(cnt[i] == 0) ++ ans;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3656
r, D, x2000 = map(int, input().split())
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
x[0] = x2000
for i in range(10):
  x[i + 1] = r * x[i] - D
  print(x[i + 1])

Measured memory_bytes: 3060
// abc046_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n, k;
  ll ans = 1;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    if (i != 0) {
      ans *= k-1;
    } else {
      ans *= k;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
num_books, num_algorithms, knowledge_req = gets.split.map(&:to_i)

prices = []
knowledges = []

num_books.times do |i|
  a = gets.split.map(&:to_i)
  price = a.shift
  prices.push(price)
  knowledges.push(a)
end

res = -1

(0...(1 << num_books)).each do |bits|
  ok = true

  num_algorithms.times do |algorithm|
    knowledge = 0

    num_books.times do |book|
      if bits & (1 << book) != 0
        knowledge += knowledges[book][algorithm]
      end
    end

    if knowledge < knowledge_req
      ok = false
    end
  end

  if ok
    price = 0

    num_books.times do |book|
      if bits & (1 << book) != 0
        price += prices[book]
      end
    end

    res = price if res == -1
    res = [res, price].min
  end
end

puts res

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int changei(string s){
	stringstream ss;
	int k;
	ss<<s;
	ss>>k;
	return k;
}
string changes(int k){
	stringstream ss;
	string s;
	ss<<k;
	ss>>s;
	return s;
}
int main(){
	string s;
	while(1){
		cin>>s;
		if(s=="0000") break;
		string tmp="";
		rep(i,0,4) tmp+=s[0];
		if(s==tmp){
			o("NA"); continue;
		}
		int i=0;
		for(i=0;;i++){
			if(s=="6174") break;
			sort(all(s));
			string t=s;
			reverse(all(t));
			int M,m;
			M=changei(t);
			m=changei(s);
			s=changes(M-m);
			while(s.size()<4) s='0'+s;
		}
		o(i);
	}
}

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

map<int, int> sum, diff;

int main() {

    int n;
    cin >> n;

    for (int i=1; i<=n; i++)
    {
        int h;
        cin >> h;

        sum[h + i]++;
        diff[h - i]++;
    }

    long long ans = 0;

    for (auto s : sum)
        ans += 1LL * s.second * diff[-s.first];

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 29220
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)
#define rrep(i, n) for(int i =int(n-1); i >= 0; i--)

#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

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

    ll zero = 0, pl = 0, mi = 0;
    vector<ll> plv, miv;
    rep(i,n){
        ll x; cin >> x;
        if(x > a){ plv.push_back(x-a); pl += x-a; }
        else if(x < a){ miv.push_back(a-x); mi += a-x; }
        else if(x == a) zero++;
    }

    ll p = plv.size();
    ll m = miv.size();

    vector<ll> p_dp(pl+1,0); p_dp[0] = 1;
    rep(i,p) rrep(j,pl) if(plv[i]+j <= pl) p_dp[plv[i]+j] += p_dp[j];
    vector<ll> m_dp(mi+1,0); m_dp[0] = 1;
    rep(i,m) rrep(j,mi) if(miv[i]+j <= mi) m_dp[miv[i]+j] += m_dp[j];

    ll ans = 0;
    loop(i,1,min(pl,mi)+1) ans += p_dp[i]*m_dp[i];
    ll count = 1; rep(i,zero) count *= 2;
    ans *= count;
    ans += count-1;

    cout << ans << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void){
int m,n,ai,min,max;
long sum;
scanf("%d",&n);
for(m=0;m<n;m++){
scanf("%d",&ai);
if(m==0){
min=ai;
max=ai;
sum=ai;
}
else{
if(ai<min){
min=ai;
}
if(max<ai){
max=ai;
}
sum+=(long)ai;
}
}
printf("%d %d %ld\n",min,max,sum);
return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;

int n;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s;

  string res;
  for (int i = 0; i < s.length(); ++i) {
    char c = s[i] + n;
    if (c > 'Z') c -= 26;
    res += c;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define pb push_back
#define in insert
#define mod 1000000007
#define pi 3.14159265358979

using namespace std;

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

    string s;
    cin>>s;
    lld len=s.size();

    lld ans=0,c=0;
    for(lld i=0;i<len;i++)
    {
        if(s[i]=='W')
        {
            ans+=(i-c);
            c++;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    vector<pair<int,int>> g(n);
    vector<int> order(n);
    double nn = 1;
    for(int i=0; i<n; i++){
        int x,y; cin >> x >> y;
        g[i] = make_pair(x,y);
        order[i] = i;
        nn *= i+1;
    }
    double tot = 0;
    do{
        for(int i=1; i<n; i++){
            tot += sqrt((g[order[i]].first - g[order[i-1]].first) * (g[order[i]].first - g[order[i-1]].first) + (g[order[i]].second - g[order[i-1]].second) * (g[order[i]].second - g[order[i-1]].second));
        }
    }while(next_permutation(order.begin(),order.end()));

    cout << std::fixed << std::setprecision(7) << tot / nn << endl;
}

Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

typedef long long i64;
typedef pair<int,int> P;


int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


int fie[100][100];

int dist[100][100];

int h;
int w;

int black = 0;
int main()
{

	for(int i = 0;i < 100;i++)
	{
		for(int j = 0;j < 100;j++)
		{
			dist[i][j] = 100000;
		}
	}
	string s;

	cin >> h >> w;

	for(int i = 0;i < h;i++)
	{
		cin >> s;
		for(int j = 0;j < w;j++)
		{
			if(s[j] == '#')
			{
				fie[i][j] = 1;
				dist[i][j] = 0;
			}
			else
			{
				black++;
			}
		}
	}

	typedef pair<P,int> P2;

	queue<P2> que;

	que.push(P2(P(0,0),1));



	while(!que.empty())
	{
		int x = que.front().first.first;
		int y = que.front().first.second;
		int c = que.front().second;
		que.pop();



		if(fie[x][y] == 1) continue;
		fie[x][y] = 1;
		dist[x][y] = c;

		for(int d = 0;d < 4;d++)
		{
			int nx = x + dx[d];
			int ny = y + dy[d];

			if(fie[nx][ny] == 0 && 0 <= nx && nx < h && 0 <= ny && ny < w)
			{
				que.push(P2(P(nx,ny),c +1));
			}
		}
	}

	if(fie[h - 1][w - 1] == 0)
	{
		cout << -1 << endl;
		return 0;
	}

	cout << black - dist[h - 1][w - 1] << endl;
	return 0;




}


Measured memory_bytes: 256