akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;
const int NAX = 2e5;

vector<int> dp;
vector<int> G[NAX];
int a[NAX], ans[NAX];
int n;
stack<pair<int,int>> st;

void dfs(int o, int k){
    int itr = lower_bound(all(dp),a[k]) - dp.begin();
    st.push({itr,dp[itr]});
    dp[itr] = a[k];
    int ansp = lower_bound(all(dp),INF) - dp.begin();
    ans[k] = ansp;
    for(auto v:G[k]){
        if(v == o) continue;
        dfs(k, v);
    }
    int x = st.top().first, y = st.top().second; st.pop();
    dp[x] = y;
}

signed main(){
    cin >> n;
    dp.resize(n,INF);
    REP(i,n) cin >> a[i];
    REP(i,n-1){
        int u, v; cin >> u >> v; u--; v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(-1,0);
    REP(i,n) cout << ans[i] << '\n';
}

Measured memory_bytes: 39172
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
    int i, n, q, count = 0;
    int mid, right, left;
    int s[100001], t[50001];

    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &s[i]);
    }

    scanf("%d", &q);
    for(i = 0; i < n; i++) {
        scanf("%d", &t[i]);
    }


    for(i = 0; i<q; i++){

        right = n;
        left = 0;

        while(left <= right){

            mid = (right + left) / 2;
            if(s[mid] == t[i]) {
                count++;
                break;
            }
            else if(s[mid] < t[i]){
                left = mid + 1;
            }
            else if(s[mid] > t[i]){
                right = mid - 1;
            }

        }
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<string> s(n);
  cout << 0 << endl;
  cin >> s[0];
  if(s[0]=="Vacant"){
    return 0;
  }
  int l=0,r=n;
  while(1){
    int mid=(l+r)/2;
    cout << mid << endl;
    cin >> s[mid];
    if(s[mid]=="Vacant"){
      return 0;
    }
    if((s[l]==s[mid])^((mid-l)%2==0)){
      r=mid;
    }
    else{
      l=mid;
    }
  }
}

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

long long dp[55][55][2505], N,A,x[55],ans;

