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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, x, y; std::cin >> n >> x >> y;
  x--, y--;
  vector<vi> cost(n, vi(n));
  rep(i, n) rep(j, n) cost[i][j] = abs(i-j);
  cost[x][y] = cost[y][x] = 1;
  rep(i, n) srep(j, i+1, n) {
    int tmp = cost[i][x]+cost[x][y]+cost[y][j];
    if (cost[i][j] > tmp) cost[i][j] = cost[j][i] = tmp;
  }
  map<int, int> cnt;
  rep(i, n) rep(j, n) cnt[cost[i][j]]++;
  srep(i, 1, n) std::cout << cnt[i]/2 << "\n";
}


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

int main(void){
  while(1){
    int n, r;
    cin >> n;
    cin >> r;
    if(n == 0 && r == 0){return 0;}

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

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


    for(int i = 0 ; i < r ; i++){
      int tempu[p[i]-1];
      int tempd[c[i]];
      for(int j = 0 ; j < p[i]-1 ; j++){
        tempu[j] = f[j];
      }
      for(int j = 0 ; j < c[i] ; j++){
        tempd[j] = f[j + p[i] -1];
      }
      for(int j = 0 ; j < c[i] ; j++){
        f[j] = tempd[j];
      }
      for(int j = 0 ; j < p[i]-1 ; j++){
        f[j+c[i]] = tempu[j];
      }
    }

    cout << f[0] << endl;
  }
}

Measured memory_bytes: 3016
#include <stdio.h>

#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int main() {
  priority_queue<int> q;
  int n, m;
  cin >> n >> m;
  int a;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a);
    sum += a;
    q.push(a);
  }

  for (int i = 0; i < m; ++i) {
    int po = q.top();
    int sa = po / 2;
    sum -= po - sa;
    q.pop();
    q.push(sa);
  }

  cout << sum << endl;
}


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

