akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int a[10000];

int main() {
  int n;
  while(cin>>n) {
    inputs(a,n);
    double ans = 0;
    REP(i,n) {
      ans += 1.0 / a[i];
    }
    ans = 1.0 / ans;
    printf("%.10f\n", ans);
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pb push_back
#define AA first
#define BB second
#define ONES(x) __builtin_popcount(x)
#define _ <<" "<<
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
const double eps=1e-6;
const int mod=1e9+7;
const double PI=acos(-1.0);
inline int read(){ int num;    scanf("%2d",&num);   return num;}
const int maxn=1e5+7;
int main()
{
	int a,b,c,d;
	a=read();b=read();//getchar();//c=read();d=read();
	//string s;cin>>s;
	//s[b-1]+=32;
	//cout<<s<<endl;
	if(a>=1&&a<=12&&b>=1&&b<=12)
	{
		cout<<"AMBIGUOUS"<<endl;
	}
	else if((a>=1&&a<=12)&&!(b>=1&&b<=12))
	{
		cout<<"MMYY"<<endl;
	}
	else if(!(a>=1&&a<=12)&&(b>=1&&b<=12))
	{
		cout<<"YYMM"<<endl;
	}
	else cout<<"NA"<<endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        a: [i32; n],
    }
    // annotate for rust-analyzer
    let n: usize = n;
    let k: usize = k;
    let mut a: Vec<i32> = a;

    a.sort();
    let ans: i32 = a.iter().take(k).sum();

    println!("{}", ans);
}


Measured memory_bytes: 2216
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,A,B;
signed main(){
	scanf("%lld%lld%lld",&n,&A,&B);
	if ((A-B)&1){
		if (A>B)swap(A,B);
		printf("%lld\n",min(A-1+(B-A)/2+1,(n-B)+(n-A-(n-B))/2+1));
	}
	else {
		printf("%lld\n",abs(A-B)/2);
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main(){
    speed;
    string a,b;
    int ans=0;
    cin >> a >> b;
    for ( int i = 0;i < a.size();i++){
        if (a[i] == b[i]){
            ans++;
        }
    }
    cout << ans;
}





Measured memory_bytes: 256
#include<iostream> 
using namespace std;
bool flag[3];
int main(){
    string a; 
    cin>>a;
    for(int i=0;i<a.length();++i){
        if(a[i]=='C')flag[0]=1; 
        if(a[i]=='F'&&flag[0])flag[1]=1; 
    }
    if(flag[1])cout<<"Yes"; 
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int num1, num2;
	scanf("%d %d", &num1, &num2);
	
	if (num1 * 500 >= num2){
		printf("Yes \n", num1);
	}
	else {
		printf("No \n", num1);
	}
	
	return 0;
}

Measured memory_bytes: 3088
N = int(input())
list_cards = [0]*N
list_cards = list(map(int,input().split()))

def insertionsort(A, N):
    for i in range(N):
        v = A[i]
        j = i-1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v        

        A_str = list(map(str, A))
        print(" ".join(A_str))

    return(A)

result_cards = insertionsort(list_cards, N)



Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <cmath>

int main() {
  int q;
  std::cin >> q;
  while (q-- > 0) {
    int64_t A, B;
    std::cin >> A >> B;
    int64_t N = A * B;

    int64_t mid = std::sqrt(static_cast<long double>(N - 1));
    for (int64_t i = mid; i < std::max(A, B); ++i) {
      if (N > i * i)
        mid = i;
      else
        break;
    }
    int64_t ans = mid * 2;
    if (A != B)
      ans--;
    if (mid * (mid + 1) >= N)
      ans--;
    std::cout << ans << std::endl;
  }
}


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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000000;
// clang-format on

int a, b;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;

  if (a < b) {
    REP(i, b) cout << a;
    cout << endl;
  } else {
    REP(i, a) cout << b;
    cout << endl;
  }

  return 0;
}


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

int main() {
    
  int a,b;
  cin >> a >> b;
  
  if((a*b)%2==0){
   
      cout<< "Even" <<endl;
      
  }
  else{
    
      cout <<"Odd" << endl;
      
  }
    
  
}


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

int main()
{
    int A;
  	int B = 0;
    cin >> A;
    if(A % 2 == 0)
    {
        B = A / 2;
        cout << fixed << setprecision(10) << double(B) / A << endl;
    }
    else
    {
        B = A / 2 + 1;
        cout << fixed << setprecision(10) << double(B) / A << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int a,b,k;

	cin>>a>>b>>k;

	int t=0;
	rrep(i,min(a,b)){
		if(a%(i+1)==0&&b%(i+1)==0)t++;
		if(t==k){
			cout<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}


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

int lcs(string s1, string s2){
    int n=s1.size();
    int m=s2.size();

    s1=' '+s1;
    s2=' '+s2;

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

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s1[i]==s2[j]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }

    return dp[n][m];

}

int main(void){
    int n; cin >> n;
    for(int i=0; i<n; i++){
        string s1,s2; cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
}


Measured memory_bytes: 7068
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char map[505][505];
int def[505][505];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };

int main() {
	int h, w;
	cin >> h >> w;
	ll count = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> map[i][j];
			def[i][j] = inf;
			if (map[i][j] == '#') {
				count++;
			}
		}
	}
	queue<P>que;
	que.push(make_pair(0, 0));
	def[0][0] = 0;
	while (!que.empty()) {
		int nowx = que.front().first;
		int nowy = que.front().second;
		que.pop();
		for (int i = 0; i < 4; i++) {
			int nextx = nowx + dx[i];
			int nexty = nowy + dy[i];
			if (nextx >= 0 && nextx < w && nexty >= 0 && nexty < h && map[nexty][nextx] == '.' && def[nexty][nextx] == inf) {
				def[nexty][nextx] = def[nowy][nowx] + 1;
				que.push(make_pair(nextx, nexty));
			}
		}
	}
	if (def[h - 1][w - 1]==inf) {
		cout << "-1" << endl;
		return 0;
	}
	ll ans = def[h - 1][w - 1] + 1;
	cout << h * w  -  count - ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define inf ((1<<30)-1)
#define linf ((1<<62)ll-1)
#define Fu(i,a,b) for(register int i=a;i<=b;i++)
#define Fd(i,a,b) for(register int i=a;i>=b;i--)
#define Fn(i,a) for(register int i=las[a];i;i=nex[i])
int Fl,Pn,SI=100;char mch='\n',ch,Bf[21];
template<typename t>void in(t&a){a=0;ch=getchar();Fl=1;while((ch<'0')||(ch>'9'))Fl=(ch=='-')?-Fl:Fl,ch=getchar();while((ch>='0')&&(ch<='9'))a=a*10+ch-'0',ch=getchar();a*=Fl;}
template<typename t>void out(t a){if(a<0)putchar('-'),a=-a;if(a==0)putchar('0');while(a)Bf[++Pn]=a%10+'0',a/=10;while(Pn)putchar(Bf[Pn]),--Pn;putchar(mch);}
template<typename t,typename ...ARGS>void in(t&a,ARGS&...args){in(a);in(args...);}
template<typename t,typename ...ARGS>void out(t a,ARGS... args){out(a);out(args...);}
using namespace std;
int n,t1,t2,s[100001];bool p[100001],is17[100001];
int main()
{
	p[1]=1;
	Fu(i,2,sqrt(100000))if(!p[i])Fu(j,2,100000/i)p[i*j]=1;
	Fu(i,1,100000)if(!p[i]&&!p[(i+1)/2])is17[i]=1;
	Fu(i,1,100000)s[i]=s[i-1]+is17[i];
	in(n);
	Fu(i,1,n)in(t1,t2),out(s[t2]-s[t1-1]);
	return 0;
}


Measured memory_bytes: 1280
import java.util.*;
import java.io.*;

public class Main {	

	private static void solve(){
		//Implement solution here.
		long[] D = new long[100001];
		int N = ni();
		long result = 0;
		for(int i = 0; i < N; i++) {
			int A = ni();
			D[A]++;
			result += A; 
		}
		int Q = ni();
		
		for(int i = 0; i < Q; i++) {
			int B = ni();
			int C = ni();
			result -= (long)B * D[B];
			result += (long)C * D[B];
			D[C] += D[B];
			D[B] = 0;			
			System.out.println(result);
 		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 53016
#include <iostream>
#include <stdlib.h>
using namespace std;
 
int main(){
  string str, code;
  int code_num;
 
  cin >> str >> code_num;
 
  for(int i=0; i<code_num; i++){
    cin >> code;
     
    int start, end;
    string buf;
     
    if(code == "replace"){
      cin >> start >> end >> buf;
 
      for(int i=0; i<=end-start; i++){
        str[start + i] = buf[i];
      }
    }else if(code == "reverse"){
      cin >> start >> end;
      buf = str;
      for(int i=0; i<=end-start; i++){
        str[start + i] = buf[end - i];
      }
    }else if(code == "print"){
      cin >> start >> end;
      for(int i=start; i<=end; i++){
        cout << str[i];
      }
      cout << endl;
    }
 
  }
 
  return(0);
 
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
s = int(s)

if s < 500:
    happy5 = s // 5
    happy = 5 * happy5
    print(happy)
else:
    happy500 = s//500
    
    happy5 = s%500
    happy5 = happy5//5
    
    happy = 1000*happy500 + 5*happy5
    print(happy)
    

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

int binarysort(int s[],int n,int key) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (s[mid] < key) left = mid + 1;
		if (s[mid] == key) return 1;
		else if (s[mid] > key) right = mid;
	}
	return 0;
}

int main() {
	int n, q;
	int c = 0;
	int s[100000];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;
	int num1 = 0;

	for (int i = 0; i < q; i++) {
		cin >> num1;
		if (binarysort(s,n,num1)) c++;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 3480
#include <iostream>
using namespace std;
 
int main() {
	int n;
  	cin >> n;
  	unsigned long long x;
  	unsigned long long z = 1;
  	bool flag = false;
  	bool zeroflag = false;
  	for (int i = 0; i < n; i++ )
    {
      cin >> x;
      if (x == 0) 
      {
        zeroflag = true;
        break;
      }
      if (x <= 1000000000000000000/z)
      {
        z = z*x;
      }
      else 
      {
		flag = true;
      }
    }
  if (!zeroflag) 
  {
    if(!flag) 
    {
  		cout << z << endl;
    }
    else
    {
        cout << -1 << endl;
    }
  }
  else
  {
    cout << 0 << endl;
  }
  
	return 0;
}

Measured memory_bytes: 3164
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	char x;
    cin >> x;
    if(x-'a'>=0){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl; 
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  ll count[2019] = {}; count[0] = 1;
  ll now = 0, p10 = 1;
  per(i,S.length()) {
    now = (now+(S[i]-'0')*p10) % 2019;
    count[now]++;
    p10 = p10*10%2019;
  }
  ll result = 0;
  rep(i,2019) result += count[i]*(count[i]-1)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3772
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	setIO();
	cin >> n;

	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		cur ^= a[i];
	}
//	cout << cur << '\n';
	for (int i = 1; i <= n; ++i) {
		cout << (cur^a[i]) << ' ';
	}
	cout << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 18508
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

vll dp_local(vll& table, int C) {
    v2ll dp(C + 1, vll(4, -LINF));
    rep(i, C) dp[i][0] = 0;

    REP(i, 1, C + 1) {
        for(int j = 2; j>= 0;j--) {
            dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j] + table[i]);
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        }
        
    }
    vll ans(C + 1);
    rep(i, C + 1) ans[i] = max(max(max(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]);
    return ans;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int R, C, K;

    cin >> R >> C >> K;
    v2ll table(R + 1, vll(C + 1, 0));
    rep(i, K) {
        int r, c;
        cin >> r >> c;
        cin >> table[r][c];
    }
    vector<v2ll> dp(R + 1, v2ll(C + 1, vll(4, -LINF)));
    //dp[0][0][0] = 0;
    rep(i, C + 1) dp[0][i][0] = 0;
    //rep(i, R + 1) dp[i][0][0] = 0;
    ll ans = -LINF;
    REP(i, 1, R + 1) {
        //auto dp2 = dp_local(table[i], C);

        REP(j, 1, C + 1) {
            rep(l, 4) dp[i][j][l] = max(dp[i][j][l], dp[i][j - 1][l]);
            rep(k, 3) {
                if (table[i][j] == 0) continue;
                if (dp[i][j - 1][k] >= 0)
                    dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j - 1][k] + table[i][j]);

            }
            ll m = 0;
            rep(l, 4) {
                m = max(m, dp[i - 1][j][l]);
            }
            dp[i][j][0] = max(dp[i][j][0], m);
            if (table[i][j] == 0) continue;
            dp[i][j][1] = max(dp[i][j][1], m + table[i][j]);
            
        }
    }
    rep(k, 4) ans = max(ans, dp[R][C][k]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 707292
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;


public class Main{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	static class Pair
	{
		int p;
		int q;
		Pair(int p,int q)
		{
			this.p = p;
			this.q = q;
		}
	}
	
	static int gcd(int a,int b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
	
	
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        
        char ar[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
        
        int n = sc.nextInt();
        String s = sc.nextLine();
        
        StringBuffer sb = new StringBuffer();
        
        for(int i = 0; i < s.length(); i++)
        {
        	int x = s.charAt(i)-'A';
        	x = (x+n)%26;
        	sb.append(ar[x]);
        }
        out.println(sb.toString());
        out.close();
	}

}


Measured memory_bytes: 21332
#include<stdio.h>

void trace(int A[],int N){
   int i;
   for(i=0;i<N;i++){
      if(i>0)printf(" ");
      printf("%d",A[i]);
   }
   printf("\n");
}


int insertionSort(int A[],int N){

   int j,i,v;

   for(i=1;i<N;i++){

      v=A[i];
      j=i-1;

      while(j>=0&&A[j]>v){

         A[j+1]=A[j];
         j--;

      }

      A[j+1]=v;
      trace(A,N);

   }
}

      
int main(){

   int N,i,j;
   int A[100];

   scanf("%d",&N);

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

  trace(A,N);
  insertionSort(A,N); 
  
   return 0;

}
   

Measured memory_bytes: 2704
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

//-----------------------------------------------
#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 1000 * 1000 + 5;
const ll mod = 1000000007;
const ll INF = 1000000000 * 1ll * 1000000000 + 500000;
const ld pi = acosl(-1.0);

int n;

void input() {
    cin >> n;
}

void solve(int testId) {
    cout << !n << endl;
}

int main() {
    // freopen("test", "r", stdin);
    int testcases = 1;
    // scanf("%d", &testcases);
    for(int testId = 1; testId <= testcases; testId++) {
        input();
        solve(testId);
    }
    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a);i<=(int)(b);++i)
#define per(i, a, b) for(int i=(a);i>=(int)(b);--i)
#define debug(x)   cout << #x << ' ' << x << endl;
#define one(x) __builtin_popcount(x)
using namespace std;

const int MAXN = 1e5 + 7;
int l[MAXN], r[MAXN], a[MAXN];
int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i, 0, n-1){
        if(s[i] == 'R') r[i] = i;
        else    r[i] = r[i-1];
    }
    per(i, n-1, 0){
        if(s[i] == 'L') l[i] = i;
        else    l[i] = l[i+1];
    }
    rep(i, 0, n-1){
        if(s[i] == 'L'){
            if((i-r[i])&1) a[r[i]+1]++;
            else    a[r[i]]++;
        } else {
            if((l[i]-i)&1)  a[l[i]-1]++;
            else    a[l[i]]++;
        }
    }
    rep(i, 0, n-1){
        printf("%d ", a[i]);
    }
    return 0;
}

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

// #include <iostream>
// #include <fstream>
// #include <string>
// #include <map>
// #include <vector>
// #include <algorithm>
// #include <regex>
// #include <chrono>
// #include <sstream>
// #include <iomanip>
// #include <queue>
// #include <stack>
// #include <set>
// #include <unordered_map>
// #include <unordered_set>


using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}

int n;
int a[25][25];

int dp[1<<22];

signed main() {

	cin >> n;

	for(int i = 0; i < n; i++) {

		for(int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	dp[0] = 1;

	for(int s = 1; s <  (1<<n); s++) {
		int i = __builtin_popcount(s);
		for(int j = 0; j < n; j++) {
			if(((s>>j)&1)==1&&a[i-1][j]==1){
				dp[s] += dp[s^(1<<j)];
				dp[s] %= SMOD;
			}
		}
	}

	cout << dp[(1<<n)-1] << endl;


    return 0;
}



Measured memory_bytes: 18688
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let n = {
        let i = read::<i64>();
        i[0]
    };

    let a = read::<i64>();
    let mut m = Vec::new();

    let mut i = 0;
    for an in a {
        i += 1;
        m.push(an - i);
    }

    m.sort();
    let b = m[(n / 2) as usize];
    let mut ans: i64 = 0;

    for mn in m.into_iter() {
        ans += (b - mn).abs();
    }

    println!("{}", ans);
}


Measured memory_bytes: 10492
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sr = new Scanner(System.in);
		String s = sr.next();
		int c = 0;
		for(int i = 0; i < s.length(); i++){
			if(s.substring(i, i + 1).equals("+")){
				c++;
			}else{
				c--;
			}
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  string a;
  ll b;
  ci(a>>b);
  ll an=0;
  For(i,1,a.size()){
    if(a[i-1]==a[i]&&a[i]==a[i+1]){
      an++;
      i++;
    }
    else if(a[i-1]==a[i])
      an++;
  }
  an*=b;
  //co(an);//確認
  //if(a[0]==a[a.size()-1]&&a[a.size()-1]!=a[a.size()-2])
    //an+=b-1;
  ll l=1,r=1;
  if(a[0]==a[a.size()-1]){
  For(i,1,a.size()){
    if(a[i-1]==a[i])
      l++;
    else
      break;
  }
  rFor(i,a.size()-2,-1){
    if(a[i+1]==a[i])
      r++;
    else
      break;
  }
  if(a.size()!=2){
    if(l+r>a.size()&&l%2==1)
      an+=b/2;
    //else if(l+r>a.size())
      
    else if(l%2==1&&r%2==1)
      an+=b-1;
  }
  }
  if(a.size()==1)
    an=b/2;
  co(an);//答え
  //co(l);
  //co(r);
}

Measured memory_bytes: 256
N = int(input())

s = ['a']*N
t = ['a']*N

for i in range(N):
  s[i],t[i] = input().split()

finish = input()

index = s.index(finish)

sum = 0
for i in range(index+1,N):
	sum += int(t[i])
print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    int k=0,n;
    char s[101];
    cin.getline(s,101);
    n=strlen(s);
    for(int i=0;i<=n/2-1;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            k++;
        }
    }
    cout<<k;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
ans = 0

import collections
c = collections.Counter(A)

two = []
four = []

for i in sorted(set(A)):
    a = c[i]
    
    if a > 1:
        two.append(i)
        
    if a > 3:
        four.append(i)
        
if len(two) > 0:
    two = sorted(two)
    ans = two[-1] * two[-2]
    
if len(four) > 0:
    ans = max(max(four)**2,ans)
    
print(ans)

Measured memory_bytes: 20620
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 200005            //array size 
#define PI 3.1415926535
using namespace std;

// #define TRACE
// #ifdef TRACE
// #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
//     template <typename Arg1>
//     void __f(const char* name, Arg1&& arg1){
//         cout << name << " : " << arg1 << std::endl;
//         //use cerr if u want to display at the bottom
//     }
//     template <typename Arg1, typename... Args>
//     void __f(const char* names, Arg1&& arg1, Args&&... args){
//         const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
//     }
// #else
// #define trace(...)
// #endif

int frog(vector<int> h,int n,int k)
{
    if(n==1) return h[1];
    if(n==2) return abs(h[2]-h[1]);

    vector<int> dp(n+1);
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);

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

        for(int j=i-1; j>=1 && i-j<=k; j--)
        {
            dp[i]=min( dp[i], abs(h[i]-h[j])+dp[j] );
        }        
    }
    return dp[n];
}

int32_t main(){

	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    //main body
    int n; cin>>n;
    int k; cin>>k;
    vector<int> h;
    h.pb(0);
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;
        h.pb(x);
    }
    
    cout<<frog(h,n,k)<<" ";
    
    return 0;
}

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

