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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007


struct edge {
    ll to, cost;
    edge(ll a, ll b) {to = a;  cost = b;}
};

const int MAXV = 2510;
const int INF = 1e9;

vector<edge> G[MAXV];
ll V;
ll d[MAXV];
ll pre[MAXV];

void Bellman_Ford(int s) {
    fill(d, d + V, INF);
    fill(pre, pre + V, -2);
    d[s] = 0;

    rep(k, V) {
        rep(i, V) {
            for (auto e : G[i]) {
                if (d[i] != INF && d[e.to] > d[i] + e.cost) {
                    d[e.to] = d[i] + e.cost;
                    pre[e.to] = i;
                    if (k == V - 1) {
                        d[e.to] = - INF;
                    }
                }
            }
        }
    }
}



int main() {
    ll M, P;
    cin >> V >> M >> P;
    rep(i, M) {
        ll a, b, c; cin >> a >> b >> c;
        a--, b--;
        G[a].pb(edge(b, P - c));
    }

    Bellman_Ford(0);

    bool negcycle = false;
    ll v = pre[V-1];

    rep(i,V){
        ll tmp = pre[v];
        v = tmp;
        if(v == -2){
            negcycle = true;
            break;
        }
    }



    if(negcycle){
        cout << (-d[V - 1] > 0 ? - d[V - 1] : 0) << endl;
    }
    else cout << -1 << endl;


}





Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <cstdlib>
using namespace std;

typedef int INT;
#define int long long

int const X=-11111111111111LL;

int read(){
    string s;cin>>s;
    if(s=="x")return X;
    else{
        stringstream ss(s);
        int t;ss>>t;
        return t;
    }
}

string solve(vector<int> const& v){
    int N=v.size();
    bool none = false;
    for(int i=1;i<N;i++){
        if(v[i]==X && v[i-1]==X){
            none=true;
        }
        if(v[i-1]==X) continue;
        if(v[i]==X) continue;
        if(i%2==0){
            if(!(v[i-1]>v[i]))none=true;
        }else{
            if(!(v[i-1]<v[i]))none=true;
        }
        if(none)break;
    }
    if(none)return "none";

    int r =  1000000000+10;
    int l = -1000000000-10;
    for(int i=0;i<N;i++){
        if(v[i]!=X) continue;
        if(i%2==0){
            if(i>0)   r=min(r,v[i-1]-1);
            if(i<N-1) r=min(r,v[i+1]-1);
        }else{
            if(i>0)   l=max(l,v[i-1]+1);
            if(i<N-1) l=max(l,v[i+1]+1);
        }
    }
    if(l==r){ return [](int l){
            stringstream ss;
            ss << l;
            return ss.str();
        }(l);
    }
    else if(l > r) return "none";
    else return "ambiguous";
}

INT main() {
    int N;
    while(cin>>N && N){
        vector<int> v(N);
        for(int i=0;i<N;i++)v[i]=read();
        cout << solve(v) << endl;
    }
}

Measured memory_bytes: 1240
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
string cal(){
	int n;cin>>n;
	rep(i,10) rep(j,10){
		if(i*j==n) return "Yes";
	}
	return "No";
}
int main()
{
	cout<<cal()<<endl;
}


Measured memory_bytes: 256
n = int(input())
M = []
for i in range(n):
    a = [int(j) for j in input().split()]
    M.append(a)
t = 0
    
for i in range(n):
    for j in range(i+1,n):
        A,B,C,D,E,F = tuple(M[i])
        u,v,w,x,y,z = tuple(M[j])
        s = 0
        for _ in range(3):
            for _ in range(4):
                if A == u and B == v and C == w and D == x and E == y and F == z:
                    s = 1
                    break
                A,B,C,D,E,F = A,C,E,B,D,F #R
            A,B,C,D,E,F = D,B,A,F,E,C #E
            for _ in range(4):
                if A == u and B == v and C == w and D == x and E == y and F == z:
                    s = 1
                    break
                A,B,C,D,E,F = A,C,E,B,D,F #R
            A,B,C,D,E,F = B,F,C,D,A,E #N

        if s != 0:
            t = 1
            
if t == 0:
    print("Yes")
else:
    print("No")
              

Measured memory_bytes: 7820
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

list<ll> l;

int main(void){
    ll n,x;
    char cmd[20];
    scanf("%lld",&n);

    REP(aaa,n){
        scanf("%s",cmd);
        if(cmd[0] == 'i'){
            scanf("%lld",&x);
            l.push_front(x);
        }else if(cmd[6] == '\0'){
            scanf("%lld",&x);
            list<ll>::iterator it = l.begin();
            while(it != l.end()){
                if(*it == x){
                    l.erase(it);
                    break;
                }
                it++;
            }
        }else if(cmd[6] == 'F')
            l.pop_front();
        else
            l.pop_back();
    }
    list<ll>::iterator it = l.begin();
    while(it != l.end()){
        printf("%lld",*it);
        it++;
        if(it != l.end())
            printf(" ");
    }
    printf("\n");
    return 0;
} 