int main(){
  int H,W;
  bool sp;
  
  cin >> H >> W;
  
  vector<vector<char>> pace(H,vector<char>(W));
  for(int i = 0; i < H;i++){
  	for(int j = 0; j < W;j++){
    	cin >> pace.at(i).at(j);
    }
  }
 
  for(int i = 0; i < W;i++){
    sp = true;
  	for(int j = 0; j < H;j++){
      if(pace.at(j).at(i) == '#'){
        sp = false;
      	break;
      }
    }
    if(sp){
    	for(int j = 0; j < H;j++){
        	pace.at(j).at(i) = '_';
        }
    }
  }
  for(int i = 0; i < H;i++){
    sp = true;
  	for(int j = 0; j < W;j++){
    	if(pace.at(i).at(j) == '#'){
        sp = false;
      	break;
      }
    }
    if(sp){
        pace.at(i).at(0) = 'd';     
    }
  }
  
  for(int i = 0; i < H;i++){
    sp = true;
  	for(int j = 0; j < W;j++){
      if(pace.at(i).at(0) == 'd'){
        sp = false;
      	break;
      }
      if(pace.at(i).at(j) != '_')
      cout << pace.at(i).at(j);
    }
    if(sp){
    	cout << endl;
    }
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

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


int main(){

    ll N;
    cin >> N;

    ll ans = 0;
    for(ll i = 1; i <= N; i += 2){
        vector<ll > ret = divisor(i);
        if(ret.size() == 8){
            ans++;
        }
    }

    cout << ans << endl;

} 

Measured memory_bytes: 256
#include <stdio.h>

#include <string.h>
#include <math.h>

void one(double *a,double *b,int c){
    double answer=0;
    int i;
    for(i=0;i<c;i++){
        answer += fabs(*a-*b);
        a++;
        b++;
    }
    printf("%lf\n",answer);
}
void two(double *a,double *b,int c){
    double answer=0;
    int i;
    for(i=0;i<c;i++){
        answer += pow(fabs(*a-*b), 2);
        a++;
        b++;
    }
    printf("%lf\n",sqrt(answer));
}
void three(double *a,double *b,int c){
    double answer=0;
    int i;
    for(i=0;i<c;i++){
        answer += pow(fabs(*a-*b), 3);
        a++;
        b++;
    }
    printf("%lf\n",pow(answer,1.0/3.0));
}
void EX(double *a,double *b,int c){
    double answer=0;
    int i;
    answer += fabs(*a-*b);
    for(i=0;i<c;i++){
        if(answer<fabs(*a-*b)){
            answer=fabs(*a-*b);
        }
        a++;
        b++;
    }
    printf("%lf\n",answer);
}

int main(void){
    int Num;
    double InputA[100],InputB[100];
    int i;

    scanf("%d",&Num);

    for(i=0;i<Num;i++){
        scanf("%lf",&InputA[i]);
    }
    for(i=0;i<Num;i++){
        scanf("%lf",&InputB[i]);
    }

    one(&InputA[0], &InputB[0], Num);
    two(&InputA[0], &InputB[0], Num);
    three(&InputA[0], &InputB[0], Num);
    EX(&InputA[0], &InputB[0], Num);

}



Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    vl c(n), d(n);
    int ret = 0;
    for (int i = 0; i <= 30; ++i) {
        for (int j = 0; j < n; ++j) {
            c[j] = a[j] % (1 << (i + 1));
            d[j] = b[j] % (1 << (i + 1));
        }
        sort(c.begin(), c.end());
        sort(d.begin(), d.end());
        ll count = 0;
        for (int j = 0; j < n; ++j) {
            count += lower_bound(d.begin(), d.end(), (1LL << (i + 1)) - c[j]) - d.begin();
            count -= lower_bound(d.begin(), d.end(), (1LL << (i)) - c[j]) - d.begin();
            count += lower_bound(d.begin(), d.end(), (1LL << (i + 2)) - c[j]) - d.begin();
            count -= lower_bound(d.begin(), d.end(), (1LL << (i + 1)) + (1LL << (i)) - c[j]) - d.begin();
        }
        if (count % 2 == 1)
            ret += 1LL << i;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 6656
#include "bits/stdc++.h"
using namespace std;
using ll=long long;

vector<bool> prime_table(int n){
	if(n==1) return vector<bool>(n+1,0);
	vector<bool> table(n+1,1);
	table[0]=table[1]=0;
	table[2]=1;
	for(int i=2;i*i<=n;++i){
		if(!table[i]) continue;
		for(int j=2;i*j<=n;++j) table[i*j]=0;
	}
	return table;
}

int insertionSort(vector<ll> &A,int n,int g){
	int cnt=0;
	for(int i=g;i<n;++i){
		int j=i-g;
		while(j>=0&&A[j]>A[j+g]){
			swap(A[j],A[j+g]);
			j-=g;
			cnt++;
		}
	}
	return cnt;
}

void shellSort(vector<ll> &A,int n){
	int cnt=0;
	auto table=prime_table(n-1);
	vector<int> G={1};
	for(int i=2;i<=n;++i) if(table[i]&&G.size()<100) G.emplace_back(i);
	reverse(G.begin(),G.end());
	cout<<G.size()<<endl;
	for(int i=0;i<G.size();++i){
		if(i==0) cout<<G[i];
		else cout<<" "<<G[i];
	}
	puts("");
	for(int i=0;i<G.size();++i){
		cnt+=insertionSort(A,n,G[i]);
	}
	cout<<cnt<<endl;
	for(int i=0;i<n;++i) cout<<A[i]<<endl;
}

int main(){
	int n;
	cin>>n;
	vector<ll> A(n);
	for(int i=0;i<n;++i) cin>>A[i];
	
	shellSort(A,n);
}
			



Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, a, b, ab, ba;
  a = b = ab = ba = 0;
  cin >> N;
  VEC<string> S(N);
  int ans = 0;
  REP(i, 0, N) {
    cin >> S[i];
    string s = S[i];
    int m = s.length();
    if (s[0] == 'B' && s[m - 1] == 'A')
      ba++;
    else if (s[m - 1] == 'A')
      ++a;
    else if (s[0] == 'B')
      ++b;

    REP(j, 1, m) {
      if (s[j - 1] == 'A' && s[j] == 'B') ans++;
    }
  }
  if (ba > 0) {
    ans += ba - 1;
    if (a > 0) {
      ans++;
      a--;
    }
    if (b > 0) {
      ans++;
      b--;
    }
  }
//   DUMP(ans);
  ans += min(a, b) > 0 ? min(a, b) : 0;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
#define out(a) printf("%d",a)
using namespace std;
int n,k,now,x,cnt;
int minn,a,b,ans;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); k=read(); minn=ans=2333333;
	for (int i=1;i<=n;i++) {
	  x=read();
	  if (x<minn) minn=x,now=i;
    }
    for (int i=1;i<=k;i++){
      a=now-i; b=n-(now+k-i); cnt=0;
      //out(a); cout<<' '; out(b); printf("\n");
      if (a>0) {
        cnt+=a/(k-1);
        if (a%(k-1)!=0) cnt++;
      }
      if (b>0) {
      	cnt+=b/(k-1);
      	if (b%(k-1)!=0) cnt++;
      }
      cnt++;
      ans=min(ans,cnt);
    }
    out(ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i,j,k,s = 0,N,minj,*p;
  scanf("%d",&N);
  if(N < 1 || N > 100)exit(1);
  
  p = malloc(N * sizeof(int));

  for(i=0;i < N;i++){
    scanf("%d",&p[i]);
    if(p[i] < 0 || p[i] > 100)exit(2);
  }
  for(i = 0;i < N;i++){
    minj = i;
    for(j = i;j < N;j++){
      if(p[j] < p[minj])minj = j;
    }
    if(minj != i){
      k = p[i];
      p[i] = p[minj];
      p[minj] = k;
      s++;
    }
  }
  for(i=0;i < N;i++){
    if(i != N-1)printf("%d ",p[i]);
    else printf("%d\n",p[i]);
  }
  printf("%d\n",s);
  return 0;
    
  }



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

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

Comb = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            Comb.append(A[i] + B[j] + C[k])

Comb.sort(reverse=True)
for i in range(K):
    print(Comb[i])


Measured memory_bytes: 8724
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int solve(int n, string s, string t) {
    rep(p, n){
        bool f = true;
        rep(i,n - p){
            if(s[i + p] != t[i]) f = false;
        }
        if(f) return p;
    }
    return n;
}

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    int p = solve(n, s, t);

    cout << t.size() + p << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long R,C,K;
    cin >> R >> C >> K;
    vector<long>r(K);
    vector<long>c(K);
    vector<long>v(K);
    vector<vector<long> >mapp(R+1,vector<long>(C+1,-1));
    for(long i=0;i<K;i++){
        cin >> r[i]>>c[i]>>v[i];
        mapp[r[i]][c[i]] = v[i];
    }
    vector<vector<bool> >went(R+1,vector<bool>(C+1,false));
    vector<vector<vector<long> > >dp(R+1,vector<vector<long> >(C+1,vector<long>(4,-1<<30)));
    queue<pair<long,long> >que;
    dp[1][1][0] = 0;
    que.push(make_pair(1,1));
    while(!que.empty()){
        long x = que.front().first;
        long y = que.front().second;
        que.pop();
        if(went[x][y])continue;
        went[x][y] = true;
        
        if(mapp[x][y] != -1){
            for(long i=2;i>=0;i--){
                dp[x][y][i+1] = max(dp[x][y][i+1],dp[x][y][i] + mapp[x][y]);
            }
        }

        if(x < R){
            dp[x+1][y][0] = max(dp[x+1][y][0],max(dp[x][y][0],max(dp[x][y][1],max(dp[x][y][2],dp[x][y][3]))));
            que.push(make_pair(x+1,y));
        }
        
        if(y < C){
            for(long i=3;i>=0;i--){
                dp[x][y+1][i] = max(dp[x][y+1][i],dp[x][y][i]);
            }
            que.push(make_pair(x,y+1));
        }
    }
    long ans = 0;
    for(long i=0;i<=3;i++){
        ans = max(ans,dp[R][C][i]);
    }
    cout << ans << endl;
    
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

bool isok(i64 n, i64 x) {
    while (n % x == 0) n /= x;
    return n % x == 1;
}

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

    i32 ans = n > 2 ? 2 : 1;
    for (i64 i = 2, lim = sqrt(n); i <= lim; i++) {
        if (n % i != 0) continue;
        if (isok(n, i)) ans++;
        if (n / i == i) continue;
        if (isok(n, n / i)) ans++;
    }

    n--;
    for (i64 i = 2, lim = sqrt(n); i <= lim; i++) {
        if (n % i != 0) continue;
        ans++;
        if (n / i == i) continue;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a,b = 0;
  scanf("%d %d",&a,&b);
  if(a>b){
    printf("a > b\n");
  }
  else if(a<b){
    printf("a < b\n");
  }
  else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
def main():
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()
    ans = 0

    for i in range(k):
        t2 = t[i::k]
        l = len(t2)
        dp = [0, 0, 0]
        for j in range(l):
            if t2[j] == "r":
                dp = [max(dp[1], dp[2]), max(dp[0], dp[2]),
                      max(dp[0]+p, dp[1]+p)]
            elif t2[j] == "s":
                dp = [max(dp[1]+r, dp[2]+r), max(dp[0], dp[2]),
                      max(dp[0], dp[1])]
            else:
                dp = [max(dp[1], dp[2]), max(dp[0]+s, dp[2]+s),
                      max(dp[0], dp[1])]
        ans += max(dp)
    print(ans)


main()


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 2005
#define MAXM 2005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

string ans = "";
int sx, sy, tx, ty;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
string dirc = "RULD";

bool flag[MAXN][MAXM] = {};
int dist[MAXN][MAXM], dist_rev[MAXN][MAXM];

void solve(){
    rep(i, tx - sx) ans += 'R';
    rep(i, ty - sy) ans += 'U';

    rep(i, tx - sx) ans += 'L';
    rep(i, ty - sy) ans += 'D';

    ans += 'L';

    rep(i, 1+ty - sy) ans += 'U';
    rep(i, 1+tx - sx) ans += 'R';

    ans += "DR";

    rep(i, 1+ty - sy) ans += 'D';
    rep(i, 1+tx - sx) ans += 'L';

    ans += 'U';

    cout << ans << endl;
}

int main(){
    cin >> sx >> sy >> tx >> ty;

    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 1010;

int a[55][55];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	rep(i, n) {
		string s; cin >> s;
		rep(j, s.size()) {
			a[i][s.at(j) - 'a']++;
		}
	}
	rep(i, 26) {
		int sum = INF;
		rep(j, n) {
			chmin(sum, a[j][i]);
		}
		rep(j, sum) {
			cout << (char)(i + 'a');
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	while(1){
		int ans=0,n;
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			int x,y,h,w;
			cin >> x >> y >> h >> w;
			int s=x+y+h;
			if(s<=60 && w<=2)ans+=600;
			else if(s<=80 && w<=5)ans+=800;
			else if(s<=100 && w<=10)ans+=1000;
			else if(s<=120 && w<=15)ans+=1200;
			else if(s<=140 && w<=20)ans+=1400;
			else if(s<=160 && w<=25)ans+=1600;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
def bubble(c, n)
  c_dup = Marshal.load(Marshal.dump(c))
  for i in 0..n-2
    for j in 0..(n-i-2)
      if c_dup[j].split(//)[1] > c_dup[j+1].split(//)[1]
        c_dup[j], c_dup[j+1] = c_dup[j+1], c_dup[j]
      end
    end
  end
  return c_dup
end

def selection(c, n)
  c_dup = Marshal.load(Marshal.dump(c))
  for i in 0..n-2
    minj = i
    for j in (i+1)..n-1
      if c_dup[j].split(//)[1] < c_dup[minj].split(//)[1]
        minj = j
      end
    end
    c_dup[i], c_dup[minj] = c_dup[minj], c_dup[i]
  end
  return c_dup
end

def is_Stable(c1, c2, n)
  for i in 0..n-2
    if c2[i].split(//)[1] == c2[i+1].split(//)[1] && c2[i] != c1[i]
      return false
    end
  end
  return true
end

n = gets.to_i
c = gets.chomp.split()


c1 = bubble(c, n)
c2 = selection(c, n)

puts c1.join(' ')
puts "Stable"
puts c2.join(' ')
is_Stable(c1, c2, n) ? puts("Stable") : puts("Not stable")



Measured memory_bytes: 7072
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e9 + 7);

const ll tam = 100010;

vector<ll> G[tam];
ll val[tam];
bool vis[tam];

ll sum;
void dfs(ll v)
{
	//cout << "(" << v << "," << val[v] << ") ";
	sum += (val[v] + 26);
	sum %= 26;
	vis[v] = true;
	for (ll u : G[v])
	{
		if ( vis[u] ) continue;
		dfs(u);
	}
}

ii E[tam];

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    string s;
    cin >> s;
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
    {
    	cin >> E[i].F >> E[i].S;
    }
    if (s.size() == 1)
    {
    	cout << "YES" << '\n';
    	return 0;
    }
    s = "a" + s + "a";

    //cout << s << endl;
	for (ll i = 0; i < s.size()-1; i++)
    {
    	val[i] = (s[i+1] - s[i] + 26) % 26;
    	//cout << "(" << val[i] << "[" << i << "," << i+1 << "]) ";
    }
    //cout << endl;

    for (ll i = 0; i < n; i++)
    {
    	//val[ E[i].F-1 ] = (val[ E[i].F-1 ] + 1) % 26;
    	//val[ E[i].S ] = (val[ E[i].S ] - 1 + 26) % 26;
    	G[E[i].F-1].pb( E[i].S );
    	G[ E[i].S ].pb(E[i].F-1);
    }
    /*
    for (ll i = 0; i < s.size()-1; i++)
    {
    	cout << "(" << val[i] << "[" << i << "," << i+1 << "]) ";
    }
    cout << endl;
    */
    for (ll i = 0; i < s.size()-1; i++)
    {
    	G[i].pb( s.size()-2-i );
    }
    clr(vis, false);
    bool poss = true;
    for (ll i = 0; i < s.size()-1; i++)
    {
    	if (vis[i]) continue;
    	//cout << "component: " << endl;
    	sum = 0;
    	dfs(i);
    	//cout << endl << "===============" << endl;
    	if (sum != 0) poss = false;
    }
    if (poss) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}
// PLUS ULTRA!!!!

Measured memory_bytes: 11500
// B - ROT N
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; string S; cin>>N>>S;
	rp(i, 0, S.size()) putchar((S[i]-'A'+N)%26+'A'); puts("");
}

Measured memory_bytes: 256
H, W, A, B = map(int, input().split())

Ans = [['0'] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if i < B and j < A:
            Ans[i][j] = 1
        if i >= B and j >= A:
            Ans[i][j] = 1
        print(Ans[i][j], end='')
    print()

Measured memory_bytes: 121560
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

S = s()

A = S.find('A')
for i in range(len(S)):
    if S[-i-1] == 'Z':
        print(len(S) - i - A)
        import sys
        sys.exit()


Measured memory_bytes: 3516
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll x; cin >> x;
  vector<ll> A;
  loop(i,0,200) {
    ll f = i;
    ll y = 1;
    loop(j,0,5) y*=f;
    if (y > 500000000000) break;
    A.push_back(y);
  }
  
  int n = A.size();
  vector<ll> signs { -1, 1 };
  loop(i,0,n) {
    loop(j,0,n) {
      for (auto &&signA: signs) {
        for (auto &&signB: signs) {
          if (signA*A[i]-A[j]*signB == x) {
            cout << signA*i << " " << signB*j << endl;
            return 0;
          }
        }
      }
    }
  }
  assert(x == 0);
  return 0;
}


Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val anagramMap = mutableMapOf<Map<Char, Int>, Int>()

    // アナグラムを求める
//    // TLE 単純に辞書を使うだけではだめ？？
//    for ( i in 0 until n) {
//        val charMap = mutableMapOf<Char, Int>()
//        val text = readLine()!!
//        for ( c in text) {
//            charMap[c] = if(charMap[c] == null) 1 else charMap[c]!! + 1
//        }
//
//        anagramMap[charMap] = if(anagramMap[charMap] == null) 1 else anagramMap[charMap]!! + 1
//    }
//
//    var sum = 0L
//    for ( v in anagramMap.values) {
//        if ( v >=2 ) {
//            sum += v.toLong() * (v.toLong() - 1) / 2
//        }
//    }
//
//    println(sum)

    // ソートを検討

    val sMap = mutableMapOf<String, Int>()
    for ( i in 0 until n) {
        val text = readLine()!!.toList().sorted().joinToString()
        sMap[text] = if(sMap[text] == null) 1 else sMap[text]!! + 1
    }

    var sum = 0L
    for ( v in sMap.values) {
        if ( v >=2 ) {
            sum += v.toLong() * (v.toLong() - 1) / 2
        }
    }

    println(sum)

}

Measured memory_bytes: 83100
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    for(i=0; i<H; i++){
      for(j=0; j<W; j++){
    printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>

using namespace std;

int main(){
	int n;

	cin >> n;

	switch (n) {
	case 1:
		cout << "Hello World" << endl;
		break;
	case 2:
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
		break;
	}
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n:usize,
      s:[Bytes; n]
   }
   let mut count = vec![0usize; 4];
   for s in s {
      if s == b"AC" {
         count[0] += 1;
      } else if s == b"WA" {
         count[1] += 1;
      } else if s == b"TLE" {
         count[2] += 1;
      } else if s == b"RE" {
         count[3] += 1;
      }
   }
   println!("AC x {}", count[0]);
   println!("WA x {}", count[1]);
   println!("TLE x {}", count[2]);
   println!("RE x {}", count[3]);
}


Measured memory_bytes: 7796
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var x = sc.nextLong();
		var k = sc.nextLong();
		var d = sc.nextLong();
		sc.close();
 
		var result = 0L;
		x = Math.abs(x);
		if (k < x / d) {
			result = x - k * d;
		} else if ((k - (x / d)) % 2 == 0) {
			result = Math.abs(x - d * (x / d));
		} else {
			result = Math.abs(x - d * ((x / d) + 1));
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 35748
#include <iostream>
const int INF=1e9;
using namespace std;
int main(){
  int d[100][100],n,p;
  cin>>n;
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) d[i][j]=INF;
  for(int i=0,r,k,t;i<n&&cin>>r>>k;i++) for(int j=0;j<k&&cin>>t;j++) d[r-1][t-1]=1;
  for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) d[i][j]++;
  cin>>p;
  for(int i=0,s,t,v;i<p;i++){
    cin>>s>>t>>v;
    if(d[s-1][t-1]>v) cout<<"NA"<<endl;
    else cout<<d[s-1][t-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3132
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>


using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 49999;

ll n, k;
ll res;
ll m[200007];
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/

	cin >> n >> k;
	forn(i, 1, n+1)
	{
		m[i%k]++;
	}
	forn(i, 0, k)
	{
		ll a = m[i];
		if ((i + i) % k == 0)
			res += a*a*a;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 1024
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
use std::collections::HashSet;
fn main() {
    let n: usize = read();
    let mut s: HashSet<String> = HashSet::new();
    for i in 0..n {
        let _s: String = read();
        s.insert(_s);
    }
    println!("{}", s.len());
}


Measured memory_bytes: 15260
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
    	int data[];
        int n,m;
        void min_update(int i,int x){
            i += n - 1;
            data[i] = x;
            while(i > 0){
                i = (i - 1)/2;
                data[i] = Math.min(data[i*2+1],data[i*2+2]);
            }
        }
        void sum_update(int i,int x){
            i += n - 1;
            data[i] += x;
            while(i > 0){
                i = (i - 1)/2;
                data[i] += x;
            }
        }
        int query(int a,int b,int k,int l,int r){
            if(r <= a || b <= l)return 0;
            if(a <= l && r <= b)return data[k];
            else{
                int vl = query(a,b,k*2+1,l,(l+r)/2);
                int vr = query(a,b,k*2+2,(l+r)/2,r);
                return vl + vr;
            }
        }
        void doIt(){
            int num = sc.nextInt();
            m = sc.nextInt();
            n = 1;
            while(n < num)n <<= 1;
//          System.out.println(n);
            data = new int [n*2];
            //????°???????
//            Arrays.fill(data,Integer.MAX_VALUE);
            for(int i = 0;i < m;i++){
                int com = sc.nextInt();
                int x = sc.nextInt()-1;
                int y = sc.nextInt();
                if(com == 0)sum_update(x,y);
                else System.out.println(query(x,y,0,0,n));
//                for(int j = 0;j < n*2 - 1;j++){
//                	System.out.print(data[j]+" ");
//                }
//                System.out.println();
            }
    	}
    }
}

Measured memory_bytes: 103540
n,m=gets.split.map(&:to_i)
a=[]
n.times{a<<gets.split.map(&:to_i)}
b=[]
m.times{b<<gets.split.map(&:to_i)}
a.each do |x,y|
  puts b.each_with_index.min_by{|(z,w),i| [[z-x,w-y].map(&:abs).inject(&:+),i]}[1]+1
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int n,ans=0;
    cin>>n;
    string s;
    rep(i,n){
        cin>>s;
        ans+=(s=="A"?1:-1);
        if(ans<0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<(ans==0 ? "YES" : "NO")<<endl;
}

Measured memory_bytes: 3160
program answer
  implicit none

  integer :: A1, A2, A3, i, cost1, cost2, cost3

  read(*,*) A1, A2, A3

  if(A3<A2) then
     cost1=abs(A3-A1)+abs(A2-A3)
  else
     cost1=abs(A2-A1)+abs(A2-A3)
  end if

  if(A1<A3) then
     cost2=abs(A1-A2)+abs(A1-A3)
  else
     cost2=abs(A3-A2)+abs(A3-A1)
  end if

  if(A1<A2) then
     cost3=abs(A1-A3)+abs(A1-A2)
  else
     cost3=abs(A2-A3)+abs(A2-A1)
  end if

  write(*,*) min(cost1,cost2,cost3)

  stop
 end program answer

Measured memory_bytes: 2860
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double a,b,x;
  cin>>a>>b>>x;
  double S=x/a;
  double ans=0;
  double PI=acos(-1);
  double rad;
  if (S>a*b/2){
    double h=(a*b-S)*2/a;
    rad=atan2(h,a);    
  } else{
    double w=2*S/b;
    rad=atan2(b,w);
  }
  ans=rad*180/PI;
  printf("%.10f\n",ans);
  return 0;
}

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

typedef long long ll;

const int INF = 10000000;
const int MAX_V = 210;
const int MAX_R = 1010;
int dl[MAX_V][MAX_V];
int ds[MAX_V][MAX_V];
int n, m, r;
int x, y, t;
char type[3];

int order[MAX_R];
int dp[MAX_R][MAX_V];



int main() {
    while(scanf("%d%d", &n, &m) != EOF && n) {
        for(int i = 0; i < MAX_V; i++) {
            fill(dl[i], dl[i] + MAX_V, INF);
            fill(ds[i], ds[i] + MAX_V, INF);
        }
        for(int i = 0; i < m; i++) {
            scanf("%d%d%d%s", &x, &y, &t, type);
            if(type[0] == 'L') {
                dl[x][y] = min(dl[x][y], t);
                dl[y][x] = min(dl[y][x], t);
            } else {
                ds[x][y] = min(ds[x][y], t);
                ds[y][x] = min(ds[y][x], t);
            }
        }

        for(int i = 1; i <= n; i++) {
            ds[i][i] = 0;
            dl[i][i] = 0;
        }

        for(int k = 1; k <= n; k++) {
            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= n; j++) {
                    dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
                    ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
                }
            }
        }

        scanf("%d", &r);
        for(int i = 1; i <= r; i++) {
            scanf("%d", &order[i]);
        }
        
        for(int i = 0; i < MAX_R; i++) {
            fill(dp[i], dp[i] + MAX_V, INF);
        }
        
        for(int i = 1; i <= n; i++) {
            dp[1][i] = ds[order[1]][i] + dl[i][order[1]];
        }
        for(int i = 2; i <= r; i++) {
            for(int j = 1; j <= n; j++) {
                if(dl[order[i]][j] == INF) continue;
                for(int k = 1; k <= n; k++) {
                    if(j == k) {
                        if(dl[order[i-1]][order[i]] == INF) continue;
                        dp[i][j] = min(dp[i][j], dp[i-1][k] + dl[order[i-1]][order[i]]);
                    }
                    else {
                        if(dl[order[i-1]][k] == INF || ds[k][j] == INF || dl[j][order[i]] == INF) continue;
                        dp[i][j] = min(dp[i][j], dp[i-1][k] + dl[order[i-1]][k] + ds[k][j] + dl[j][order[i]]);
                    }
                }
            }
        }
        int ans = INF;
        for(int i = 1; i <= n; i++) {
            ans = min(ans, dp[r][i]);
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 4392
import java.util.Scanner;


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

        int H = 0;
        int W = 0;

        while (true) {
            H = sc.nextInt();
            W = sc.nextInt();

            if (H == 0 && W == 0) break;

            for (int i=0; i<H; ++i) {
                for (int j=0; j<W; ++j) {
                    if (i == 0 || j == 0) System.out.print('#');
                    else if (i == H-1 || j == W-1) System.out.print('#');
                    else System.out.print('.');
                }
                System.out.print('\n');
            }

            System.out.print('\n');
        }
    }
}


Measured memory_bytes: 38716
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    int N;
    cin >> N;
    vi a(N);
    map<int, int> mp;
    rep(i, N) {
        cin >> a[i];
        mp[a[i]] = 0;
    }

    {
        int i = 0;
        for (auto& p : mp) {
            p.second = i++;
        }
    }

    rep(i, N) {
        a[i] = mp[a[i]];
    }

    int ans = 0;
    rep(i, N) {
        if (a[i] % 2 != i % 2) {
            ans++;
        }
    }
    cout << ans / 2 << endl;

}


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

int main() {
    string s, p;
    cin >> s >> p;
    bool can;
    for (int i = 0; i < s.size(); ++i) {
        can = false;
        for (int j = 0; j < p.size(); ++j) {
            if (s[(i + j) % s.size()] != p[j]) {
                break;
            }
            if (j == p.size() - 1) {
                can = true;
            }
        }
        if (can) {
            break;
        }
    }
    if (can) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int gcd(int x, int y) {
    if(x<y) swap(x,y);
    if (y == 0) return x;
    return gcd(y, x%y);
}

int main(){
    int K;
    ll ans = 0;
    cin >> K;
    FOR(a,1,K+1){
        FOR(b,1,K+1){
            FOR(c,1,K+1){
                ans += gcd(a,gcd(b,c));
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
	cin>>n>>m;
	if(!(n%3)||!(m%3)||!((n+m)%3))
	  {cout<<"Possible"<<endl;return 0;}
	cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N,K;
int mark[MAXN];

void work(){
    scanf("%d%d",&N,&K);
    for(int i=1;i<=K;i++){
        int x; scanf("%d",&x);
        while(x--){
            int y; scanf("%d",&y);
            mark[y]=true;
        }
    }
    int ans=0;
    for(int i=1;i<=N;i++)if(!mark[i]) ans++;
    printf("%d\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}









Measured memory_bytes: 3844
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod

int main(){
	ll m;
	cin>>m;
	ll keta=0,wa=0;
	rep(i,m){
		ll d,c;
		cin>>d>>c;
		keta+=c;
		wa+=d*c;
	}
	cout<<keta-1+(wa-1)/9<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int ans=0,min,mid,max,i,n,q,s[101010],t[50010];
scanf("%d\n",&n);
for(i=0;i<n;i++){
scanf("%d",&s[i]);
}
s[i]=1000000010;
scanf("\n%d\n",&q);
for(i=0;i<q;i++){
scanf("%d",&t[i]);
}
for(i=0;i<q;i++){
min=0,max=n;
while(min<max){
mid=(min+max)/2;
if(s[mid]==t[i]){
ans++;
break;
}
else if(s[mid]<t[i]){
min=mid+1;
}
else{
max=mid;
}
}
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2268
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("1"),0;
#define mod 1000000007
//#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,a,b,num[100],k;
int g(int a,int b,int c,int d){
	if (b<c) return (b-a+1)+(d-c+1);
	else return (d-a+1);
}
signed main(){
	a=read();b=read();
	if (a==b) ret;
	num[0]=1;
	F(i,1,60) num[i]=num[i-1]*2;
	D(i,59,0){
		if ((a^b)&num[i]){
			a=a%num[i+1];b=b%num[i+1];k=i;break;
		}
	}
	int p=-1;
	D(i,k-1,0){
		if (b&num[i]){
			p=i;break;
		}
	}
	wrn(g(a,num[p+1]+num[k]-1,a+num[k],num[k+1]-1));
	return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
H = list(map(int, sys.stdin.buffer.readline().split()))

cummax = list(itertools.accumulate(H, max))
H = np.array(H, dtype=int)
cummax = np.array(cummax, dtype=int)
ans = np.count_nonzero(H >= cummax)
print(ans)


Measured memory_bytes: 14028
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<int> num;
  
  UnionFind(int N) : par(N),rank(N),num(N) {
        for(int i = 0; i < N; i++){ 
          par[i] = i;
          rank[i] = 0;
          num[i] = 1;
        }
   }
      
  void init(int N){
        for(int i = 0; i < N; i++){ 
          par[i] = i;
          rank[i] = 0;
          num[i] = 1;
        }
  }
  
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  
  int ranker(int x){
    x = root(x);
    return rank[x];
  }
  
  int number(int x){
    x = root(x);
    return num[x];
   }
  
  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if ( rx == ry ) return;
    if ( rank[rx] < rank[ry] ){
      par[rx] = ry;
      num[ry] += num[rx];
      num[rx] = 0;
    } else {
      par[ry] = rx;
      num[rx] += num[ry];
      num[ry] = 0;
      if ( rank[rx] == rank[ry] ) rank[rx]++;
    }
   }
  
  bool same(int x, int y){
    return root(x) == root(y);
  }
};

int N,K,L;

int main(){
    cin >> N >> K >> L;
    UnionFind road(N),train(N);
    rep(i,K){
        int p,q;
        cin >> p >> q;
        p--,q--;
        road.unite(p,q);
    }
    rep(i,L){
        int p,q;
        cin >> p >> q;
        p--,q--;
        train.unite(p,q);
    }
    
    map<P,int> ans;
    
    rep(i,N) ans[mp(road.root(i),train.root(i))]++;
    
    rep(i,N) cout << ans[mp(road.root(i),train.root(i))] << " ";
    
    
}

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

int main(){
    int a,b;
    char op;
    
    while (1){
        cin >> a >> op >> b;
        if (op == '?') break;
        if ( op == '+' ){cout << a + b << endl;
        }else if ( op == '-' ){cout << a - b << endl;
        }else if ( op == '*' ){cout << a * b << endl;
        }else if ( op == '/' ){cout << a / b << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
(n,k) = tuple(map(int,input().split()))

if n == k:
    print(0)
if n < k:
    if n <= k-n:
        print(n)
    if n > k-n:
        print(k-n)
if n > k:
    n2 = n%k
    print(min(n2,abs(n2-k)))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
bool issubseq(string S, string T){
  T += '#';
  int p = 0;
  int N = S.size();
  for (int i = 0; i < N; i++){
    if (S[i] == T[p]){
      p++;
    }
  }
  return p + 1 == T.size();
}
int main(){
  string S;
  cin >> S;
  string T;
  cin >> T;
  int N = S.size();
  string s1, s2;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      s1 += S[i];
    }
    if (i % 2 == 1){
      s2 += S[i];
    }
  }
  if (issubseq(T, s1) || issubseq(T, s2)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
  string O, E; cin >> O >> E;
  int on = O.size(), en = E.size();
  for(int i = 0; i < on; i++){
    cout << O[i];
    if(i < en) cout << E[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256