int isPrime(int n){
	for(int i=2; i*i<=n; ++i){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}

#define MAX_N 1000000

int ans[MAX_N];

main(){
	ans[0] = 0;
	ans[1] = 0;
	for(int i=2; i<MAX_N; i++){
		ans[i] = ans[i-1] + isPrime(i);
	}
	
	int n;
	while(cin>>n){
		cout << ans[n] << endl;
	}
}



Measured memory_bytes: 7000
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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 long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
   int a,b;
   cin>>a>>b;
   vector<int> vec(a,0);
   rep(i,b){
       int p;
       cin>>p;
       rep(j,p){
           int t;
           cin>>t;
           vec.at(t-1)++;
       }
   }
   int sum=0;
   rep(i,a){
       if(vec.at(i)==0){
           sum++;
       }
   }
   cout<<sum<<endl;
}



Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    S = Scanner.string()
    k = Scanner.int()
    N = len(S)
    M = set()
    for i in range(N):
        for j in range(k):
            M.add(S[i: i + j + 1])
    M = sorted(list(M))
    print(M[k - 1])


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    int n;
    cin>>n;
    if(n >= 400 && n <= 599){
        cout<<8;
    }else if(n >= 600 && n <= 799){
        cout<<7;
    }else if(n >= 800 && n <= 999){
        cout<<6;
    }else if(n >= 1000 && n<=1199){
        cout<<5;
    }else if(n >= 1200 && n <= 1399){
        cout<<4;
    }else if(n >= 1400 && n <= 1599){
        cout<<3;
    }else if(n >= 1600 && n <= 1799){
        cout<<2;
    }else{
        cout<<1;
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll R, G, B, N;
	cin >> R >> G >> B >> N;

	ll ans = 0;

	for (ll r = 0; r <= N; ++r)
	{
		ll n1 = N - r * R;
		if (n1 < 0) break;
		for (ll g = 0; g <= N; ++g)
		{
			ll n2 = n1 - g * G;
			if (n2 < 0) break;

			if (n2 % B == 0) ans++;
		}
	}

	cout << ans << endl;

	//system("pause");
}

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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        a[0] = Integer.parseInt(sc.next());
        a[1] = Integer.parseInt(sc.next());
        a[2] = Integer.parseInt(sc.next());
        Arrays.sort(a);
        System.out.println(a[0] + " " + a[1] + " " + a[2]);
    }
}