Measured memory_bytes: 34404
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

struct Edge { int from, to; };
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &g, int from, int to) {
	g[from].push_back(Edge{ from, to });
}

void dfs(const Graph& g, int v, vector<bool>& used, vi& vs)
{
	used[v] = true;
	for (auto i : g[v])
	{
		if (!used[i.to]) dfs(g, i.to, used, vs);
	}
	vs.push_back(v);
}

void rdfs(const Graph& rg, int v, vector<bool>& used, int k, vi& cmp)
{
	used[v] = true;
	cmp[v] = k;
	for (auto i : rg[v])
	{
		if (!used[i.to]) rdfs(rg, i.to, used, k, cmp);
	}
}

int strongly_connected_component(Graph graph, vi& cmp)
{
	int V = graph.size();
	Graph g(V), rg(V);
	vector<bool> used(V);
	vi vs;
	cmp.resize(V);
	REP(i, V)
	{
		for (auto e : graph[i])
		{
			add_edge(g, i, e.to);
			add_edge(rg, e.to, i);
		}
	}
	REP(i, V)
	{
		if (!used[i]) dfs(g, i, used, vs);
	}
	used = vector<bool>(V);
	reverse(ALL(vs));
	int k = 0;
	for (auto i : vs)
	{
		if (!used[i]) rdfs(rg, i, used, k++, cmp);
	}
	return k;
}

Graph buildGraph(const Graph& g, const vi& cmp, int K)
{
	int V = g.size();
	vector<set<int>> s(K);
	Graph res(K);
	REP(i, V)
	{
		for (auto e : g[i]) s[cmp[i]].insert(cmp[e.to]);
	}
	REP(i, K)
	{
		for (auto j : s[i]) if (i != j) add_edge(res, i, j);
	}
	return res;
}

ll solve(const vector<vi>& tree, int v)
{
	ll res = 1, tmp = 1;
	REP(i, tree[v].size())
	{
		tmp *= solve(tree, tree[v][i]);
		tmp %= MOD;
	}
	res += tmp;
	return res;
}

int main()
{
	int n, m;
	cin >> n >> m;
	Graph g(n);
	REP(i, m)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		add_edge(g, a, b);
	}
	vi cmp;
	int k = strongly_connected_component(g, cmp);
	Graph dag = buildGraph(g, cmp, k);
	vector<vi> tree(n);
	vi root;
	REP(i, dag.size())
	{
		if (dag[i].size() == 0) root.push_back(i);
		for (auto e : dag[i])
		{
			tree[e.to].push_back(e.from);
		}
	}
	ll ans = 1;
	REP(i, root.size())
	{
		ans *= solve(tree, root[i]);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	int n, a, cnt = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (i % 2 == 0 || a % 2 == 0)
			continue;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3644
INF = float('inf')

def bellman_ford(graph, weights, s):
  d = {v: INF for v in graph}
  d[s] = 0
  edges = [(u, v) for u, vs in graph.items() for v in vs]
  for _ in range(len(graph) - 1):
    for (u, v) in edges:
      d_temp = d[u] + weights[u, v]
      if d_temp < d[v]:
        d[v] = d_temp

  for (u, v) in edges:
    if d[u] + weights[u, v] < d[v]:
      print('NEGATIVE CYCLE')
      return None
  return d


n_vertex, n_edge, s = [int(x) for x in input().split()]
graph = {i: [] for i in range(n_vertex)}
weights = {}
for i in range(n_edge):
    u, v, w = [int(x) for x in input().split()]
    graph[u].append(v)
    weights[u, v] = w

d = bellman_ford(graph, weights, s)

if d is not None:
    for i in range(n_vertex):
        print(d[i] if d[i] is not INF else 'INF')


Measured memory_bytes: 6496
import math

x, n = map(int, input().split())
p = list(map(int, input().split()))

pnt_big = 0
pnt_small = 0
ans_big = 100
ans_small = 100
for i in range(101):
    if p.count(x+i) == 0:
        ans_big = x+i
        pnt_big = 1
    if p.count(x-i) == 0:
        ans_small = x-i
        pnt_small = 1
    if pnt_small == 1 or pnt_big == 1:
        break

if pnt_big ==1 and pnt_small == 1:
    print(ans_small)
if pnt_big == 0 and pnt_small == 1:
    print(ans_small)
if pnt_big == 1 and pnt_small == 0:
    print(ans_big)

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto L=in(),R=in(),D=in();
	ll S=0;
	for(ll i=L;i<=R;i++){
		if(!(i%D)) S++;
	}
	out(S);
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e5+20;
const int inf=0x3f3f3f3f;

vector<int>ed[maxn];
int rd[maxn];
int n;

inline void init()
{
	n=read();
	REP(i,1,n-1)
	{
	 	int x=read(),y=read();
	 	ed[x].push_back(y);
	 	ed[y].push_back(x);
	 	rd[x]++;rd[y]++;
	}
	REP(i,1,n)sort(ed[i].begin(),ed[i].end(),[](int a,int b){ return rd[a]<rd[b];});
}

int cir[maxn],clen;

inline int bfs(int S)
{
	static int dis[maxn],pre[maxn];
	queue<int>q;
	memset(dis,inf,sizeof(dis));
	memset(pre,0,sizeof(pre));
	dis[S]=0; q.push(S); 
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int v:ed[u])
		{
			if(dis[v]>dis[u]+1)
			{
				dis[v]=dis[u]+1;
				pre[v]=u;
				q.push(v);
			}
		}
	}
	int mx=1;
	REP(i,1,n)if(dis[i]>dis[mx])mx=i;
	int u=mx;
	clen=0;
	while(u)cir[++clen]=u,u=pre[u];
	return mx;
}