int main()
{
    cin >> N >> A;
    for(int i = 1; i <= N; i++) cin >> x[i];
    for(int pref = 1; pref <= N; pref++)
    {
        for(int total = 1; total <= A*N; total++)
        {
            dp[1][pref][total] = dp[1][pref-1][total] + (x[pref] == total);
        }
    }
    for(int parts = 2; parts <= N; parts++)
    {
        for(int pref = 1; pref <= N; pref++)
        {
            for(int total = 1; total <= A*N; total++)
            {
                dp[parts][pref][total] = dp[parts][pref-1][total] + dp[parts-1][pref-1][max(0LL,total-x[pref])];
            }
        }
    }
    for(int parts = 1; parts <= N; parts++) ans += dp[parts][N][parts*A];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 54400
#include <iostream>
#include <cstdio>

using namespace std;
#define MAX 5000000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2 +2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0; i < n1; i++)
    {
        L[i] = A[left + i];
    }
    for(int i = 0; i < n2; i++)
    {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j =0;
    for(int k = left; k < right; k++)
    {
        cnt++;
        if(L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right)
{
    if (left+1 < right)
    {
        int mid = (left + right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);

    }
}

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

    mergeSort(A, n, 0, n);

    for(i = 0; i < n; i++)
    {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}



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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    long long H, W;

    ist >> H >> W;

    /* ------- 計算 ------- */

    long long ans;

    if (H % 2 == 0 && W % 2 == 0)
    {
        ans = H * W / 2;
    }
    else if (H % 2 == 1 && W % 2 == 0)
    {
        ans = (H - 1) * W / 2 + W / 2;
    }
    else if (H % 2 == 0 && W % 2 == 1)
    {
        ans = H * (W - 1) / 2 + H / 2;
    }
    else
    {
        ans = (H - 1) / 2 * (W - 1) + (H - 1) / 2 + (W - 1) / 2 + 1;
    }

    if (H == 1 || W == 1)
    {
        ans = 1;
    }

    ost << ans << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


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

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i * 108 / 100 == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


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

  cin >> S;
  
if(S[2] == S[3] && S[4] == S[5]){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
  
  return 0;
 }

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];

  sort(all(d));

  if (d[N/2 - 1] == d[N/2]) {
    cout << 0 << endl;
  } else {
    cout << d[N/2] - d[N/2 - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

bool good(char c){return c=='a' || c=='i' || c=='u' || c=='e' || c=='o';}

bool culclate(){
  ll N;
  cin>>N;
  if(N==0){return false;}
  vector<string> A(N);
  cin>>A;
  for(auto &I:A){
    string tmp={I[0]};
    int sz=I.size();
    for(int i=0;i<sz;i++){
      if(i+1<sz && good(I[i])){tmp.push_back(I[i+1]);}
    }
    I=tmp;
  }
  sort(A.begin(),A.end());
  ll ans=0;
  bool ok=true;
  for(int i=0;i+1<N;i++){
    int mi=min(A[i].size(),A[i+1].size());
    int mx=max(A[i].size(),A[i+1].size());
    for(int j=0;j<mi;j++){
      if(A[i][j]!=A[i+1][j]){ans=max(ans,j+1LL); break;}
      if(j+1==mx){ok=false;}
      if(j+1==mi){ans=max(ans,j+2LL);}
    }
  }
  if(!ok){ans=-1;}
  cout<<ans<<endl;
  return true;
}

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


  return 0;
}



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

int main() {

long double a,b,c,d;

cin >> a >> b >> c >> d;

long double di;

di=sqrt((a-c)*(a-c)+(b-d)*(b-d));

cout << fixed << setprecision(15) << di << endl;

}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

int main()
{
    int N, M;
    cin >> N >> M;

    int p = 0;

    // スイッチがどの電球と接続しているかをbitで持つ
    vector<int> connect(N);

    rep(i, 0, M)
    {
        int k;
        cin >> k;

        rep(j, 0, k)
        {
            int s;
            cin >> s;
            --s; // 0から数えた方が処理書きやすいので
            connect[s] |= (1 << i);
        }
    }

    rep(i, 0, M)
    {
        int x;
        cin >> x;
        p |= (x << i);
    }

    int ans = 0;

    // 全通りのスイッチのon/offのパターンを調べる
    rep(i, 0, (1 << N))
    {
        // 電球のon/offをbitで表現
        int t = 0;
        rep(j, 0, N)
        {
            if ((i >> j) & 1)
            {
                t ^= connect[j];
            }
        }
        // tのbitが1の時、スイッチは奇数個
        // tのbitが0の時、スイッチは偶数個
        // tにはスイッチ数で割った結果がこの段階で入っている
        // なのでpとそのまま比較することで、結果の検討ができる
        if (t == p)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <map>

int N;
std::map<long long,int,std::greater<long long>> cnt;
int main(){
  std::cin>>N;
  for(int i=0;i<N;++i){
    long long temp;
    std::cin>>temp;
    ++cnt[temp];
  }
  int check=0;
  long long ans=1;
  for(auto&& Map:cnt)
    if(check>1)
      break;
  	else if(Map.second>1){
      ans*=Map.first;
      ++check;
      if(Map.second>3&&check<2){
        ans*=Map.first;
        ++check;
      }
    }
  
  if(check>1)
    std::cout<<ans<<std::endl;
  else
    std::cout<<"0"<<std::endl;
  
  return 0;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cerr << x[i] << " ";
        }
        cerr << x[x.size()-1] <<endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}
 
int main(void) {
    double a, b, x;
    cin >> a >> b >> x;

    double thresh = a * a * b / 2;
    if(x < thresh) {
        double theta = atan((a * b * b)/ (2 * x));
        cout << setprecision(9) << theta * 180.0 / PI << endl;
    }
    else {
        double theta = atan(2.0 / a / a * (a * b - x / a));
        cout << setprecision(9) << theta * 180.0 / PI << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int ante[5];
    int dis=0;
    int flg=1;
    int i,l,m;
    for(i=0;i<5;i++){
        scanf("%d",&ante[i]);
    }
    scanf("%d",&dis);
    for(l=0;l<5;l++){
        for(m=4;m>l;m--){
            if((ante[m]-ante[l])>dis){
                flg=0;
            }
        }
    }
    if(flg==1){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>


int main()
{
	int A, B,C,D, P;
	int X, Y;

	scanf("%d%d%d%d%d", &A, &B, &C, &D, &P);

	X = A * P;
	if(P <= C){
		Y = B;
	} else {
		Y = B + (P-C) * D;
	}

	if(X < Y)
		printf("%d\n", X);
	else
		printf("%d\n", Y);

	return 0;
}

Measured memory_bytes: 596
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
int N;
cin >> N;
vector<long long> a(N);
for(int i = 0;i<N;i++)cin >> a[i];
for(int i = 1; i<N+1;i++){
	a[i-1] = a[i-1]-i;
	
}
long long M;
sort(a.begin(),a.end());
M = a[N/2];
long long ans = 0;
for(int i= 0;i<N;i++){
	ans+=abs(a[i]-M);
}
cout << ans << endl;
}



Measured memory_bytes: 1792
#include <iostream>

int main(){
	int value;
	int loopvalue;
	bool ischeck = true;
	std::cin >> loopvalue;
	for(int i=0;i<loopvalue;i++) {
		std::cin >> value;
		if(0 == value % 2){
			if(value % 3 == 0 || value % 5 == 0) {
				continue;
			}
			ischeck = false;
		}
	}
	if(ischeck) {
		std::cout << "APPROVED" << std::endl;
	} else{
		std::cout << "DENIED" << std::endl;
	}
	
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
def fnSolv():
  iNum = int(input())
  lHn  = list(map(int, input().split()))
  lDP  = [0 , abs(lHn[1] - lHn[0])]
  for iI in range(2,iNum):
    iDP0 = lDP[0]
    iDP1 = lDP[1]
    lDP[0] = iDP1
    lDP[1] = min( [iDP0 + abs(lHn[iI] - lHn[iI-2]), iDP1 + abs(lHn[iI] - lHn[iI-1])] )
  print(lDP[1])

if __name__ == '__main__':
  fnSolv()


Measured memory_bytes: 22712
#include "bits/stdc++.h"
using namespace std;
int main() {
  int N, ans;
  cin >> N;
  for (int i = 1; i <= 10; i++){
    ans = 1000*i - N;
    if (ans < 1000&&ans >= 0) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    while (cin >> n) {
        int ans = 0;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++) {
                int gcdij = __gcd(i, j);
                for (int k = 1; k <= n; k++)
                    ans += __gcd(gcdij, k);
            }
        cout << ans << '\n';
    }
    return 0;
}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int a,b,c;

signed main(){
    cin>>a>>b>>c;
    a+b+c==max({a,b,c})*2?puts("Yes"):puts("No");
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

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

    vector<ll> height(N+1);
    height[0] = A[0];
    ll step = 0;
    
    for (int i = 0; i < N-1; i++)
    {
        height[i+1] = max(height[i], A[i+1]);

        step += max(height[i+1] - A[i+1], (ll) 0);
    }

    cout << step << endl;
    
    return 0;
}


Measured memory_bytes: 6424
from collections import deque
days = int(input())
clast = list(map(int,input().split()))


def scoreing(givenlist):
    global days,clast,allpref
    resultlist = []
    result = 0
    donelist = [deque([0])]*26
    for i in range(days):
        held = givenlist[i]

        donelist[held-1].append(i+1)
        zanen = sum([clast[j]*((i+1)-donelist[j][-1]) for j in range(26)])

        result += allpref[i][held-1] - zanen
        resultlist.append(result)
    donelist.append(resultlist[days-1])
    return donelist

allpref = [] #allpref[day][contest]
for i in range(days):
    allpref.append(list(map(int,input().split())))
donelist = [0]*26
contestlist = []
for i in range(days):
    max = -10**10
    result = 0
    contest = False
    for held in range(26):
        tempdonelist = donelist[:]
        tempdonelist[held] = i+1
        zanen = sum([clast[j]*((i+1)-tempdonelist[j]) for j in range(26)])
        result = allpref[i][held] - 0.5*zanen
        if result >= max:
            max = result;contest = held


    donelist[contest] = i+1
    contestlist.append(contest+1)

for cont in contestlist:
    print(cont)


Measured memory_bytes: 9624
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 1e4 + 5, MAX_DIGIT = 9, oo = 1e6;
int max_length_with_last_digit[MAX_N][MAX_DIGIT];
int digit_cost[MAX_DIGIT + 1] = {0,2,5,5,4,5,6,3,7,6};

int main()
{
    int total_cost, no_of_digits;
    cin >> total_cost >> no_of_digits;

    vector <int> is_present(MAX_DIGIT + 1, false);
    for(int i = 1; i <= no_of_digits; i++)
    {
        int digit;
        cin >> digit;
        is_present[digit] = true;
    }

    vector <int> max_length(total_cost + 1, -oo);
    max_length[0] = 0;

    for(int cost = 1; cost <= total_cost; cost++)
    {
        for(int last_digit = 1; last_digit <= MAX_DIGIT; last_digit++)
        {
            if(!is_present[last_digit] || digit_cost[last_digit] > cost)
                continue;

            int remaining_cost = cost - digit_cost[last_digit];

            max_length_with_last_digit[cost][last_digit] = 1 + max_length[remaining_cost];

            max_length[cost] = max(max_length[cost], max_length_with_last_digit[cost][last_digit]);
        }
    }

    vector <int> answer;

    for(int cost = total_cost; cost > 0; )
    {
        for(int last_digit = MAX_DIGIT; last_digit >= 1; last_digit--)
        {
            if(!is_present[last_digit])
                continue;

            if(max_length_with_last_digit[cost][last_digit] == max_length[cost])
            {
                answer.push_back(last_digit);

                cost -= digit_cost[last_digit];

                break;
            }
        }
    }

    for(int i = 0; i < answer.size(); i++)
        cout << answer[i];

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


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

    cout << n * n - a << endl;


    return 0;
}


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

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int a, b; cin >> a >> b;
	map<int, string>mp;
	mp[1] = "kogakubu10gokan";
	for (int i = 0; i < a; ++i) {
		int y; cin >> y;
		string st; cin >> st;
		mp[y] = st;
	}
	auto it = mp.upper_bound( b);
	cout << (prev(it))->second << endl;
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
  cin >> a.at(i);
  }
  
  int count = 0;
  int push = 1;
  
  while(count < N){
    count++;
    if(a.at(push-1) == 2){
      cout << count << endl;
      break;
    }
    push = a.at(push-1);
  }
  if(count >= N)
    cout << -1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
bool u[11111111];
void Main() {
  int n;
  R n;
  int a[n];
  rep(i,n) R a[i];
  rep(i,n) {
    int x=0;
    rep(j,7) {
      if(i+j>=n) break;
      x*=10;
      x+=a[i+j];
      u[x]=1;
    }
  }
  rep(i,1111111) {
    if(!u[i]) {
      pr(i);
      return;
    }
  }
}

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


Measured memory_bytes: 10812
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI1(x) scanf("%d",&x);
#define inI2(x,y) scanf("%d %d",&x,&y);
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z);
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
int a,b,k,di[10],r,ans;
int main()
{
    inI2(a,b);
    for(int i=a;i<=b;i++)
    {
        bool p=true;
        k=i;
        r=0;
        while(k>0)
        {
            ++r;
            di[r]=k%10;
            k/=10;
        }
        for(int i=1;i<=r;i++)
        {
            if(di[i]!=di[abs(r-i+1)])p=false;
        }
        if(p)ans++;
    }
    printf("%d",ans);
}


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


int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i,n){cin >> a[i];}
  ll ans=0;
  map<int,int> mp;
  rep(i,n){
      int sa=i-a[i];
      ans+=mp[sa];
      int wa=a[i]+i;
      mp[wa]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 21292
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
#include<valarray>
typedef unsigned long long ull;
typedef  long long ll;

int main() {
	int N, Q;

	std::cin >> N >> Q;
	std::vector< std::pair<int , int > > pxx;
	std::vector<int > abx;
	std::vector<ll > answerx;
	abx.resize(N);
	answerx.resize(N);
	for (int i = 1; i < N; i++)
	{
		int tmpa , tmpb;
		std::cin >> tmpa >> tmpb;
		abx[tmpb - 1] = tmpa;
	}

	pxx.resize(Q);
	for (int i = 0; i < Q; i++)
	{
		int tmpp, tmpx;
		std::cin >> tmpp >> tmpx;
		pxx[i] = std::make_pair(tmpp , tmpx);
	}

	std::sort(pxx.begin(), pxx.end() );

	int befa = 1;
	int j = 0;
	int cntq = 0;
	while (j < N)
	{
		if(j != 0) answerx[ j ] = answerx[ abx[ j ] - 1 ];
		int cura = pxx[cntq].first;
		while(( j == cura - 1) )
		{
			answerx[ j ] += (ll)pxx[cntq].second;
			if (cntq < Q - 1) {
				cntq += 1;
			}
			else
			{
				cura = -100;
				break;
			}
			cura = pxx[cntq].first;
		}
		befa = j+1;
		j++;

	}

	for (int i = 0; i < N; i++)
	{
		if (i != 0) std::cout << " ";
		std::cout << answerx[i];
	}
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n,k;
ll a[101];
ll memo[100001];
ll mini;

ll hoge(ll i){
    if(memo[i]!=0){
        return memo[i];
    }
    if(i<mini){
        return memo[i]=2;
    }
    rep(j,0,n-1){
        if(i-a[j]>=0){
            if(hoge(i-a[j])==2){
                return memo[i]=1;
            }
        }
    }
    return memo[i]=2;
    
}

int main(){fastio
    cin>>n;
    cin>>k;
    mini=inf;
    rep(i,0,n-1){
        cin>>a[i];
        mini=min(mini,a[i]);
    }
    if(hoge(k)==1){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 4224
import math
import fractions
a,b,c,d = map(int, input().split())
e = a-1
less_than_e = e - (e//c) - (e//d) + (e//(c*d//fractions.gcd(c,d)))
less_than_b = b - (b//c) - (b//d) + (b//(c*d//fractions.gcd(c,d)))
print(less_than_b - less_than_e)

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

int main(){
   int n;
   cin >> n;
   int *d = new int[n];
    for(int i=0;i<n;i++){
       cin >> d[i];
    }

   int sumrest=0;
   for(int j=0;j<n;j++){
     for(int k=j+1;k<n;k++){
        sumrest+=d[j]*d[k];
 //       cout << sumrest << endl;
    }
   }
   cout << sumrest << endl;
  return 0;
}

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

int main() {
    int A[5];
    for (int i = 0; i < 3; i++) {
        cin >> A[i];
    }
    int k;
    cin >> k;

    sort(A, A + 3);
    int ans = A[0] + A[1] + A[2] * pow(2, k);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int H = sc.nextInt();
            int N = sc.nextInt();

            int[] A = new int[N + 1];
            int[] B = new int[N + 1];
            for (int i = 0; i < N; i++) {
                A[i + 1] = sc.nextInt();
                B[i + 1] = sc.nextInt();
            }

            long[][] dp = new long[N + 2][H + 10000 + 2];

            for (int i = 0; i <= N; i++) {
                Arrays.fill(dp[i], Long.MAX_VALUE / 2);
                dp[i][0] = 0;
            }

            for (int i = 1; i <= N; i++) {
                for (int j = 1; j <= H + A[i]; j++) {
                    if (j < A[i]) {
                        dp[i][j] = Math.min(dp[i - 1][j], B[i]);
                    } else {
                        dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - A[i]] + B[i]);
                    }
                }
            }

            long ans = Long.MAX_VALUE / 2;

            for (int i = dp[N].length - 1; i >= H; i--) {
                ans = Math.min(ans, dp[N][i]);
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 247488
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = new int[2][];
        a[0] = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        a[1] = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            int sum = 0;
            for (int j = 0; j < n; j++)
            {
                if (j < i)
                {
                    sum += a[0][j];
                }
                else if (j == i)
                {
                    sum += a[0][j];
                    sum += a[1][j];
                }
                else
                {
                    sum += a[1][j];
                }
            }
            ans = Math.Max(ans, sum);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.NoSuchElementException;

	
public class Main{
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		long[] A=new long[N];
		for (int i=0;i<N;++i) A[i]=sc.nextLong();
		Arrays.sort(A);
		if (A[0]==0) {
			System.out.println(0);
			return;
		}
		long prd=1;
		for (int i=0;i<N;++i) {
			if (prd<=((long)1e18)/A[i]) prd=prd*A[i];
			else {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(prd);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 35728
fn main() {
    ioset! { inp, buf }
    macro_rules! scan {
        ($($r:tt)*) => {
            input! { inp, $($r)* }
        }
    }
    macro_rules! print {
        ($($t:expr),*) => {
            write!(buf, $($t),*).unwrap();
        } 
    }
    scan! { s: chars, }
    let mut ans = 0;
    let mut cnt = 0;
    for c in s {
        if c == 'R' {
            cnt += 1;
        }
        else {
            cnt = 0;
        }
        ans = std::cmp::max(ans, cnt);
    }
    print!("{}\n", ans);
}

use std::io::{ stdout, BufWriter, Write };

#[macro_export]
macro_rules! ioset {
    ($inp:ident, $buf:ident) => {
        inset!($inp);
        outset!($buf);
    }
}

#[macro_export]
macro_rules! inset {
    (source = $s:expr, $iter:ident) => {
        let mut $iter = $s.split_whitespace();
    };
    ($iter:ident) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut $iter = s.split_whitespace();
    }
}

#[macro_export]
macro_rules! input {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt, $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, mut $var:ident : $t:tt, $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, ($var:expr) : $t:tt, $($r:tt)*) => {
        $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
}

#[macro_export]
macro_rules! read_value {

    // tuple
    ($iter:expr, ( $($t:tt), * )) => {
        ( $(read_value!($iter, $t)), * )
    };
    
    // array
    ($iter:expr, [ $t:tt; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    
    // string
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        $iter.next().unwrap().parse::<usize>().expect("Parse error") - 1
    };
    
    // any other
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[macro_export]
macro_rules! outset {
    ($buf:ident) => {
        let sout = stdout();
        let mut $buf = BufWriter::new(sout.lock());
    }
}

#[macro_export]
macro_rules! output {
    ($buf:expr, $($t:expr),*) => {
        write!($buf, $($t),*).unwrap();
    }
}

struct Chars<'a>(&'a Vec<char>);

impl<'a> std::fmt::Display for Chars<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
        write!(f, "{}", self.0.iter().collect::<String>())
    }
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	int n,n1;

	bool visit[310][310];
	int dep[310][310];


	int morty[2] = {-1,1};
	char morty1[310][310];

	void bfs(int tmp,int tmp1){

		visit[tmp][tmp1] = 1;
		queue<pair<int,int>> queue1;
		queue1.push({tmp,tmp1});
		while(!queue1.empty()){
			auto tmpp = queue1.front();
			queue1.pop();
			int fi = tmpp.first;
			int se = tmpp.second;
			FOR(i,0,2){
				if(fi+morty[i]>=0 and fi+morty[i]<=n-1 and morty1[fi+morty[i]][se]!='#'){
					if(!visit[fi+morty[i]][se]){
						visit[fi+morty[i]][se] = 1;
						queue1.push({fi+morty[i],se});
						dep[fi+morty[i]][se] = dep[fi][se]+1;
					}
				}
			}
			FOR(i,0,2){
				if(se+morty[i]>=0 and se+morty[i]<=n1-1 and morty1[fi][se+morty[i]]!='#'){
					if(!visit[fi][se+morty[i]]){
						visit[fi][se+morty[i]] = 1;
						queue1.push({fi,se+morty[i]});
						dep[fi][se+morty[i]] = dep[fi][se]+1;
					}
				}
			}
		}
	}
	

	void solve(){
		
		
		in(n,n1);
		int tmp = 0;
		FOR(i,0,n)FOR(i1,0,n1){in(morty1[i][i1]);if(morty1[i][i1] =='.')tmp++;}
		bfs(0,0);
		if(dep[n-1][n1-1] == 0 and (n!=1 and n1!=1)){out(-1);}
		else out(tmp-dep[n-1][n1-1]-1);




		
		
	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 384
s = input()

acgt_max = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[j] != 'A' and s[j] != 'C' and s[j] != 'G' and s[j] != 'T':
            acgt_max = max(acgt_max, j - i)
            break
    else:
        acgt_max = max(acgt_max, j - i + 1)
print(acgt_max)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



signed main(){
	ll x; cin>>x;
	ll now = 100;
	ll ans = 0;
	while(now<x){
		now += now/100;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
n = int(input())
for _ in range(n):
    a, b, c = map(int, input().split())
    if (a**2 + b**2 == c**2) or\
            (b**2 + c**2 == a**2) or\
            (c**2 + a**2 == b**2):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5600
N,W = map(int, input().strip().split(" "))
oj = []
for i in range(N):
    tmp = list(map(int, input().strip().split(" ")))
    oj.append(tmp)

dp = [[0] * (W+1) for i in range(N)]
for i in range(W+1):
    dp[0][i] = oj[0][1] if oj[0][0] <= i else 0

for i in range(1,N):
    for j in range(W+1):
        if j < oj[i][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-oj[i][0]] + oj[i][1])
print(max(dp[N-1]))


Measured memory_bytes: 119788
import java.util.Scanner;

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

        int N = Integer.parseInt(sc.next());

        for (int i = 0; i < N; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());

            if (a < b) {
                a ^= b;
                b ^= a;
                a ^= b;
            }

            if (a < c) {
                a ^= c;
                c ^= a;
                a ^= c;
            }

            if (Math.pow(a, 2) == (Math.pow(b, 2) + Math.pow(c, 2))) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 33508
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, K;
  cin >> N >> K;
  v(bool) A(N, true);
  i64 d;
  i64 a;
  rep(i, K){
    cin >> d;
    rep(j, d){
      cin >> a;
      a--;
      A[a] = false;
    }
  }

  cout << accumulate(rng(A), 0LL) << "\n";

}

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

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


int main() {
  int l,r,a,min;
  cin >> l >> r;

  min=2018;
  if(r-l>=2019) min=0;
  else {
    while(l>2018) l-=2019;
    while(r>2018) r-=2019;
    if(l<r) {
      for(int i=l;i<r;i++) {
	for(int j=i+1;j<=r;j++) {
	  a=i*j;
	  while(a>2018) a-=2019;
	  if(a<min) min=a;
	}
      }
    }else min=0;
  }

  cout << min << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int xmove[17000];
int ymove[17000];
void solve(){
    string s;
    cin >> s;
    ll x,y;
    cin >> x >> y;
    Vi hor,ver;
    bool horizontal=true;
    ll ctr=0;
    bool first;
    if(s[0]=='T') first=false;
    else first=true;
    for(auto c:s){
        if(c=='F'){
            ctr++;
        }else{
            if(horizontal) hor.pb(ctr);
            else ver.pb(ctr);
            horizontal^=true;
            ctr=0;
        }
    }
    if(horizontal) hor.pb(ctr);
    else ver.pb(ctr);
    
    if(first) {
        xmove[8500+hor[0]]=1;
        hor[0]=0;
    }
    else xmove[8500]=1;
    ymove[8500]=1;
    for(auto mov: hor){
        p_queue(ll) que;
        rp(i,17000){
            if(xmove[i]==0) continue;
            if(i-mov>=0) que.push(i-mov);
            if(i+mov<17000) que.push(i+mov);
        }
        fill(xmove,xmove+16999,0);
        while(!que.empty()){
            ll i=que.top(); que.pop();
            xmove[i]=1;
        }
    }
    for(auto mov: ver){
        p_queue(ll) que;
        rp(i,17000){
            if(ymove[i]==0) continue;
            if(i-mov>=0) que.push(i-mov);
            if(i+mov<17000) que.push(i+mov);
        }
        fill(ymove,ymove+16999,0);
        while(!que.empty()){
            ll i=que.top(); que.pop();
            ymove[i]=1;
        }
    }
    Yes(xmove[x+8500]==1&&ymove[y+8500]==1);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3928
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    //int a,b,c;
    //cin >> a >> b >> c;
    vector<int>a(3);
    REP(i,3)cin >> a[i];
    SORT(a);
    int answer = 0;
    while(a[0]+2 <= a[2]){
        a[0]+=2;
        answer++;
    }
    while(a[1]+2 <= a[2]){
        a[1]+=2;
        answer++;
    }
    if(a[0]==a[1]){
        if(a[0]!=a[2]){
            answer++;
        }
    }
    else{
        answer+=2;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
#include<cstring>
#include<list>
using namespace std;
int dx[] = { -1,0,0,1 };
int dy[] = { 0,1,-1 ,0 };
#define endl '\n'
#define mod 1000000007
const long double P = 3.141592653589793238L;
void GAME_OVER()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("ouput.txt", "w", stdout);

}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mod;
		y = (y >> 1); //y/=2
		x = (x*x) % mod;
	}

	return p;
}


long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = (p * i);
		p /= p1;
		p1++;
	}
	return p;
}
int n, m; char c[1001][1001]; long long mem[1001][1001];
long long dp(int x, int y) {
	if (x == n-1&&y == m-1)
		return 1;
	if (mem[x][y] != -1)
		return mem[x][y];
	int r = 0, d = 0;
	if (x < n-1&&c[x+1][y]=='.')
		d=dp(x + 1, y);
	if (y < m-1&&c[x][y+1]=='.')
		r=dp(x, y + 1);
	return mem[x][y] = (d + r) % mod;

}
int main()
{
	GAME_OVER();
	memset(mem, -1, sizeof mem);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			cin >> c[i][j];
	}
	cout << dp(0, 0) << endl;
	return 0;

}



Measured memory_bytes: 12584