Measured memory_bytes: 26284
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n;
	cin>>m>>n;
	int sun =0 ,d,s;
	for(int i=4;i<=m;i++){
		s=0;
		for(int j=22;j<=n;j++){
			d=j;
			s=(d%10)*(d/10);
			if(s==i&&j%10>=2&&j/10>=2)
				sun++;
		}
	}
	cout<<sun;
}

Measured memory_bytes: 256
s = input()
q = int(input())
head = []
tail = []
state = 1

for i in range(q):
    query = input().split()
    if len(query) == 1:
        state *= -1

    elif state == 1:
        if query[1] == "1":
            head.append(query[2])
        else:
            tail.append(query[2])
    else:
        if query[1] == "1":
            tail.append(query[2])
        else:
            head.append(query[2])

if state == 1:
    print("".join(head[::-1])+s+"".join(tail))
else:
    print("".join(tail[::-1])+s[::-1]+"".join(head))


Measured memory_bytes: 6252
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*4
#define ll long long	 
struct segmenttree{
	ll tree[nn*2+10];ll tag[nn*2+10];
	#define lc id<<1
	#define rc id<<1|1
	void add(ll id,ll y)
	{
		tree[id]+=y;
		tag[id]+=y;
	}
	void down(ll id)
	{
		add(lc,tag[id]);
		add(rc,tag[id]);
		tag[id]=0;
	}
	#define mid (l+r)/2
	void update(ll a,ll b,ll l,ll r,ll id,ll y)
	{
		if(l>=a and r<=b)
		{
			add(id,y);
			return ;
		}
		down(id);
		if(a<=mid) update(a,b,l,mid,lc,y);
		if(b>mid) update(a,b,mid+1,r,rc,y);
		tree[id]=max(tree[lc],tree[rc]); 
	}
	ll query(ll a,ll b,ll l,ll r,ll id)
	{
	//	cout<<l<<" "<<r<<":"<<id<<"\n";
		if(l>=a and r<=b) return tree[id];
		ll sm=-1e16;down(id);
		if(a<=mid) sm=max(sm,query(a,b,l,mid,lc));
		if(b>mid) sm=max(sm,query(a,b,mid+1,r,rc));
		return sm;
	}
	ll query(ll l,ll r)
	{
		return query(l+1,r+1,1,nn,1);
	}
	void update(ll l,ll r,ll y)
	{
		update(l+1,r+1,1,nn,1,y);
	}
}trcyx;
struct farmer{
	ll l,r,sm;
	void in()
	{
		scanf("%lld%lld%lld",&l,&r,&sm);
	}
};
vector<farmer> ad[nn],sb[nn];
ll n,m;
ll f[nn];
int main()
{
	scanf("%lld%lld",&n,&m);
	for(ll i=1;i<=m;i++)
	{
		farmer a;a.in();
		ad[a.l].push_back(a);
		sb[a.r+1].push_back(a);
	}
	f[0]=0;
	ll cn=0;//cout<<"ag";
	for(ll i=1;i<=n+1;i++)
	{
		for(ll j=0;j<(ll)ad[i].size();j++)
		{
			farmer bow=ad[i][j];
			trcyx.update(bow.l,bow.r,-bow.sm);
			cn+=bow.sm;
		}
		for(ll j=0;j<(ll)sb[i].size();j++)
		{
			farmer bow=sb[i][j];
			trcyx.update(bow.l,bow.r,bow.sm);
			cn-=bow.sm;
		}//cout<<"k";
		f[i]=trcyx.query(0,i-1)+cn;
		trcyx.update(i,i,f[i]);
	}
	cout<<trcyx.query(0,n);
	return 0;
}

