akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N, M; cin >> N >> M;
    vector<int> a(M);
    vector<int> b(M);
    rep(i, M){
        cin >> a[i] >> b[i];
    }
    UnionFind U(N+1);

    int ans = 0;
    rep(i, M){
        U.init(N+1);
        rep(j, M){
            if(j == i)continue;
            int x = a[j];
            int y = b[j];
            U.merge(x, y);
        }
        bool ok = true;
        for (int k = 1; k <= N; k++){
            for (int l = k; l <= N; l++){
                if(!U.issame(k, l)){
                    ok = false;
                }
            }
        }
        if(!ok){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define FORR(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define MAXIMIZE(a, b) (a) = max((a),(b))
#define MINIMIZE(a, b) (a) = min((a),(b))

using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<int, Pii> iPii;
int N,D,Q;
vector<ll> Ds;
vector<int> Qs;
vector<ll> reachableMin;
vector<ll> dps;
int main() {
  cin >> N >> D;
  REP(i, N) {
    ll d;
    cin >> d;
    Ds.push_back(d);
  }
  cin >> Q;
  REP(i , Q) {
    int q;
    cin >> q;--q;
    Qs.push_back(q);
  }
  ll prev=0;
  FORR(it, Ds) {
    ll newVal=prev;
    if (*it <= prev*2 + 1) {
      newVal+=*it;
    }
    reachableMin.push_back(newVal);
    prev=newVal;
  }
  reverse(ALL(reachableMin));

  ll cur=D;
  dps.push_back(cur);
  FOR(it, Ds) {
    if (abs(cur-*it)<cur) {
      cur = abs(cur-*it);
    }
    dps.push_back(cur);
  }

  FOR(it, Qs) {
    ll pos=dps[*it];
    if (*it!=N-1) {
      ll m = reachableMin[*it + 1];
      if (pos<=m) {
        cout << "NO" << endl;
      } else {
        cout << "YES" << endl;
      }
    } else {
      if (pos!=0) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }

  }

  return 0;
}


Measured memory_bytes: 19692
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();
const unsigned long long int ULLINF = numeric_limits<unsigned long long int>::max();

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

    LL k;
    cin >> k;
    VLL v(1000001,0);

    v[1] = 7%k;
    for (LL i=2; i <= k; i++) {
        v[i] = (v[i-1] * 10 + 7) % k;
    }

    for (LL i=1; i <= k; i++) {
        if (v[i]==0) {
            cout << i << endl;
            return 0;
        }
    }
    
    cout << "-1" << endl;

    return 0;
}


Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

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

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



int N, K;
vector<int> d;
vector<vector<int>>A;
void input() {
	cin >> N >> K;
	d.resize(K);
	A.resize(K, vector<int>());
	rep(i, 0, K) {
		cin >> d[i];
		A[i].resize(d[i]);
		rep(j, 0, d[i]) {
			cin >> A[i][j];
		}
	}
	
}

void solve() {
	int ans = 0;
	rep(i, 1, N + 1) {
		bool have = false;
		fore(v, A) {
			fore(p, v) {
				if (p == i)have = true;
			}
		}
		if (have != true)ans++;
	}
	cout << ans << endl;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	input();
	solve();
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    if (s == "ABC")
    {
        cout << "ARC\n";
    }
    else
    {
        cout << "ABC\n";
    }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<vector<vector<bool>>> dp(N+1, vector<vector<bool>>(4, vector<bool>(1000, false)));
    dp[0][0][0] = true;
    for(int i=0; i<N; i++)
    {
        int num = S[i] - '0';
        for(int j=0; j<4; j++)
        {
            for(int k=0; k<1000; k++)
            {
                if(j<3 && k%10 == num)
                {
                    dp[i+1][j+1][k] = dp[i][j][k/10];
                }
                dp[i+1][j][k] = (dp[i+1][j][k] || dp[i][j][k]);
            }
        }
    }
    int ans = 0;
    for(int i=0; i<1000; i++)
    {
        if(dp[N][3][i])
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25872
#include <iostream>
typedef long long ll;
using namespace std;
int main(){
    ll n;
    cin >> n;
    ll ans =0;
    int i= 1;
    while( (ll)i * i + 2*i <= n){
           if(n % i == 0){
                ans += n / i - 1;
           }
           i++;
    }
    cout << ans;
}


Measured memory_bytes: 256
/***************************************************************\
 * bitter --
 *
 * Author: Cobalt Sato
 *
 * Purpose:
 *
 * Usage:
 *
 * Repository:
 *
 * Reference:
 *
 * File formats:
 *
 * Restrictions:
 *
 * Error handling:
 *
 * Warning:
 *
 * Notes:
 *
\***************************************************************/
#include <iostream>
#include <cassert>
#include <string>
#include <bits/stdc++.h>

using namespace std;
int main()
{
  vector<int> vec = {};
  vector<int>::iterator it;
  int nuts;
  int gram;
  int a;
  int total = 0;
  int sum = 0;
  int count = 0;
  cin >> nuts;
  cin >> gram;

  it = vec.begin();
  for (int i = 0; i < nuts; ++i){
    cin >> a;
    sum += a;
    it = vec.insert(it,a);
  }
  sort(vec.begin(),vec.end());


  if (sum <= gram - total){
    total += sum;
    count += nuts; 
  } 
  else{
    for (int i = 0; i < nuts; ++i){
      if ((gram - total) >= vec[i]){
        total += vec[i];
        ++count; 
        cout << total << endl;
      }
      else {
        break;
      }
    }
  }
  while (true){
    if ((gram - total) >= vec[0]){
        total += vec[0];
        ++count; 
      }
      else {
        break;
      }
    }
  cout << count << endl;
  return (0);
}






Measured memory_bytes: 256
import sys

for line in sys.stdin:
	[p, q] = line.split();
	a = float(p);
	b = float(q);
	
	if (a < 35.5) & (b < 71.0):
		print('AAA');
	elif (a < 37.5) & (b < 77.0):
		print('AA');
	elif (a < 40.0) & (b < 83.0):
		print('A');
	elif (a < 43.0) & (b < 89.0):
		print('B');
	elif (a < 50.0) & (b < 105.0):
		print('C');
	elif (a < 55.0) & (b < 116.0):
		print('D');
	elif (a < 70.0) & (b < 148.0):
		print('E');
	else:
		print('NA');

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

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

    vector<int>l(N);

    for(int i=0; i<N; i++) cin >> l[i];

    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());

    cout << accumulate(l.begin(), next(l.begin(), K), 0) << endl;



    return 0;
}

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

int main(){
    int i,n,buf;
    int min,max;
    long int sum;
    std::vector<int> a;

    std::cin>>n;

    for(i=0;i<n;i++){
        std::cin>>buf;
        a.push_back(buf);
    }

    min=1000000;
    max=-1000000;
    sum=0;
    for(i=0;i<n;i++){
        sum=sum+a[i];
        if(a[i]>max){
            max=a[i];
        }
        if(a[i]<min){
            min=a[i];
        }
    }
    std::cout<<min<<" "<<max<<" "<<sum<<std::endl;

    return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e9

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; }

typedef long long ll;

using namespace std;

int main(int argc, char const *argv[])
{
    int A, P;
    cin >> A >> P;

    P += A * 3;

    cout << P / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    S = input().strip()
    T = input().strip()
    return S, T


def solve(S, T):
    mincost = 1000000
    for i in range(len(S)-len(T)+1):
        j = i + len(T)
        cost = 0
        for s, t in zip(S[i:j], T):
            if s != t:
                cost += 1
        mincost = min(mincost, cost)
    return mincost


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9152
li = list(input())
counter = 0
counter1 = 0
import copy
lii = copy.deepcopy(li)

for i in range(len(li)-1):
    if li[i] == li[i+1] and li[i+1] == "0":
         li[i+1] = "1"
         counter += 1
    if li[i] == li[i+1] and li[i+1] == "1":
         li[i+1] = "0"
         counter += 1
if lii[0] == "0":
    lii[0] == "1"
else:
    lii[0] == "0"
for i in range(len(lii)-1):
    if lii[i] == lii[i+1] and lii[i+1] == "0":
         lii[i+1] = "1"
         counter1 += 1
    if lii[i] == lii[i+1] and lii[i+1] == "1":
         lii[i+1] = "0"
         counter1 += 1
print(max(counter1,counter))


Measured memory_bytes: 5156
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

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

    vector<ll> vv(n,0);

    vv[0]=v[0]+(k-v[n-1]);

    rep(i,n-1){
     vv[i+1]  = v[i+1]-v[i];
    }
//    rep(i,n-1){
//        cout<<vv[i]<<endl;
//    }

    sort(vv.begin(),vv.end());
    ll ans = 0;
    rep(i,n-1){
        ans+=vv[i];
    }
    cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>//好办法iudsghyifgshui
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
#define iinf 0x3f3f3f3f3f3f3f3f
#define lowbit(x) x&(-x)
#define isdigit(ch) (ch>='0'&&ch<='9')
#define P (ll)(pow(10,9)+7)
using namespace std;
ll n,k,f[10001];
inline ll qpow(reg ll a,reg int x)
{
    if(x<0)return 1;
    reg ll s=1;
    while(x)
	{
		if(x&1)
		{
			s*=a;
			s%=P;
		}
		a*=a;
		a%=P;
		x>>=1;
	}
    return s;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    f[0]=1;
    for(reg int i=1;i<n;i++)
    {
		for(reg int j=i;j;j--)
		f[j]=(f[j+1]+f[j-1])%P;
		f[0]=f[1];
	}
    printf("%lld",f[n-k]*qpow(2,n-k-1)%P);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#include <cstring>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return 0;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}



/* Iterative Function to calculate (x^y)%p  
in O(log y) */
unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
long long modInverse(long long n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
 long long nCrModPFermat( long long n, 
                                 ll r, ll p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
     long long fac[n + 1]; 
    fac[0] = 1; 
    for (ll i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}


///target expert

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll s; cin>>s;
    ll ans=0; ll n=1;
    while(n*3<=s){
        ll s1= s-n*3;
        ans+= nCrModPFermat(s1+n-1,n-1,MAX);
        ans%=MAX;
        n++;
    }
    cout<<ans;
}



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

const int MAX_N=105;
int n;
int a[MAX_N][3];

int main()
{
	ios::sync_with_stdio(false);
	while(cin>>n){
		int xi,yi,hi=0;
		for(int i=0;i<n;++i)
		{
			cin>>a[i][0]>>a[i][1]>>a[i][2];
			if(!hi&&a[i][2]){
				xi=a[i][0];	yi=a[i][1];	hi=a[i][2];
			}
		}
		int x,y,h;
		bool boo=false;
		for(int i=0;i<=100&&!boo;++i)
		{
			for(int j=0;j<=100&&!boo;++j)
			{
				x=i;	y=j;
				h=hi+abs(x-xi)+abs(y-yi);
				boo=true;
				int hh;
				for(int k=0;k<n;++k)
				{
					hh=max(h-abs(x-a[k][0])-abs(y-a[k][1]),0);
					if(hh!=a[k][2]){
						boo=false;	break;
					}
				}
			}
		}
		cout<<x<<" "<<y<<" "<<h<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define MAX_R 11
#define MAX_C 10001

using namespace std;

int r, c;
int senbei[MAX_R][MAX_C];

int dfs(int d) {
  int ret = 0;
  if (d == r) {
    for (int i = 0; i < c; ++i) {
      int t = 0;
      for (int j = 0; j < r; ++j) {
        t += senbei[j][i];
      }
      ret += max(t, r - t);
    }
    return ret;
  }
  
  ret = dfs(d + 1);
  for (int i = 0; i < c; ++i) {
    senbei[d][i] = (senbei[d][i] + 1) % 2;
  }
  ret = max(ret, dfs(d + 1));
  for (int i = 0; i < c; ++i) {
    senbei[d][i] = (senbei[d][i] + 1) % 2;
  }
  return ret;
}

int main() {

  while (true) {
    scanf("%d %d", &r, &c);
    if (r == 0 && c == 0) break;
    
    for (int i = 0; i < r; ++i) {
      for (int j = 0; j < c; ++j) {
        scanf("%d", &senbei[i][j]);
      }
    }

    int ans = dfs(0);
    printf("%d\n", ans);
  }
  
  return 0;
}

Measured memory_bytes: 3060
# 2019 6/22
# ABC 131 D MEgalomania

N = int(input())
work = []

for i in range(N):
    a, b = map(int, input().split())
    work.append([b, a])

work.sort()

time = 0

is_ok = True

for i in range(N):
    time += work[i][1]
    if time > work[i][0]:
        is_ok = False
        break

if is_ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 35620
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    D = [1] * (N + 1)
    D[0] = 0
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            D[a] = 0
    print(sum(D))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9200
//
//  main.cpp
//  temp
//
//  Created by 松本拓真 on 2018/02/25.
//  Copyright © 2018年 TakumaMatsumoto. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int g[3][3];

bool ti() {
    for (auto i = 0; i < 2;i++) {
        size_t def = g[i+1][0] - g[i][0];
        for (auto k=1;k<3;k++) {
            if (g[i+1][k] - g[i][k] !=def) return false;
        }
    }
    for (auto j=0;j<2;j++) {
        size_t def = g[0][j+1] - g[0][j];
        for (auto k=1;k<3;k++) {
            if (g[k][j+1] - g[k][j] !=def) return false;
        }
    }
    return true;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    for (auto i = 0; i < 3; i++)
        for (auto j = 0; j < 3;j++) {
            int v; cin >> v;
            g[i][j] = v;
        }
    
    cout << (ti() ? "Yes" : "No");
    
    return 0;
}


Measured memory_bytes: 256
num = list(map(int, input().split()))
q = int(input())
anslist = []

for i in range(q):
    top, front = map(int, input().split())
    if top == num[0]:
        order = ''
    elif top == num[1]:
        order = 'N'
    elif top == num[2]:
        order = 'W'
    elif top == num[3]:
        order = 'E'
    elif top == num[4]:
        order = 'S'
    elif top == num[5]:
        order = 'NN'


    for o in order:
        if o == 'N':
            next = '263415'
        elif o == 'W':
            next = '326154'
        elif o == 'S':
            next = '513462'
        else:
            next = '421653'

        temp = [0]*6
        for i,n in enumerate(next):
            temp[i] = num[int(n)-1]

        num = temp

    if front == num[1]:
        ans = num[2]
    elif front == num[2]:
        ans = num[4]
    elif front == num[3]:
        ans = num[1]
    elif front == num[4]:
        ans = num[3]

    anslist.append(ans)

for ans in anslist:
    print(ans)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll n; cin >> n;
	ll sum = 0;
	for( int i = 0; i < n; ++i ){
		ll x; cin >> x;
		if( x % 4 == 0 ){
			sum += 2;
		} else if( x % 2 == 0 ){
			sum += 1;
		}
	}
	cout << ( ( sum >= n-(n%2) ) ? "Yes" : "No" ) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
//#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,i,ans=0;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    n -= k;
    for(i=0;i<n;i++)
        ans += a[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main(){
	int n,h,w,cnt=0;
	cin >>n>>h>>w;
	rep(i,n)
		rep(j,n){
			if (i+w<=n&&j+h<=n)
				cnt++;
		}
	cout <<cnt<<endl;
}

Measured memory_bytes: 256
chomp(my $len = <STDIN>);
chomp(my $a = <STDIN>);

my @e = split(//, $a);
my %s, %e;

for (my $i=0; $i<$len; $i++) {
    my $c = $e[$i];
    $s{$c} = $i unless defined($s{$c});
    $e{$c} = $i;
}

my $max = 0;
for (my $i=1; $i<$len-1; $i++) {
    my $num = 0;
    for my $c ('a'..'z') {
	$num++ if $s{$c} <= $i && $i < $e{$c};
    }
    if ($max < $num) { $max = $num; }
}

print $max, "\n";


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
const int N=1e3+5;
int n,m,x_,y_,x[N],y[N];
int main() {
	scanf("%d%d%d%d",&n,&m,&x_,&y_);
	for(int i=1;i<=n;i++)scanf("%d",&x[i]);
	for(int i=1;i<=m;i++)scanf("%d",&y[i]);
	sort(x+1,x+n+1); sort(y+1,y+m+1);
//	for(int i=1;i<=n;i++)printf("%d ",x[i]);
	if(y[1]<=x[n])return puts("War"),0;
	if(min(y_,y[1])>max(x[n],x_))return puts("No War"),0;
	else return puts("War"),0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BFizzBuzzSum {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      ll ans = 0;
      for(int i=1; i<=n; i++) {
        if (i%3 != 0 && i%5 != 0) {
          ans += i;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  BFizzBuzzSum solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  string S;
  cin >> S;
  ll N = S.length();
  ll ans = 0;

  for (ll bit = 0; bit < 1 << N - 1; ++bit) {
    ll tmp = S[0] - '0';
    REP(i, N - 1) {
      if (bit & (1 << i)) {
        ans += tmp;
        tmp = S[i + 1] - '0';
      } else {
        tmp = tmp * 10 + S[i + 1] - '0';
      }
    }
    ans += tmp;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, sum;
    int i;

    while(scanf("%d %d", &a, &b) != EOF){
        sum = a + b;
        for(i = 0; sum > 0; i++){
            sum /= 10;
        }
        printf("%d\n", i);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint n, x, d;
  cin >> n >> x >> d;
  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    } else {
      cout << n + 1 << endl;
    }
    return 0;
  }
  // ?
  if (d < 0) {
    x = -x;
    d = -d;
  }
  unordered_map<int, vector<pair<lint, lint>>> now;
  for (lint A = 0; A <= n; ++A) {
    // S = Ax + Bd
    lint Bmin = (A - 1) * A / 2, Bmax = (2 * n - A - 1) * A / 2;
    lint Adiv = A * x / d, Smod = A * x % d;
    if (Smod < 0) {
      Smod += abs(d);
      // ?
      ++Adiv;
    }
    now[Smod].push_back({Adiv + Bmin, Adiv + Bmax});
  }
  lint cnt = 0;
  allrep (m, now) {
    sort(all(m.second));
    lint now = LLONG_MIN;
    allrep (p, m.second) {
      lint l = max(now, p.first), r = max(now, p.second + 1);
      cnt += r - l;
      now  = r;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 17864
#include<bits/stdc++.h>
using  namespace std;
int main()
{
   long long  n,s=0;
    cin>>n;
    vector<long long  >v;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    long long m=*max_element (v.begin(),v.end());
    long long  k=n/2;
    for(int i=1;i<k;i++)
    {
        s=s+v[i]*2;
        //cout<<s<<" ";
    }
    if(n%2==0)
        s=s+m;
        else
            s=s+m+v[k];
    cout<<s<<endl;
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
int main() {
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    int sum = 0;
    long long ans = 0;
    int right = 0;
    for(int left = 0; left < n; ++left) {
        while(right < n && (sum ^ a.at(right)) == (sum + a.at(right))) {
            sum += a.at(right);
            ++right;
        }

        ans += right - left;
        if(left == right) ++right;
        else {
            sum -= a.at(left);
        }
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	ll cur = 0, res = 0;
	FORD(i,0,n-1) {
		if (a[i+1] > a[i]) cur = 0;
		else cur++;
		res = max(res,cur);
	}
	cout << res << endl;


}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int n, k; cin>> n>> k;
        int rem= n% k;
        cout << min(rem, abs(rem- k));
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
def nlcm(lista):
    res = lista[0]
    for i in range(1,len(lista)):
        res = lcm(res,lista[i])
    return res

def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n = int(input())
    a = list(map(int, input().split()))
    cm = nlcm(a)-1
    res = 0
    for i in a:
        res += cm % i
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 66792
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<ctime>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 200500
#define inf 1152921504606846976
#define ll long long
#define mm 1000000007
#define eps 1e-9
#define low(x) x&(-x)
#define pb push_back
#define mp make_pair
#define PII pair<int,int>
using namespace std;
ll a[maxn],s[maxn];
int n;
ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

int main(){
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	n=read();
	rep(i,1,n) a[i]=read(),s[i]=s[i-1]+a[i];
	ll ans=inf;
	rep(i,1,n-1) ans=min(ans,abs(s[i]-(s[n]-s[i])));
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=52,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

struct matrix{
  ll m[MAXn][MAXn];
};
ll n,k;
matrix mul(matrix &a,matrix &b){
  matrix ret;
  REP (i,n) REP (j,n) ret.m[i][j] = 0;
  REP (i,n) REP (j,n) REP (u,n) {
    ret.m[i][j] = (ret.m[i][j] + (a.m[i][u] * b.m[u][j])%MOD)%MOD;
  }
  return ret;
}
int main(){
  IOS();
  cin >> n >> k;
  matrix base,tmp;
  REP (i,n) REP (j,n) cin >> base.m[i][j];
  REP (i,n) REP (j,n) tmp.m[i][j] = (i==j);

  while (k) {
    if (k&1) tmp = mul(tmp,base);
    base = mul(base,base);
    k>>=1;
  }

  matrix tp;
  REP (i,n) REP (j,n) {
    if (j == 0) tp.m[i][j] = 1;
    else tp.m[i][j] = 0;
  }
  tp = mul(tmp,tp);

  ll ans = 0;
  REP (i,n) ans = (ans + tp.m[i][0])%MOD;
  cout << ans << endl;
}


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

int n, A[50], dp[2000][2000];

int solve(int i, int m){
    if (dp[i][m])return dp[i][m];

    if (m == 0) dp[i][m] = true;
    else if (i >= n) dp[i][m] = false;
    else if (solve(i + 1, m)) return true;
    else if (solve(i + 1, m - A[i])) return true;
    else dp[i][m] = false;

    return dp[i][m];
}

int main(){
    int q, M;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    cin >> q;
    for (int i = 0; i < q; i++){
        cin >> M;
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    ll ans = 0;
    rep(i,n){
      if(h[i] >= k) ans++;
    }
    print(ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<j; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef pair<int, int> 		pii;

int main()
{
//	freopen("t.in","r",stdin);
//	freopen("t.out","w",stdout);
	IOS;
	int a, b;
	cin >> a >> b;
	int p = log10(b)+1;
	int temp = a*pow(10, p) + b;
	if(ceil(sqrt(temp)) == floor(sqrt(temp)))
		puts("Yes");
	else
		puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000

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

  int res=n;
  if (n == 100) res++;
  for (int i=0; i<d; i++) {
    res *= 100;
  }

  printf("%d\n", res);

  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int m = Integer.parseInt(in[1]);

        int l0 = 0;
        int r0 = 1000000000;
        for(int i = 0; i < m; i++) {
            in = br.readLine().split(" ");
            int l = Integer.parseInt(in[0]);
            int r = Integer.parseInt(in[1]);
            l0 = Math.max(l0, l);
            r0 = Math.min(r0, r);
        }

        System.out.println(r0 >= l0? r0 - l0 + 1 : 0);

        br.close();
    }
}

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

int main()
{
    ll a, b;
    ll v, w;
    ll t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    if (w >= v)
    {
        cout << "NO" << endl;
        exit(0);
    }
    ll diff = abs(v - w) * t;

    if (abs(a - b) <= diff)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for( i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 2*100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
using namespace std;


int main()
{
	fast;
	ll n;
	cin>>n;
	ll i;
	ll a[n];
	vector<ll>v;
	//ll k=0;
	ll x=1;
	rep(i,n) cin>>a[i];
	rep(i,n)
	{
		if(a[i]==x)
		{
			v.pb(x);
			x++;
		}
	}
	if(v.size()==0)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<n-v.size()<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 6868
n, x, y = map(int, input().split())
ans = [0 for _ in range(n-1)]
for i in range(1, n):
    for j in range(i+1, n+1):
        d = min(j-i, abs(x-i) + abs(y-j) + 1)
        ans[d-1] += 1

print(*ans, sep='\n')

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	int k, x;
	cin >> k >> x;
	int l = x - k + 1;
	int r = x + k - 1;
	if(l < -1000000){
		int raz = -1000000 - l;
		r += raz;
	}
	if(r > 1000000){
		int raz = r - 1000000;
		l -= raz;
	}
	for(int i = l; i <= r; i++)
		cout << i << " ";
}

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

bool check( long long int y ) {

  if ( ( y % 4 ) != 0 ) return false;
  if ( ( y % 100 ) == 0 && ( y % 400 ) != 0 ) return false;
  return true;

}

int main () {

  string input;

  int st = 2012;

  while( true ) {

    cin >> input;

    if ( input == "#" ) break;

    int cnt = 0;

    int m[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    long long int d[5] = {0};

    for ( int i = 0; i < input.size(); i++ ) {

      if ( input[i] == '.' ) {
	cnt++;
      }else {
	d[cnt] *= 10;
	d[cnt] += input[i] - '0';
      }

    }

    long long int num = 0;

    if ( cnt == 2 ) {

      if ( d[0] == st ) {
	num = d[2] - 21;
      }else {
	num = 10;
	d[0]--;
	num += ( d[0] - st ) * 365 + d[0] / 4 - d[0] / 100 + d[0] / 400;
	num -= st / 4 - st / 100 + st / 400;
	d[0]++;
	for ( int i = 0; i < d[1] - 1; i++ ) {
	  num += m[i];
	  if ( i == 1 ) {
	    if ( check( d[0] ) == true ) num++;
	  }
	}
	num += d[2];
      }

      d[4] = num % 20;
      num /= 20;
      d[3] = num % 18;
      num /= 18;
      d[2] = num % 20;
      num /= 20;
      d[1] = num % 20;
      num /= 20;
      d[0] = num % 13;

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

	if ( i != 0 ) cout << ".";
	cout << d[i];

      }

      cout << endl;

    }else if ( cnt == 4 ) {

      num += d[0] * 20 * 20 * 18 * 20;
      num += d[1] * 20 * 18 * 20;
      num += d[2] * 18 * 20;
      num += d[3] * 20;
      num += d[4];

      if ( num <= 10 ) {

	d[0] = st;
	d[1] = 12;
	d[2] = 21 + num;

      }else {

	num -= 10;

	d[0] = st+1;
	d[1] = 1;
	d[2] = 1;

	int k;

	while( true ) {

	  if ( check( d[0] ) == false ) {
	    k = 365;
	  }else {
	    k = 366;
	  }

	  if ( num <= k ) break;
	  num -= k;
	  d[0]++;

	}

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

	  k = m[i];
	  if ( check( d[0] ) == true && i == 1 ) k++;
	  if ( num <= k ) {
	    d[2] = num;
	    break;
	  }else {
	    d[1]++;
	    num -= k;
	  }

	}

      }

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

	if ( i != 0 ) cout << ".";
	cout << d[i];

      }

      cout << endl;

    }

  }

  return 0;

}

Measured memory_bytes: 1188
N = gets.to_i
S1 = gets.chomp.chars
S2 = gets.chomp.chars
MOD = 10 ** 9 + 7
ans = 1
prev = nil
i = 0
while i < N
  if S1[i] == S2[i]
    # 2x1
    if prev.nil?
      ans = 3
    elsif prev == :v
      ans = ans * 2 % MOD
    else
      # do nothing
    end
    prev = :v
    i += 1
  else
    # 1x2
    if prev.nil?
      ans = 6
    elsif prev == :v
      ans = ans * 2 % MOD
    else
      ans = ans * 3 % MOD
    end
    prev = :h
    i += 2
  end
end
puts ans


Measured memory_bytes: 1788
import java.util.Scanner;

//Live Schedule
public class Main{

	int C, D, W, X;
	int[][] E, F;
	int[][][] dp;
	
	int get(int d, int w, int x){
		if(d==D||x<0)return 0;
		if(dp[d][w][x]!=-1)return dp[d][w][x];
		int res = get(d+1, w, x);
		for(int i=0;i<C;i++){
			if(E[i][d]==0)continue;
			int R = E[i][d], f = F[i][d];
			if(f<=w)res = Math.max(res, R+get(d+1, w-f, x));
			if(x==0)continue;
			for(int k=i+1;k<C;k++){
				if(E[k][d]==0)break;
				R+=E[k][d]; f+=F[k][d];
				if(w<f)break;
				res = Math.max(res, R+get(d+1, w-f, x-1));
			}
		}
		return dp[d][w][x] = res;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		dp = new int[30][51][6];
		for(;;){
			C = sc.nextInt(); D = sc.nextInt(); W = sc.nextInt(); X = sc.nextInt();
			if((C|D|W|X)==0)break;
			E = new int[C][D]; F = new int[C][D];
			for(int i=0;i<C;i++)for(int j=0;j<D;j++)E[i][j]=sc.nextInt();
			for(int i=0;i<C;i++)for(int j=0;j<D;j++)F[i][j]=sc.nextInt();
			for(int i=0;i<D;i++)for(int j=0;j<=W;j++)for(int k=0;k<=X;k++)dp[i][j][k]=-1;
			System.out.println(get(0, W, X));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<stdio.h>
using namespace std;

int main(){
  int inpt, h, m, s;
  scanf("%d", &inpt);
  h = inpt/3600;
  m = (inpt%3600)/60;
  s = inpt - h*3600 - m*60;
  printf("%d:%d:%d\n", h,m,s);
  return 0;
}


Measured memory_bytes: 2760