akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

long long modpow(long long x,long long n) {
    long long result = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            result = (result * x) % mod;
        }
        x = (x * x) % mod;
        n >>= 1;
    }
 
    return result;
}

long long x[200000],y[200000];

int main(void){
	long long h=llin(),w=llin(),a=llin(),b=llin(),ans=0,i;
	int j;
	x[0]=1;
	for(j=1;j<h+w;j++)
		x[j]=(x[j-1]*j)%mod;
	rep(j,h+w)
		y[j]=modpow(x[j],mod-2);
	for(i=1;i<=h-a;i++)
		ans=(ans+(x[i+b-2]*y[i-1]%mod*y[b-1]%mod*x[h-i+w-b-1]%mod*y[h-i]%mod*y[w-b-1]%mod))%mod;
	llprint(ans);
	
	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
ll a[100010];
int main()
{
	ll n,k,s;
	scanf("%lld %lld %lld",&n,&k,&s);
	if(k==n){
		for(int i=0;i<n;i++){
			cout<<s<<(i==n-1?'\n':' ');
		}
	}else{
		for(int i=0;i<k;i++){
			cout<<s<<" ";
		}
		for(int i=0;i<n-k;i++){
			if(s==1){
				cout<<2<<(i==n-k-1?'\n':' ');
			}else{
				cout<<s-1<<(i==n-k-1?'\n':' ');
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#define MAX 200
using namespace std;


bool my_comp(pair<int,int> a,pair<int,int> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }
    if(a.second!=b.second){
        return a.second>b.second;
    }else return true;
}

int main(){
    int N;
    cin >> N;
    pair<int,int> red[101];
    pair<int,int> blue[101];
    for(int i=0;i<N;i++){
        cin >> red[i].first >> red[i].second;
    }
    sort(red,red+N);
    for(int i=0;i<N;i++){
        cin >> blue[i].first >> blue[i].second;
    }
    sort(blue,blue+N);
    vector<bool> V(N,false);
    int count = 0;
    for(int i=0;i<N;i++){
        int max = 0;
        int tmp = -1;
        for(int j=0;j<N;j++){
            if(V[j])continue;
            if(blue[i].first>red[j].first&&blue[i].second>red[j].second&&max<=red[j].second){
                max=red[j].second;
                tmp = j;
            }
        }
        if(tmp!=-1){
            count++;
            V[tmp] = true;
        }
    }
    cout <<count << endl;
    return 0;
}

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

int main()
{
	std::string s;
	std::cin >> s;
	std::stack<char> pre;
	int count{};
	for (auto& e: s)
	{
		if (pre.empty() || e == pre.top())
		{
			pre.push(e);
		}
		else
		{
			pre.pop();
			count++;
		}
	}
	printf("%d\n", 2 * count);

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    int cnt = 1, ans = 0;
    REP(i,n) {
        cin >> a[i];
        if(i>0 && a[i]==a[i-1]) ++cnt;
        else {
            ans += (cnt/2);
            cnt = 1;
        }
    }
    ans += (cnt/2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
D, X = map(int, input().split())
a = [0] + [(int(input())) for i in range(N)]

cnt = 0
for i in range(1,N+1):
    for j in range(100+1):
        if j*a[i]+1 <= D:
            cnt += 1
answer = cnt + X
print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 110
#define llg long long 
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,maxlen,len[maxn],L,c[maxn],ma[maxn];
char s[maxn][maxn],ans[maxn],ch[maxn];
inline int getint()
{
       int w=0,q=0; char c=getchar();
       while((c<'0' || c>'9') && c!='-') c=getchar(); if(c=='-') q=1,c=getchar(); 
       while (c>='0' && c<='9') w=w*10+c-'0', c=getchar(); return q ? -w : w;
}


int main()
{
	//yyj("A");
	cin>>n;
	for (llg i=1;i<=26;i++) ma[i]=0x7fffffff;
	for (llg i=1;i<=n;i++)
	{
		memset(c,0,sizeof(c));
		scanf("%s",s[i]+1);
		len[i]=strlen(s[i]+1);
		for (llg j=1;j<=len[i];j++) c[s[i][j]-'a'+1]++;
		for (llg j=1;j<=26;j++) ma[j]=min(ma[j],c[j]);
	}
	for (llg j=1;j<=26;j++)
		for (llg i=1;i<=ma[j];i++)
			cout<<(char)('a'+j-1);
	printf("%s",ans);
	return 0;
}


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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> f(n,0);
    rep(i,n){
        rep(j,10){
            int a; cin >> a;
            f[i] += (a<<j);
        }
    }
    ll p[n][11];
    rep(i,n) rep(j,11) cin >> p[i][j];
    ll ans = -10000000000;
    for(int bit = 1; bit < (1<<10); ++bit){
        ll tmp = 0LL;
        rep(i,n){
            int con = __builtin_popcount(bit & f[i]);
            tmp += p[i][con];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

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

static const int INFTY = 2000000000;
static const int MAX_N = 500000;
static int L[MAX_N / 2 + 2], R[MAX_N / 2 + 2];
static int cnt = 0;

void merge(int A[], int left, int mid, int right) {
    auto n1 = mid - left;
    auto n2 = right - mid;
    auto i = 0;

    for (i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }

    L[n1] = INFTY;
    R[n2] = INFTY;

    i = 0;
    auto j = 0;

    for (int k = left; k < right; k++) {
        cnt += 1;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i += 1;
        } else {
            A[k] = R[j];
            j += 1;
        }
    }
}

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

int main() {

    int A[MAX_N], N, i = 0;
    cin >> N;
    for(i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    mergeSort(A, 0, N);

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

    return 0;
}



Measured memory_bytes: 6908
using System;
using System.Linq;
using System.Collections.Generic;


namespace ABC162
{
    class B
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            long sum = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i % 3 != 0 && i % 5 != 0) sum += i;
            }

            Console.WriteLine(sum);
        }
    }
}



Measured memory_bytes: 27540
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        var hw = Console.ReadLine().Split()
            .Select(x => long.Parse(x))
            .ToArray();

        if (hw.Any(x => x % 3 == 0))
        {
            Console.WriteLine(0);
            return;
        }

        var s = hw[0] * hw[1];
        Func<long[], IEnumerable<long>> q = _hw =>
            from hh in Enumerable.Range(1, (int)_hw[1] - 1)
            let sa = _hw[0] * hh
            from rect in new[] 
                { new[] { _hw[0], _hw[1] - hh }
                , new[] { _hw[1] - hh, _hw[0] }
                }
            let sb = rect[0] / 2 * rect[1]
            let ss = new[] { sa, sb, s - sa - sb }
            select ss.Max() - ss.Min();

        Console.WriteLine(Math.Min(q(hw).Min(), q(hw.Reverse().ToArray()).Min()));
    }
}


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

int main() {
    //input
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i = 0;i<m;i++){
        cin >> b.at(i);
    }
    vector<vector<int>> a(n,vector<int>(m,0));
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            cin >> a.at(i).at(j);
        }
    }
    int count = 0;
    for(int i = 0;i<n;i++){
        int sum = 0;
        for(int j = 0;j<m;j++){
            sum += a.at(i).at(j) * b.at(j);
        }
        sum += c;
        if(sum > 0)count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

#define INF 1e9

int n, m, x;
int main() {
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, 0 ,n){
		cin >> c[i];
		rep(j, 0 ,m) cin >> a[i][j];
	}
	
	
	int ans =INF;
	rep(bit, 0, 1<<n){
		vector<int> skill(m);
		int nc = 0;
		rep(i, 0, n){	
			if(bit>>i & 1){
				rep(k, 0, m) skill[k] += a [i][k];
				nc += c[i];
			}
		}
		bool overedX = true;
		rep(i, 0, m) if(skill[i] < x) overedX = false;
		if(overedX) ans = min(ans, nc);
	}
	
	
	if(ans == INF) ans = -1;
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3160
import itertools
n,m,R=map(int,input().split())
r=list(map(int,input().split()))
g=[[100000*200+1]*n for i in range(n)]
for _ in range(m):
    a,b,c=map(int,input().split())
    g[a-1][b-1]=g[b-1][a-1]=c
for k in range(n):
    for i in range(n):
        for j in range(n):
            g[i][j]=min(g[i][j],g[i][k]+g[k][j])
print(min(
    sum(g[s[i-1]-1][s[i]-1] for i in range(1,R))
    for s in itertools.permutations(r)))

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

int memo[3000][2]={};

vector<int> back[3000];
vector<int> toward[3000];

void myb(int now)
{
	for (auto i = back[now].begin(); i != back[now].end(); ++i)
	{
		if (memo[*i][0]==0)
		{
			memo[*i][0]=1;
			myb(*i);
		}
	}
}
void myt(int now)
{
	for (auto i = toward[now].begin(); i != toward[now].end(); ++i)
	{
		if (memo[*i][1]==0)
		{
			memo[*i][1]=1;
			myt(*i);
		}
	}
}

struct edge
{
	int from;
	int to;
	long long cost;
};

int main(int argc, char const *argv[])
{
	int n,m,p;
	cin>>n>>m>>p;
	edge abc[m];
	for (int i = 0; i < m; ++i)
	{
		cin>>abc[i].from>>abc[i].to>>abc[i].cost;
		--abc[i].from;
		--abc[i].to;
		abc[i].cost*=-1;
		abc[i].cost+=p;
		back[abc[i].to].emplace_back(abc[i].from);
		toward[abc[i].from].emplace_back(abc[i].to);
	}
	memo[n-1][0]=1;
	myb(n-1);
	memo[0][1]=1;
	myt(0);
	long long dist[n];
	for (int i = 0; i < n; ++i)
	{
		dist[i]=INT_MAX;
	}
	dist[0]=0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if (memo[abc[j].to][0]==1&&memo[abc[j].from][0]==1&&memo[abc[j].to][1]==1&&memo[abc[j].from][1]==1&&dist[abc[j].to]>dist[abc[j].from]+abc[j].cost)
			{
				dist[abc[j].to]=dist[abc[j].from]+abc[j].cost;
				if (i==n-1&&memo[abc[j].to][0]==1&&memo[abc[j].to][1]==1)
				{
					cout<<"-1\n";
					return 0;
				}
			}
		}
	}
	if (dist[n-1]>0LL)
	{
		dist[n-1]=0LL;
	}
	cout<<-1LL*dist[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

ll k;
cin>>k;
string s,ans;
cin>>s;
for(int i=0;i<s.size();i++)
{
    ans+=s[i];
    if(i+1==k&&i!=s.size()-1)
    {
        ans+="...";
        break;
    }
}
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int K,T;
	cin >> K >> T;
	vector<int> A(T);
	for(int i =0; i < T; i++) cin >> A[i];
	sort(begin(A),end(A));
	int sum =0;
	for(int i =0; i < T-1; i++) sum +=A[i];
	if(sum+1 >= A[T-1]) cout << "0\n";
	else cout << A[T-1]-sum-1 << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

const ll m = 1000000007;
int main() {
    int n;
    ll s = 0, ans = 0;
    cin >> n;
    vector<ll>a(n);
    rep(i, n) {
        cin >> a[i];
        s += a[i];
    }
    //s = s % m;
    rep(i, n) {
        s = s - a[i];
        // s = s % m;
        ll tmp = s % m;
        ans += a[i] * tmp;
        ans = ans % m;
    }
    ans = ans % m;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4360
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <string>
#include <functional>
#include <map>
#include <cstring>
#include <set>
#include <cmath>
using namespace std;

using ii = pair < int , int >;
using ti = tuple < int ,int ,int >;
using lint = long long;
using ll = pair < lint , lint >;

int main(){
	//freopen("in.txt","r",stdin);
	int n;
	scanf("%d",&n);
	vector < int > v;
	for(int i=0;i<n;i++){
		int x;scanf("%d",&x);
		v.push_back(x);
	}
	sort(v.rbegin(),v.rend());
	int q=0,w=0;
	for(int i=0;i<n;i++){
		if(i&1){
			w+=v[i];
		}
		else{
			q+=v[i];
		}
	}
	printf("%d\n",abs(w-q));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}

void solve(){
    ll i,j,k,l,n,m,x,y,z,r;
	cin>>n>>k;
	
	vll a(n+1);
	for(i=0;i<k;i++){
		cin>>x;
		for(j=0;j<x;j++){
			cin>>y;
			a[y]++;
		}
	}
	ll ans=0;
	for(i=1;i<=n;i++){
		if(!a[i])ans++;
	}
	cout<<ans<<endl;
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

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

//単純に探す => O(n)
//1. まず，rotated pointを見つける (最小値を二分探索する．)
/*
一番左の要素を取り出す．
*/
using namespace std;

typedef long long ll ;

ll max(ll a, ll b) { return a < b ? b : a; }


int main() {
  string s;
  cin >> s;
  
  int len = s.size();
  
  ll sum = 0;
  for(int bit = 0; bit < 1 << (len - 1); ++bit) {
    ll next = 0;
    for(int i = 0; i<(int)s.size() - 1; ++i) {
      next += (s.at(i) - '0');
      if(bit & (1 << i)) {
        sum += next;
        next = 0;
      } else {
        next *= 10;
      }
    }
    sum += next + s.back() - '0';
  }
  
  cout << sum << endl;
  
  return 0; 
}


Measured memory_bytes: 256
def solve():
    N, *T = map(int, open(0).read().split())

    bottleneck = (0, 10**15)
    for i, t in enumerate(T):
        if t <= bottleneck[1]:
            bottleneck = (i, t)
    
    if N % bottleneck[1] == 0:
        print(bottleneck[0] + N // bottleneck[1] + 4 - bottleneck[0])
    else:
        print(bottleneck[0] + N // bottleneck[1] + 1 + 4 - bottleneck[0])


if __name__ == '__main__':
    solve()

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner (System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        if(s>w) System.out.println("safe");
        else System.out.println("unsafe");
    }
}

Measured memory_bytes: 35724
#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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];

  map<ll, ll> ma, pa;
  rep(i, n){
    pa[ a[i]+i+1 ]++;
    ma[ i+1-a[i] ]++;
  }

  ll result = 0;
  for(auto p: pa){
    result += p.second*ma[p.first];
  }
  cout<<result<<endl;

  return 0;
}

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

using namespace std;
typedef long long ll;
int n,x;char op;ll dp[3],nxt[3];

int main()
{
	scanf("%d%d",&n,&dp[0]);
	dp[1]=dp[2]=-1ll<<60;
	for(int i=1;i<n;i++)
	{
		scanf(" %c%d",&op,&x);
		if(op=='-') x=-x;
		nxt[0]=dp[0]+x,nxt[1]=dp[1]-x,nxt[2]=dp[2]+x;
		dp[0]=max(nxt[0],max(nxt[1],nxt[2]));
		if(op=='+') dp[1]=max(nxt[1],nxt[2]),dp[2]=nxt[2];
		else dp[1]=dp[0],dp[2]=max(nxt[1],nxt[2]);
	}
	printf("%lld",dp[0]);
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let n: usize = input.next();
    let m: usize = input.next();
    let mut e: Vec<Vec<usize>> = vec![Vec::new();n];
    for _ in 0..m {
        let a: usize = input.next::<usize>() - 1;
        let b: usize = input.next::<usize>() - 1;
        e[a].push(b);
        e[b].push(a);
    }
    let mut u: Vec<bool> = vec![true;n];
    let mut x: VecDeque<usize> = VecDeque::new();
    let mut i: usize = 0;
    x.push_back(i);
    loop {
        u[i] = false;
        let n = e[i].iter().filter(|&&i| u[i]).last();
        if n.is_some() {
            i = *n.unwrap();
            x.push_back(i);
        } else {
            break;
        }
    }
    i = 0;
    loop {
        u[i] = false;
        let n = e[i].iter().filter(|&&i| u[i]).last();
        if n.is_some() {
            i = *n.unwrap();
            x.push_front(i);
        } else {
            break;
        }
    }
    println!("{}", x.len());
    for v in x {
        print!(" {}", v + 1);
    }
    println!("");
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 13052
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>
using namespace std;
 
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;
 
int main() {
	// random_device rnd;
	// mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
	vector<int> num (4);
	for(int i = 0;i < 4;i++){
		cin >> num[i];
	}
	SORT(num)
	if(num[0] == 1 && num[1] == 4 && num[2] == 7 && num[3] == 9){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int n;
    cin >> n;
    char s[n];
    rep(i, n) { cin >> s[i]; }

    // 処理
    int cntP = 0;
    int cntW = 0;
    int cntG = 0;
    int cntY = 0;
    rep(i, n) {
        if (s[i] == 'P') cntP = 1;
        if (s[i] == 'W') cntW = 1;
        if (s[i] == 'G') cntG = 1;
        if (s[i] == 'Y') cntY = 1;
    }
    // 出力
    int cnt = cntP + cntW + cntG + cntY;
    cout << (cnt == 3 ? "Three" : "Four") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}

int N;
string S1, S2;

ll res = 1;
ll D = 1e9+7;

ll solve(int k, int pattern) {
    if (k >= N) return 1;
    if (S1[k] == S2[k]) {
        if (!pattern) {
            return 2 * solve(k+1,0) % D;
        } else {
            return solve(k+1,0) % D;
        }
    } else {
        if (!pattern) {
            return 2 * solve(k+2,1) % D;
        } return 3 * solve(k+2,1) % D;
    }
}

int main() {
    cin >> N;
    cin >> S1 >> S2;

    if (S1[0] == S2[0]) {
        res = 3 * solve(1,0) % D;
    } else {
        res = 6 * solve(2,1) % D;
    }
    cout << res << endl;


    
}


Measured memory_bytes: 256
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n, k):
    if n % k == 0:
        return 0
    else:
        md = n % k
        dv = n / k
        return md



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    # S = parsed_lines[1][0]
    # return n, k, S
    return n, k


if not do_submit:
    n, k = input_parse("""
    3 2
    """)
    print(sol(n, k))

    n, k = input_parse("""
    3 1
    """)
    print(sol(n, k))
    n, k = input_parse("""
    8 5
    """)
    print(sol(n, k))

else:
    n, k= list(map(int, input().split()))
    # S = input().split()
    # print(sol(n, k, S))
    #n = int(input().strip())
    # S = input().strip()
    print(sol(n, k))



Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define per(i,a,n) for(int i=a;i<=n;i++)
#define ls l+mid>>1
#define rs mid+1+r>>1
using namespace std;
typedef  long long ll;
int vp[10010];
char s[200010];
int main()
{
  int n,p;
  cin>>n>>p;
  ll ans=0;
  scanf("%s",s+1);
  ll kk=1,an=0;
  vp[0]=1;
  if(p==2||p==5){
    for(int i=n;i>=1;i--){
        if((s[i]-'0')%p==0)
            ans+=i;
    }
    cout<<ans<<endl;
  }
  else{
    for(int i=n;i>=1;i--){
         an=an+((s[i]-'0')*kk)%p;
         an%=p;
         ans+=vp[an];
         vp[an]++;
         kk=kk*10%p;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int X;
	cin >> X;
	if (X == 7 || X == 5 || X == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


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

int main(){
    int n;
    while( cin >> n , n ){
        int a[7] = {0}, age;

        for(int i=0 ; i < n ; i++ ){
            cin >> age;
            if( age >= 60 ) 
                age = 60;
            a[age/10]++;
        }
        for(int i=0 ; i < 7 ; i++ ){
            cout << a[i] << endl;
        }
    }
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    ll n; cin >> n;
    cout << n*(n-1)/2 << endl;
}

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

int main(){
  char s[111];
  scanf("%s",s);
  int i,ans=0;
  for(i=0;i<=strlen(s);i++){
    if(s[i]=='C') break;
  }
  for(i;i<strlen(s);i++){
    if(s[i]=='F') ans++;
  }
  puts(ans?"Yes":"No");
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
int n,m,x;
cin>>n>>m>>x;
int a[m],count=0;
rep(i,m){
cin>>a[i];
if(a[i]<x)
count++;
}
cout<<min(count,m-count)<<endl;


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;


namespace B_007_54
{
    internal class Program
    {
        private static void Main(string[] args)
        {

            new Logic_B().Start();//

        }

        public class Logic_B
        {
            public void Start()
            {
                var hw = Console.ReadLine().Split(' ');
                var ALength = Convert.ToInt32(hw[0]);
                var BLength = Convert.ToInt32(hw[1]);

                var AImage = new List<string>();
                for (int i = 0; i < ALength; i++)
                {
                    AImage.Add(Console.ReadLine());
                }

                var BImage = new List<string>();
                for (int i = 0; i < BLength; i++)
                {
                    BImage.Add(Console.ReadLine());
                }

                for (int i = 0; i < AImage.Count; i++)
                {
                    for (int j = 0; j < AImage.Count; j++)
                    {
                        var valid = false;
                        for (int m = 0; m < BImage.Count; m++)
                        {
                            for (int n = 0; n < BImage.Count; n++)
                            {
                                if (i + m >= AImage.Count || j + n >= AImage.Count)
                                {
                                    valid = false;
                                    break;
                                }
                                if (AImage[i + m][j + n] == BImage[m][n])
                                {
                                    valid = true;
                                }
                                else
                                {
                                    valid = false;
                                    break;
                                }
                            }
                            if (!valid)
                            {
                                break;
                            }
                        }
                        if (valid)
                        {
                            Console.WriteLine("Yes");
                            return;
                        }
                    }
                }
                Console.WriteLine("No");
            }
        }

    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	int N;
	int[]a;
	void solve(){
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		a=new int[N];
		int min=1000;
		int max=0;
		
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
			min=Math.min(min, a[i]);
			max=Math.max(max, a[i]);
		}
		
		System.out.println(max-min);
	}

}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
int d[201][201], n, m, R, r[10], id[10];

int main()
{
	sf("%d%d%d",&n,&m,&R);
	fo(i,1,R) sf("%d",&r[i]);
	memset(d,0x3f,sizeof(d));
	fo(i,1,m)	
	{
		int a, b, c;
		sf("%d%d%d",&a,&b,&c);
		d[a][b] = d[b][a] = c;
	}
	fo(k,1,n) fo(i,1,n) fo(j,1,n) if(i!=j&&j!=k&&i!=k) gmin(d[i][j],d[i][k]+d[k][j]);
	fo(i,1,R) id[i] = i;
	int cur = 0, ans = 0x3f3f3f3f;
	do
	{
		cur = 0;
		fo(i,1,R-1) cur += d[r[id[i]]][r[id[i+1]]];
		gmin(ans,cur);
	}while(next_permutation(id+1,id+R+1));
	pf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
N,M = map(int,input().split())
H = list(map(int,input().split()))
Route = []
Check = [""] * N


for i in range(M):
    Route.append(list(map(int,input().split())))
    
Route.sort()


for i in range(M):
    
    if H[Route[i][0] - 1] < H[Route[i][1] - 1]:
        Check[Route[i][0] - 1] = "Bad"
    
    elif H[Route[i][0] - 1] > H[Route[i][1] - 1]:
        Check[Route[i][1] - 1] = "Bad"
        
    else:
        Check[Route[i][0] - 1] = "Bad"
        Check[Route[i][1] - 1] = "Bad"

count = 0

for i in range(N):
    if Check[i] == '':
        count += 1
        
print(count)

Measured memory_bytes: 32524
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;


int main(){
  int n, tmp = 0;
  int ans = 0;
  cin >> n;
  vector<int> h(n);

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

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

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=10000000001;

ll number(ll mid,vector<ll>& a){
  ll num=0;
  rep(i,a.size()){
    ll M=mid-a[i];
    num+=(ll)(a.end()-lower_bound(ALL(a),M));
  }
  return num;
}

int main(){
  ll n,m; cin>>n>>m;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  sort(ALL(a));

  ll l=0;
  ll r=LMAX;
  while(r-l>1){
    ll mid=(r+l)/2;
    ll num=number(mid,a);
    // cout<<num<<endl<<" l "<<l<<" r "<<r<<" mid "<<mid<<endl;
    if(num<m) r=mid;
    else l=mid;
  }
  // cout<<l<<endl;
  vector<ll> b(n);
  rep(i,n){
    if(i==0) b[i]=a[i];
    else b[i]=a[i]+b[i-1];
  }
  ll sum=0;
  ll c=0;
  rep(i,n){
    auto itr=upper_bound(ALL(a),l-a[i]);
    int id=a.end()-itr;
    // cout<<"id "<<id<<endl;
    c+=id;
    if(id==n)
    sum+=a[i]*id+b[n-1];
    else{
      sum+=a[i]*id+(b[n-1]-b[n-1-id]);
    }
    // cout<<sum<<endl;
  }
  c=m-c;
  sum+=c*l;
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int cnt[4]={0};
  int i;
  for(i=0;i<3;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    cnt[a-1]++;
    cnt[b-1]++;
  }
  for(i=0;i<4;i++){
    if(cnt[i]==3){
      puts("NO");
      return;
    }
  }
  puts("YES");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

char s[14];

int main()
{
	scanf("%s",s);
	for (int i=0;i<4;i++) putchar(s[i]);
	putchar(' ');
	for (int i=4;i<12;i++) putchar(s[i]);
	puts("");
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }

  int result=0;
  rep(i,n)if(a[a[i]]==i)result++;
  cout<<result/2;

  return 0;
}

Measured memory_bytes: 640
N = int(input())
sec = [1,-2]
for i in range(2,32):
  if i%2 == 0:
    sec.append(sec[i-2]+pow(2,i))
  else:
    sec.append(sec[i-2]-pow(2,i))
#print(sec)
sec.reverse()
sec.append(0)
sec.append(0)
ans = []
for i in range(32):
  temp = 0
  if N >0 and sec[i] >0:
    if N>sec[i+2]:
      temp = 1
      #print(N,pow(-2,31-i))
      N -= pow(-2,31-i)
  elif N<0 and sec[i] <0:
    if N < sec[i+2]:
      temp = 1
      #print(N,pow(-2,31-i))
      N -= pow(-2,31-i)      
  ans.append(str(temp))

T = "".join(ans)
print(int(T))

Measured memory_bytes: 3064
// C - Stonens
// https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c?lang=en

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll s;

int main() {
  scanf("%lld", &s);

  ll x1=0, y1=0; // fixed
  ll x2, y2, x3, y3;

  x2=pow(10,9); // why?
  y2=1; // why?

  // S = |x2*y3 - y2*x3|
  x3=(x2-s%x2)%x2;
  y3=(s+x3)/x2;

  printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);
}


Measured memory_bytes: 256
#SUN,MON,TUE,WED,THU,FRI,SAT
s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)



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


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int g(int x) {
    int ret = 0;
    if (x % 4 == 1 || x % 4 == 2)ret++;
    for (int i = 1; i < 60; i++)
        if ((x & (1LL << i)) && !(x & 1))ret += (1LL << i);
    return ret;
}

signed main() {
    int A, B;
    cin >> A >> B;
    cout << (g(A) ^ A ^ g(B)) << endl;
}

Measured memory_bytes: 256
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int n,k;
int a[105];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int ans=0,i;
	for(i=1;i<=n;i++){
		if(a[i]<=k){
			k-=a[i];
			++ans;
		}else break;
	}
	if(i==n+1&&k)--ans;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3)
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cstring>
#include <iostream>
#include <algorithm>
#define maxn 100010
// #define int long long
using namespace std;
void write(int x){if(x<0){putchar('-');x=-x;}if(x>9) write(x/10);putchar(x%10+'0');}
int read(){int d=0,w=1;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')
w=-1;for(;c>='0'&&c<='9';c=getchar())d=(d<<1)+(d<<3)+c-48;return d*w;}
void wln(int x){write(x);putchar('\n');}
void wrs(int x){write(x);putchar(' ');}
int n,a[maxn],cnt;
signed main()
{
	// freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;a[i++]=read());
	sort(a+1,a+n+1);
	if(a[n]==a[1])
	{
		if(a[1]==n-1) puts("Yes");
			else puts(n>>1>=a[1]?"Yes":"No");
		return 0;
	}
	if(a[n]-a[1]>1||a[n]!=a[n-1])
	{
		puts("No");
		return 0;
	}
	for(;a[cnt+1]==a[1];cnt++);
	puts(cnt+(n-cnt>>1)>=a[n]&&cnt<a[n]?"Yes":"No");
	return 0;
}


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

int main(){
long long unsigned int n,m,i,j;
cin>>n>>m;
long long unsigned int broken[n+1],dp[n+1],modu=1000000007;
for(i=0;i<n+1;i++)broken[i]=false;
for(i=0;i<m;i++){cin>>j;broken[j]=true;}
dp[0]=1;
for(i=1;i<=n;i++)
{
	if(broken[i])dp[i]=0;
	else
	{
	if(i==1)
	dp[i]=(dp[i-1])%modu;
	else
	dp[i]=(dp[i-1]+dp[i-2])%modu;
	}
}
cout<<dp[n];
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std; using P=pair<int,int>; using ll=long long; ll m=1e9+7;

int main() {
  int n; cin>>n;
  ll a[n],b[n]; for(int i=0;i<n;i++) cin>>a[i]>>b[i];
  ll ys=1e18, sm=0; bool all=true;
  for(int i=0;i<n;i++) {
    sm+=a[i];
    if (a[i]>b[i]) ys=min(ys,b[i]);
    if (a[i]!=b[i]) all=false;
  }
  if (all) cout<<"0"<<endl;
  else cout<<sm-ys<<endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
int light[20]={0},a[20];
vector<int> v[20];
signed main(){
  fast;
  int n,m,ans=0,k,x;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
  	 cin>>k;
  	 for(int j=0;j<k;j++){
  	 	cin>>x;
  	 	v[x-1].pb(i);
  	 }
  }
  for(int i=1;i<=m;i++) cin>>a[i];
  for(int mask=0;mask<(1<<n);mask++){
  	  memset(light , 0 , sizeof(light));
      for(int i=0;i<n;i++){
      	if((mask&(1<<i))){
      		for(int j=0;j<v[i].size();j++){
               light[v[i][j]]++;
      		}
      	}
      }
      int f = 1;
      for(int i=1;i<=m;i++){
      	if(light[i]%2==a[i]) continue;
      	else { f = 0 ; break;}
      }

        ans+=f;
       

      
      	
  }
  cout<<ans<<endl;
}
  


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
 
int main() {
  int n;
  cin >> n;
  vector<int>a(3*n);
  rep(i,3*n) cin>>a[i];
  sort(a.begin(),a.end(),greater<int>());
  ll ans=0;
  rep(i,n){
    ans+=a[2*i+1];
  }
  cout<<ans<<endl;
}
  



Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main (int argc, char const* argv[]) {
  int ar[11][11], N, get, sum;
  while (true) {
    // load
    cin >> N;
    if (N == 0) break;
    memset(ar, 0, sizeof ar);
    for (int i = 0; i < N; i += 1) {
      for (int j = 0; j < N; j += 1) {
        cin >> get;
        ar[i][j] = get;
      }
    }
    // calc
    for (int i = 0; i < N; i += 1) {
      int sum_h = 0, sum_v = 0;
      for (int j = 0; j < N; j += 1) {
        sum_h += ar[i][j];
        sum_v += ar[j][i];
      }
      ar[i][N] = sum_h;
      ar[N][i] = sum_v;
    }
    // sum
    sum = 0;
    for (int i=0;i<N;i++) sum += ar[i][N];
    ar[N][N] = sum;
    // print
    for (int i = 0; i <= N; i += 1) {
      for (int j = 0; j <= N; j += 1) {
        printf("%5d",ar[i][j]);
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include "cstdio"
#include "algorithm"
#include "cmath"
using namespace std;
const int MAXN=10000+10;
int  n,m;
struct node{
    int a,b; double vi;
}edge[MAXN*MAXN];
double x[MAXN];
double y[MAXN];
int F[MAXN];
int Found(int x){
    if(F[x]==x) return x;
    return F[x]=Found(F[x]);
}
bool Union(int x,int y){
    int xn=Found(x);
    int yn=Found(y);
    if(xn!=yn){
        F[yn]=xn;
        return true;
    }
    return false;
    
}
double dis(double x1,double y1,double x2,double y2){
    return sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
}
bool cmp(node a,node b){
    return a.vi>b.vi;
}
int main(){
    scanf("%d %d",&n,&m);
    double sum=0;
    for(int i=1;i<=n;i++){
        scanf("%lf %lf",&x[i],&y[i]);
    }
    for(int i=1;i<=m;i++){
        int a,b; scanf("%d %d",&a,&b);
        edge[i].a=a; edge[i].b=b;
        edge[i].vi=dis(x[a],y[a],x[b],y[b]);
        sum+=edge[i].vi;
    }
    for(int i=1;i<=n;i++)
        F[i]=i;
    sort(edge+1,edge+1+m,cmp);
    for(int i=1;i<=m;i++){
        if(Union(edge[i].a,edge[i].b)){
            sum-=edge[i].vi;
        }
    }
    printf("%.3lf\n",sum);
    return 0;
}

Measured memory_bytes: 3408
N = int(input())
s = [input() for _ in range(N)]

ret = 0
a, b, c = 0, 0, 0
for i in range(N) :
  ret += s[i].count('AB')
  if s[i][-1] == 'A' and s[i][0] == 'B' :
    c += 1
  elif s[i][-1] == 'A' :
    a += 1
  elif s[i][0] == 'B' :
    b += 1

if c >= 2 :
  ret += c - 1
  c = 1
  
if c > 0 and a > 0 :
  a -= 1
  ret += 1
if c > 0 and b > 0 :
  b -= 1
  ret += 1
  
ret += min(a, b)
print(ret)

Measured memory_bytes: 44504