Measured memory_bytes: 35200
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
ans=0
for i in range(k):
  R=0
  S=0
  P=0
  cnt=0
  while i+cnt*k<n:
    if i+cnt*k-k<0:
      if t[i+cnt*k]=='r':
        ans+=p
        P=1
      elif t[i+cnt*k]=='s':
        ans+=r
        R=1
      else:
        ans+=s
        S=1
    elif i+cnt*k-k>=0 and t[i+cnt*k]==t[i+cnt*k-k]:
      if t[i+cnt*k]=='r' and P==0:
        ans+=p
        P=1
      elif t[i+cnt*k]=='r' and P==1:
        P=0
      elif t[i+cnt*k]=='s' and R==0:
        ans+=r
        R=1
      elif t[i+cnt*k]=='s' and R==1:
        R=0
      elif t[i+cnt*k]=='p' and S==0:
        ans+=s
        S=1
      elif t[i+cnt*k]=='p' and S==1:
        S=0
    elif i+cnt*k-k>=0 and t[i+cnt*k]!=t[i+cnt*k-k]:
      if t[i+cnt*k]=='r':
        ans+=p
        P=1
      elif t[i+cnt*k]=='s':
        ans+=r
        R=1
      else:
        ans+=s
        S=1
    cnt+=1
print(ans)

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int64_t N, tmp, ans = large;
    cin >> N;
    for (int64_t i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            tmp = i + (N / i);
            ans = min(ans, tmp);
        }
    }
    cout << ans - 2;
}

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

int n, maxval=-1, ans;

int main()
{
  scanf("%d", &n);
  int i;
  for(i=0; i<n; i++)
  {
    int x;
    scanf("%d", &x);
    ans+=x;
    maxval=max(maxval, x);
  }
  ans-=maxval/2;
  printf("%d", ans);
}

Measured memory_bytes: 256