int vis[maxn];
int times;
int id[maxn];

void getid(int u,int fa)
{
	id[u]=++times;
	for(int v:ed[u])if(v!=fa)getid(v,u);
}

void dfs(int u,int fa,vector<int>&A)
{
	vector<int>son;
	for(int v:ed[u])if(v!=fa)son.push_back(v);
	REP(i,0,SZ(son)-2)A.push_back(id[son[i]]);
	A.push_back(id[u]);
	if(!son.empty())dfs(son.back(),u,A);
}

inline void doing()
{
	int S=bfs(1);
	bfs(S);
	REP(i,1,clen)vis[cir[i]]=1;
	REP(i,1,clen)
	{
		for(int v:ed[cir[i]])
			if(!vis[v] && rd[v]>=2)
				puts("-1"),exit(0);
	}
	vector<int>A,B;
	times=0; getid(cir[1],0); dfs(cir[1],0,A);
	times=0; getid(cir[clen],0); dfs(cir[clen],0,B);
	chkmin(A,B);
	REP(i,0,n-1)printf("%d ",A[i]);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 22856
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
uvw = [LIST() for _ in range(N-1)]

graph = defaultdict(list)

for u, v, w in uvw:
	graph[u-1].append((v-1, w))
	graph[v-1].append((u-1, w))

#print(graph)

color = [0]*N
color[0] = 1

def DFS(node):
	for x, w in graph[node]:
		if not color[x]:
			if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			DFS(x)

DFS(0)

for x in color:
	if x == 1:
		print(0)
	elif x == -1:
		print(1)
	else:
		print("HOGE")






Measured memory_bytes: 108088
#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 fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  string ans;
  if(c-a-b >=0 && 4*a*b < (c-a-b)*(c-a-b)){
    ans="Yes";
  }
  else{
    ans="No";
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
letter = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
num = int(input())
print(letter[num - 1])

Measured memory_bytes: 3064
/*
welcome to my code           hi from    s_agnik1511 
Don't just copy it.
Analyze it.
coz that's what heroes do.....
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#include<numeric>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
#define dude             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mesc(number,character)   char f[number];memset(f,character,number);
#define mesi(number,value)   int f[number];memset(f,value,number);
#define fr(i,start,end)  for(i=start;i<=end;i++)
#define rf(i,start,end)  for(i=start;i>=end;i--)
#define tst              int t;cin>>t;while(t--)
#define ai               ll n,i;cin>>n;ll a[n];
#define pi               3.14159265358979323846
#define ll               long long int
#define acc              accumulate
#define ld               long double
#define pb               push_back
#define r0               return 0;
#define pp               pop_back
#define vec              vector
#define sec              second
#define S                string
#define D                double
#define len              length
#define br               break;
#define wh               while
#define fs               first
#define F                float
#define gcd              __gcd
#define sz               size
#define endl             "\n"
#define sp              " "
const ll ifn=-1000000000000000000;
const ll inf=1000000000000000000;
const int N=100000;
    //vec<ll>arr(N,-1);
    //memset(arr,0,N);
ll power(ll x, ll y, ll p) { 
    ll res = 1;
    x = x % p;  
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p; 
    } 
    return res; 
} 
void swap(int x,int y) {
    int t=x;
    x=y;
    y=t;
}
bool vow(char c) {
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='A'||c=='E'||c=='I'||c=='O'||c=='U') {
        return true;
    }
    else {
        return false;
    }
}
/*int facti(ll x) {
    if(arr[x]!=-1)return arr[x];
    else {
    if(x<=1) {
        arr[x]=1;
    }
    else if(x==2) {
        arr[x]=2;
    }
    else {
        arr[x]=x*facti(x-1);
        arr[x]%=1000000007;
    }
    return arr[x]%1000000007;
    }
}*/
bool isPrime(ll n) { 
    if (n<=1)  return false; 
    if (n<=3)  return true;
    if (n%2==0||n%3==0) return false; 
  
    for (ll i=5;i*i<=n;i=i+6) 
        if (n%i==0||n%(i+2)==0) 
           return false; 
  
    return true; 
} 
int chek(S s,int i,int j) {
    ll cnt=0,k,a;
    fr(k,i,j) {
        //cnt=(cnt*10)+(int(s[k])-48);
        a=int(s[k])-48;
        cnt=(cnt*10)+(a);
    }
    return cnt;
}
int lcm(ll a,ll b) {
    return (a*b)/gcd(a,b);
}
void solve() {
S s;
cin>>s;
(s=="ARC")?cout<<"ABC":cout<<"ARC";
}
int main() {
    dude
    solve();
   r0
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
n,k=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
mod=10**9+7
import numpy as np
dp=np.zeros((n+1,k+1),dtype=np.int64)
dp[0][0]=1
for i in range(n):
    dp[i+1]=dp[i]
    dp[i+1,a[i]+1:]-=dp[i,:-(a[i]+1)]
    np.cumsum(dp[i+1],out=dp[i+1])
    dp[i+1]%=mod
print(dp[n][k])

Measured memory_bytes: 90484
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

ll result[200005] = {0};
void fact(ll n) {
   if (n >= 0) {
      result[0] = 1;
      for (ll i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
   }
}

void dfs(ll n, ll m, ll i, vector<ll> &v){
  if(i == n){
  }else{
    for(int k = 1; k <= m; k++){
      v.push_back(k);
      dfs(n, m, i+1, v);
      v.pop_back();
    }
  
  }
}

void solution(){
  ll n, k;
  cin >> n >> k;
  set<ll> s;
  loop(i, k){
    ll d;
    cin >> d;
    loop(j, d){
      ll tmp;
      cin >> tmp;
      s.insert(tmp);
    }
  }

  cout << n-s.size() << endl;
}     



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

int main(void){

	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (r <= x&&r + x <= W&&r <= y&&r + y <= H){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
/**
 * Created by hiramekun at 20:57 on 2020-04-26.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll k, x;
    cin >> k >> x;
    cout << (k * 500 >= x ? "Yes" : "No") << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	//initialize
	int a[4][13];
	int i,j;
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			a[i][j] = 1;
		}
	}
	//scanning
	int n;
	scanf("%d\n",&n);
	int k;
	for(k=0;k<n;k++){
		char p;
		int r;
		int q;
		scanf("%c ",&p);
		scanf("%d\n",&q);
		if(p=='S'){
			r = 0;
		}else if(p=='H'){
			r = 1;
		}else if(p=='C'){
			r = 2;
		}else{
			r = 3;
		}
		q = q-1;
		a[r][q] = 0;
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(a[i][j]==1){
				if(i==0){
					printf("S ");
				}else if(i==1){
					printf("H ");
				}else if(i==2){
					printf("C ");
				}else{
					printf("D ");
				}
				printf("%d\n",j+1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;
int n ,m;
long long lcm ,a[N];
long long lcm2 ;
int main(){
    cin >> n >> m ;
    for(int i=0;i<n;++i){
        scanf("%lld",a+i);
        if(!i) lcm = a[i]/2 ,lcm2 = a[i] ;
        else{
            lcm2 = lcm2 * a[i] / __gcd(lcm2,a[i]) ;
            lcm = lcm/__gcd(lcm,a[i]/2)*(a[i]/2) ;
        }
    }
    if(lcm>m) return cout << 0,0 ;
    for(int i=0;i<n;++i){
        long long x = lcm / (a[i]/2) ;
        if(x%2) continue ;
        return cout << 0,0 ;
    }
    long long x = (m - lcm)/lcm2 ;
    cout << x+1 ;
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;


int main() {
	double a, b, c; cin >> a >> b >> c;
	double s, l, h;

	h = sin(c / 180.*M_PI)*b;
	s = a * h / 2.;

	double d = sqrt(b*b - h * h);
	double e = hypot(h, (c > 90) ? a + d : abs(a - d));
	l = a + b + e;

	printf("%.20f\n%.20f\n%.20f\n", s, l, h);
}


Measured memory_bytes: 3360
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int64_t sum = 0;
    if (A >= (2 * C) && B >= (2 * C)) {
        int64_t s = max(X, Y);
        sum += s * (2 * C);
    } else if ((A + B) >= 2 * C) {
        if (X > Y) {
            int64_t sa = X - Y;
            int64_t s = min(X, Y);
            sum += s * (2 * C);
            sum += min((sa * A), (sa * 2 * C));
        } else if (Y > X) {
            int64_t sa = Y - X;
            int64_t s = min(X, Y);
            sum += s * (2 * C);
            sum += min((sa * B), (sa * 2 * C));
        } else {
            int64_t s = min(X, Y);
            sum += s * (2 * C);
        }
    } else {
        sum = (A * X) + (B * Y);
    }

    cout << sum << endl;
    return 0;
}

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

using namespace std;

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


	int n,k;cin>>n>>k;
	int res=k;
	for(int i=1;i<=n-1;i++){
		res=res*(k-1);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
input = gets.split().map(&:to_i)
N = input[0]
Y = input[1]
res = "-1 -1 -1"

(0..N).each do |i|
    (0..(N-i)).each do |j|
        k = N - i - j
      	res = "#{i} #{j} #{k}" if 10000 * i + 5000 * j + 1000 * k == Y
    end
end

puts res

Measured memory_bytes: 1788
### coding: UTF-8

#import math
#import random as rd
#import numpy as np

n,a,b=map(int,input().split( ))

s=0


for i in range(n):
    line=list(map(int,str(i+1)))
    if sum(line)>=a and sum(line)<=b:
        s+=i+1

print(s)



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
	double pi=M_PI,c,S,L,h,hen;
	double a,b;
	cin>>a>>b>>c;
	double rad=c/180*pi;
	//cout<<sin(rad)<<endl;
	S=1/2.0*a*b*sin(rad);
	h=2*S/a;
	hen=pow(a*a+b*b-2*a*b*cos(rad),1.0/2);
	L=hen+a+b;
	cout<<setprecision(10)<<S<<endl<<L<<endl<<h<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  map<string,int> mp; //mp.find("")!=mp.end(); mp[ss]+=1;
  mp["AC"]=0;
  mp["WA"]=0;
  mp["TLE"]=0;
  mp["RE"]=0;
  rep(i,n){
    string ss;cin>>ss;
    mp[ss]++;
  }

  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;
}


Measured memory_bytes: 3668
function Main(inp) {
    var input = inp.split("\n");
    var s = input[0];
    var total = 700;
    for (var i = 0; i < 3; i++) {
        if (s[i] === 'o') {
            total += 100;
        }
    }
    console.log(total);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
<?php
    list($N,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    for($x=1;$x<=$N;$x++){
        $flg[$x] = $x;
    }
    
    for($i=1;$i<=$K;$i++){
        $gomi = fgets(STDIN);
        
        $array[$K] = array_map('intval',explode(" ",trim(fgets(STDIN))));
        
        // var_dump($array[$K]);
        
        foreach($array[$K] as $value){
            // echo $value;
            if(in_array($value,$flg)){
                // echo "a\n";
                $flg[$value] = "a";
            }
        }
    
    }
    $count=0;
    foreach ($flg as $value){
        if($value != "a"){
            $count++;
        }
    }
    echo $count."\n";

    
    
?>

Measured memory_bytes: 16368
#include<stdio.h>

int main()

{
  int A1,A2,A3,x;
  scanf("%d %d %d",&A1,&A2,&A3);
  x=A1+A2+A3;
  if(x==22 || x>22)
  {
      printf("bust\n");
  }
  else
  {
      printf("win\n");
  }

  return 0;
}


Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main(){

    while(1){

        //入力
        int n; cin >> n;
        if(!n) break;
        vector<vector<bool> > date(n + 1, vector<bool> (31, false));
        vector<set<int> > map(n + 1);

        for(int i = 1; i <= n; i++){
            int num; cin >> num;
            for(int j = 0; j < num; j++){
                int input; cin >> input;
                date[i][input] = true;
            }

            map[i].insert(i);
        }

        //setを用いたdp

        for(int d = 1; d <= 30; d++){

            set<int> temp;
            for(int i = 1; i <= n; i++){
                if(!date[i][d]) continue;

                for(set<int>::iterator it = map[i].begin(); it != map[i].end(); it++){
                    temp.insert(*it);
                }
            }

            if(temp.size() == n){
                cout << d << endl;
                goto NEXT;
            }

            for(int i = 1; i <= n; i++){
                if(date[i][d]) map[i] = temp;
            }
        }
        cout << -1 << endl;
        NEXT: ;
    }

    return 0;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [set() for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)
ans = 0
seen = [0]*n
def dfs(v):
    res = 0
    stack = [v]
    seen[v] = True
    while stack:
        res += 1
        v = stack.pop()
        for nv in G[v]:
            if seen[nv]:
                continue
            seen[nv] = True
            stack.append(nv)
    return res
for i in range(n):
    if not seen[i]:
        ans = max(ans, dfs(i))
print(ans)

Measured memory_bytes: 151004
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]

n,m,s,t = map(int, input().split())
uvab = [list(map(int, input().split())) for i in range(m)]
Ga = Graph()
Gb = Graph()
for u,v,a,b in uvab:
  Ga.add_edge(u-1,v-1,a)
  Ga.add_edge(v-1,u-1,a)
  Gb.add_edge(u-1,v-1,b)
  Gb.add_edge(v-1,u-1,b)
dist_a = Dijkstra(Ga,s-1)
dist_b = Dijkstra(Gb,t-1)
cost = 10 ** 18
money = 10 ** 15
ans = []
for i in range(n-1,-1,-1):
  tmp = dist_a.shortest_distance(i) + dist_b.shortest_distance(i)
  cost = min(cost, tmp)
  ans.append(cost)
for i in reversed(ans):
  print(money - i)

Measured memory_bytes: 147708
#include"bits/stdc++.h"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using ll=long long; 
using ld=long double; 
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int mod1=1e9+7; 
#define MAX 1000002
ll fact[MAX+7];
ll powerm1(ll a,ll b){ ll res=1; while(b) { if(b&1) res=(res*a)%mod1; a=(a*a)%mod1; b>>=1; } return res; }
void fac(){ fact[0]=1; fact[1]=1; rep(i,2,MAX-1) fact[i]=(fact[i-1]*i)%mod1; }
ll modInv(int n){ return powerm1(n,mod1-2); }
int ncr(int n,int r){ if (r==0) return 1; return (fact[n]*modInv(fact[r])%mod1*modInv(fact[n-r])%mod1)%mod1; }
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif
  int n; cin>>n; if(n<2){ cout<<0; return 0; } if(n==2){ cout<<2<<"\n"; return 0; }
  ll ans=powerm1(10,n); ans=(ans-2*powerm1(9,n)); while(ans<0) ans+=mod1; ans=(ans+powerm1(8,n))%mod1; cout<<ans; 
}

Measured memory_bytes: 3548
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());

            var p = (x - a) % b;
            Console.WriteLine(p);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll r, d, x;
    cin >> r >> d >> x;

    rep (i, 10)
    {
        x = x * r - d;

        cout << x << endl;
    }

    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

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

    int ans=0;
    rep(i,4){
        if(s[i]=='2'){
            ans++;
        }
    }
    cout<<ans<<endl;
}



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


int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(c-a-b<=0) printf("No");
	else {
		if(1ll*(c-a-b)*(c-a-b)<=4ll*a*b) printf("No");
		else printf("Yes");
	}
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int s[100001], v[100001], r[100001];

void init() {
  rep(i, 0, 100001) {
    s[i] = i;
    r[i] = 0;
  }
}

int find(int x) {
  if(s[x] == x) {
    return x;
  }else {
    return s[x] = find(s[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(r[x] < r[y]) {
    s[x] = y;
    if(v[x]) v[y] = v[x];
  }else {
    s[y] = x;
    if(r[x] == r[y]) r[x]++;
    if(v[y]) v[x] = v[y];
  }
}

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int a[200001], b[200001], c[200001];
  init();
  rep(i, 0, k) cin >> a[i] >> b[i] >> c[i];
  rep(i, 0, k) {
    if(a[i] == 1) {
      int bb = find(b[i]);
      int cc = find(c[i]);
      if(v[bb] && v[cc] && v[bb] != v[cc]) {
        cout << i + 1 << endl;
        return 0;
      }
      unite(bb, cc);
    }else {
      int bb = find(b[i]);
      if(v[bb] && v[bb] != c[i]) {
        cout << i + 1 << endl;
        return 0;
      }
      v[bb] = c[i];
    }
  }

  cout << 0 << endl;
}

Measured memory_bytes: 6624
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;


struct UnionFind {
    vector<int> par;  // 根の番号
    map<int,int> parcnts; // 2つ以上のノードを持つグループについて、根の番号とサイズを保持。1つのやつは持たなくていい
    int N;
    ll inconv; // 不便さ : uniteするごとに差分更新する

    UnionFind(int _N) : par(_N) { 
        for(int i = 0; i < _N; i++) par[i] = i; //最初は全員が自分自身を根にもつ
        N = _N;
        inconv = ((ll)N)*((ll)N-1)/2;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { 
    	ll rxcnt,rycnt; // x,yの根のグループに属する個数
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        par[rx] = ry; 
        if(parcnts.find(rx)==parcnts.end()){
        	rxcnt = 1;
        }else{
        	rxcnt = parcnts.find(rx)->second;
        	parcnts.erase(rx);
        }
        if(parcnts.find(ry)!=parcnts.end()){
        	rycnt = parcnts.find(ry)->second;
        	parcnts.find(ry)->second += rxcnt;
        }else{
        	rycnt = 1;
        	parcnts.insert(mp(ry,1+rxcnt));
        }


        ll inconv_x = rxcnt*(rxcnt-1)/2; // xのグループ内での便利さ
        ll inconv_y = rycnt*(rycnt-1)/2; // yのグループ内での便利さ
        ll inconv_xy = (rxcnt+rycnt)*(rxcnt+rycnt-1)/2; // xとyのグループを併合したときの便利さ
        inconv = inconv + inconv_x + inconv_y - inconv_xy; // これらを踏まえて、全体の不便さを差分更新
    }
};

int main(int argc, const char * argv[]) {
	ll n,m;
	cin >> n >> m;
	int a[m],b[m];
	ll ret[m+1];

	REP(i,m){
		cin >> a[i] >> b[i];
	}

	UnionFind tree(n);

	ret[m] = n*(n-1)/2;
	for(int i=m-1;i>=0;i--){
		tree.unite(a[i]-1,b[i]-1);
		ret[i] = tree.inconv;
	}

	FOR(i,1,m){
		println(ret[i]);
	}

	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;cin>>s;
    stack<char> S;

    for(auto i:s)
    {
        if(i == '0' || i == '1')
            S.push(i);
        else if(!S.empty())
            S.pop();
    }

    string ans = "";

    while(!S.empty())
    {
        ans+=S.top();
        S.pop();
    }

    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    int siz=t.size();
    vector<vector<int>>dp(n,vector<int>(3,-1000000000));
    for(int i=0;i<k;i++){
        if(t[i]=='r'){
            dp[i][0]=0;
            dp[i][1]=0;
            dp[i][2]=p;
        }
        if(t[i]=='s'){
            dp[i][0]=r;
            dp[i][1]=0;
            dp[i][2]=0;
        }
        if(t[i]=='p'){
            dp[i][0]=0;
            dp[i][1]=s;
            dp[i][2]=0;
        }
    }
    for(int i=0;i+k<n;i++){
        if(t[i+k]=='r'){
            dp[i+k][0]=max({dp[i+k][0],dp[i][1],dp[i][2]});
            dp[i+k][1]=max({dp[i+k][1],dp[i][0],dp[i][2]});
            dp[i+k][2]=max({dp[i+k][2],dp[i][0]+p,dp[i][1]+p});
        }
        if(t[i+k]=='s'){
            dp[i+k][0]=max({dp[i+k][0],dp[i][1]+r,dp[i][2]+r});
            dp[i+k][1]=max({dp[i+k][1],dp[i][0],dp[i][2]});
            dp[i+k][2]=max({dp[i+k][2],dp[i][0],dp[i][1]});
        }
        if(t[i+k]=='p'){
            dp[i+k][0]=max({dp[i+k][0],dp[i][1],dp[i][2]});
            dp[i+k][1]=max({dp[i+k][1],dp[i][0]+s,dp[i][2]+s});
            dp[i+k][2]=max({dp[i+k][2],dp[i][0],dp[i][1]});
        }
    }
    int x=0;
    for(int i=n-1;i>=n-k;i--)x+=max({dp[i][0],dp[i][1],dp[i][2]});
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include <functional>
#include <queue>
using namespace std;
using ll = long long;
vector<int> G[100000];
int Par[100000];
int n,m;
int tocnt[100000];
int root;
int depth[100000];

int dfs(int idx)
{
	if(depth[idx]!=0)return depth[idx];
	if(G[idx].empty())return depth[idx] = 1;
	for(auto &i:G[idx])
	{
		depth[idx] = max(depth[idx],dfs(i)+1);
	}
	return depth[idx];
}


int main()
{
	cin >> n >> m;
	for(int i = 0;i<n+m-1;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		tocnt[b]++;
	}
	for(int i = 0;i<n;i++)
	{
		if(tocnt[i]==0)root = i;
	}
	map<pair<int,int>,bool> mp;
	using P = pair<int,int>;
	priority_queue<P,vector<P>,greater<P>> pq;
	pq.emplace(0,root);

	vector<P> vp;
	dfs(root);
	for(int i = 0;i<n;i++)
		vp.emplace_back(depth[i],i);

	sort(vp.begin(),vp.end(),greater<>());
	vector<int>depth2(n);

	for(int i =0;i<n;i++)
	{
		int now = vp[i].second;
		for(auto &j:G[now])
		{
			depth2[j] = depth2[now]+1;
		}
	}
	
	for(int i =0;i<n;i++)
	{
		for(auto j:G[i])
		{
			if(depth2[i]-depth2[j]==-1)
			{
				Par[j] = i;
			}
		}
	}
	
	Par[root] = -1;
	for(int i = 0;i<n;i++)cout << Par[i]+1 << endl;
}


Measured memory_bytes: 15696
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n,ar[3][3],b[15];
  bool visited[3][3];
  for(int i = 0;i<3;i++){
    for(int j  = 0;j<3;j++){
      cin >> ar[i][j];
    }
  }
  cin >> n;
   for(int i = 0;i<n;i++){
      cin >> b[i];
      }

 for(int i = 0;i<3;i++){
   for(int j = 0;j<3;j++){
      visited[i][j] = false;
      for(int k = 0;k<n;k++){
        if(ar[i][j]==b[k])visited[i][j] = true;
      }
   }
 }

 int ans = 0;
 for(int i = 0;i<3;i++){
    if(visited[i][0] && visited[i][1] && visited[i][2])ans = 1;
 }
 for(int i = 0;i<3;i++){
    if(visited[0][i] && visited[1][i] && visited[2][i])ans = 1;
 }

 if(visited[0][0] && visited[1][1] && visited[2][2])ans = 1;
 if(visited[0][2] && visited[1][1] && visited[2][0])ans = 1;

  if(ans==1)cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        String res = "Yes";
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                res = "No";
                break;
            }
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 35836
def z_algo(s):
    """Z-algorithm O(|S|)

    Args:
        s (str): 対象文字列
    
    Returns:
        list: lcp配列 (z[i]: sとs[i:]の最長共通接尾辞の長さ)
    """
    n = len(s)
    z = [0] * n
    z[0] = n
    i, j = 1, 0
    while i < n:
        while i + j < n and s[j] == s[i+j]:
            j += 1
        z[i] = j

        if j == 0:
            i += 1
            continue

        k = 1
        while i + k < n and k + z[k] < j:
            z[i+k] = z[k]
            k += 1

        i += k
        j -= k

    return z


n = int(input())
s = input()

res = 0
for i in range(n-1):
    z = z_algo(s[i:])
    for j in range(n-i):
        if z[j] <= j and res < z[j]:
            res = z[j]

print(res)

Measured memory_bytes: 79464
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
    int N,D;
    cin >> N >> D;
    int A = 2*D+1;
    int B;
    B = N/A;
    if(N%A!=0)B++;
    cout << B << endl;
    }

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

int P, Q, A, N;
int dfs(int p, int q, int x, int n) {
    if (P * q == Q * p) return 1;
    if (P * q < Q * p) return 0;
    if (n == N) return 0;
    int ret = 0;
    for (int i = x; q * i <= A; i++) {
        ret += dfs(p*i + q, q*i, i, n+1);
    }
    return ret;
}

int main() {
    while (cin >> P >> Q >> A >> N, P) {
        cout << dfs(0, 1, 1, 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);

    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3500
// Vicfred
// https://atcoder.jp/contests/abc178/tasks/abc178_d
// math
import std.stdio;

void main() {
    const int mod = 10^^9+7;
    int n;
    readf("%s", &n);

    int[] dp = new int[n+1];

    dp[0] = 1;

    for(int i = 3; i <= n; i++)
        dp[i] = 1;

    for(int i = 3; i <= n; i++) {
        for(int j = 3; j <= i-3; j++) {
            dp[i] += dp[j];
            dp[i] %= mod;
        }
        dp[i] %= mod;
    }

    dp[n].writeln;
}



Measured memory_bytes: 2828
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    char a;
    cin>>a;
    if(isupper(a))
    {
        cout<<"A";
    }
    else
    {
        cout<<"a";
    }
    
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	bool ok = true;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	if (A[0] != 0)ok = false;
	for (int i = 1; i < N; i++) {
		if (A[i] - A[i - 1] >= 2) {
			ok = false;
		}
	}
	if (!ok) {
		cout << -1 << endl;
	}
	else {
		//A.push_back(0);
		for (int i = 1; i < N; i++) {
			if (A[i] != 0) {
				if (A[i] == A[i - 1] + 1) {
					res++;
				}
				else {
					res += A[i];
				}
			}
		}
		cout << res << endl;
	}

	
}

Measured memory_bytes: 1792