akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>

#define INF 1000000007

using namespace std;

int n,m;
long long ans = 1;
int main()
{
	cin >> n >> m;
	if(n > m)swap(n,m);
	if(m - n > 1)
	{
		cout << 0 << endl;
		return 0;
	}
	
	
	for(int i = 1;i  <= m;i++)
	{
		ans *= i;ans =ans % INF;
	}
	for(int i = 1;i <= n;i++)
	{
		ans *= i;ans =ans % INF;
	}
	if(m - n != 1)
	{
		ans += ans;ans = ans % INF;
	}
	
	cout << ans << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  string s;
  cin>>s;
  ll count=0;
  ll ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T'){
      count++;
      ans=max(ans,count);
    }
    else{
      count=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;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>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int x, n;
    cin >> x >> n;
    set<int> st;
    rep (i, n) {
        int y;
        cin >> y;
        st.insert(y);
    }

    int diff = inf;
    int ans = inf;
    for (int i = -2000; i <= 2000; i++) {
        if (st.count(i)) continue;
        int di = abs(x - i);
        if (di < diff) {
            diff = di;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
n = int(input())
c = 1
tmp = 26
while tmp < n:
    tmp += 26**(c + 1)
    c += 1
ans = ''
for i in range(c):
    a = n % 26
    if a == 0:
        a = 26
    ans = chr(a + 96) + ans
    n = (n - a) // 26
print(ans)


Measured memory_bytes: 9184
def remain(pos,length):
  p=pos
  for c,d in moves:
    if s[p]==c:
      if d=='L':
        p-=1
      if d=='R':
        p+=1
    if p<0 or p>=length:
      return False
  return True

n,q=map(int,input().split())
s=input()
moves=[list(map(str,input().split())) for _ in range(q)]
l=-1
r=n
while r-l!=1:
  mid=(l+r)//2
  if remain(mid,n)==True:
    r=mid
  else:
    l=mid
remain_left=r
if remain_left==n:
  print(0)
  exit()
l=remain_left
r=n
while r-l!=1:
  mid=(l+r)//2
  if remain(mid,n)==True:
    l=mid
  else:
    r=mid
remain_right=l
print(remain_right-remain_left+1)

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int ans = 1000;
  rep(i, n-2){
    int num;
    num = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
    ans = min(ans, abs(num-753));
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,m,q;
    cin>>n>>m>>q;

    ll lr[503][503];

    ll tmp,tmp2;
    REP(i,1,m+1){
        cin>>tmp>>tmp2;
        lr[tmp][tmp2]++;
    }
    ll s[503][503];
    REP(i,1,n+1){
        REP(j,1,n+1){
            s[i][j] = s[i][j-1]+lr[i][j];
        }
    }
    while(q--){
        ll l,r;
        ll sum = 0;
        cin>>l>>r;
        REP(j,l,r+1){
            sum += s[j][r]-s[j][l-1];
        }
        cout<<sum<<endl;
    }
    return  0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/


int main() {
    cin >> n >> m;
    vi v(n);
    REP(i, n) {
        cin >> v[i];
        ans += 2 * min(v[i], m - v[i]);
    }
    cout << ans << endl;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

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

const int maxn = 100010;

int b[maxn], u[maxn], l[maxn];

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

	vector<pair<ll, int>> vec(N);

	rep(i, N) {
		cin >> b[i] >> l[i] >> u[i];
		vec[i] = mp((ll)X * u[i] - (ll)b[i] * (u[i] - l[i]), i);
	}
	sort(ALL(vec));
	reverse(ALL(vec));

	vector<ll> ps(N + 1);
	ll all = 0;

	for (int i = N-1; i >= 0; --i) {
		int id = vec[i].se;
		all += (ll)b[id] * l[id];
	}

	rep(i, N) {
		ps[i+1] = ps[i] + vec[i].fi;
	}

	ll ans = (ll)X * N;
	ll lo = 0, hi = (ll)X * N;

	bool zero = 1;
	rep(i, N) if (b[i]) {
		zero = 0;
	}
	if (zero) hi = 0;

	while (hi - lo > 1) {
		ll mid = (lo + hi) / 2;
		ll x = mid % X, m = mid / X;

		ll diff = ps[m] - all;

		bool ok = 0;
		for (int i = m; i < N; ++i) {
			ll nd;
			int id = vec[i].se;
			if (x >= b[id]) {
				nd = diff + (x - b[id]) * u[id] + (ll)b[id] * l[id];
			} else {
				nd = diff - (b[id] - x) * l[id] + (ll)b[id] * l[id]; 
			}
			if (nd >= 0) {
				ok = 1;
			}
		}

		m = (mid + X-1) / X;
		diff = ps[m] - all;
		for (int i = 0; i < m; ++i) {
			ll nd;
			int id = vec[i].se;
			if (x >= b[id]) {
				nd = diff + (x - b[id]) * u[id] - vec[i].fi + (ll)b[id] * l[id];
			} else {
				nd = diff - (b[id] - x) * l[id] - vec[i].fi + (ll)b[id] * l[id]; 
			}
			if (nd >= 0) {
				ok = 1;
			}			
		}
		if (ok) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	cout << hi << endl;

	return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
signed main(){
  int x[5],i;
  for(i=0;i<5;i++){
    scanf("%d",&x[i]); 
  }
for(i=0;i<5;i++){
  if(x[i]==0){
    printf("%d\n",i+1);
  
  }
}
return(0);
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb(a) push_back(a)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
using vP = vector<P>;

int main(){
    int h,w;
    cin>>h>>w;
    
    vector<string> a(h);
    rep(i,h)cin>>a[i];
    
    if(a[0][0]!='#'){
        cout << "Impossible" << endl;
        return 0;
    }
    
    bool ok = true;
    int ni = 0, nj = 0;
    a[0][0] = '.';
    
    vi di = {1,0};
    vi dj = {0,1};
    
    while(ok && (!(ni==h-1 && nj==w-1))){
        
        ok = false;
        
        rep(k,2){
            int ai = ni + di[k];
            int aj = nj + dj[k];
            
            if(ai>=h || aj>=w)continue;
            
            if(a[ai][aj]=='#'){
                
                a[ai][aj] = '.';
                ni = ai;
                nj = aj;
                ok = true;
                
                break;
            }
        }
    }
    
    rep(i,h)rep(j,w){
        if(a[i][j]!='.'){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  string T, U;
  for(int i = 0; i < N; i++) {
    if(i % 2 == 0) {
      T.push_back('0');
      U.push_back('1');
    }
    else {
      T.push_back('1');
      U.push_back('0');
    }
  }
  int count_T = 0, count_U = 0;
  for(int i = 0; i < N; i++) {
    if(S[i] != T[i]) {
      count_T++;
    }
    else {
      count_U++;
    }
  }
  if(count_T < count_U) {
    cout << count_T << endl;
  }
  else {
    cout << count_U << endl;
  }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

const ll LMAX = 8000;

vector<bool> awase(string &s, string  &t){
  ll n = s.size();
  ll m = t.size();
  vector<bool> check(2*LMAX+1);
  for(int i=0;i<=2*LMAX;i++){
    bool ok = true;
    for(int j=0;j<m;j++){
      if(i+j>=LMAX && i+j<LMAX+n){
        ll idx = j;
        ll jdx = i+j-LMAX;
        if(s[jdx] != '?' and t[idx] != '?' and s[jdx] != t[idx]) ok = false;
      }
    }
    check[i] = ok;
  }
  return check;
}



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

    string a, b, c;
    cin >> a >> b >> c;

    auto ab = awase(a, b);
    auto ac = awase(a, c);
    auto bc = awase(b, c);

    ll A = a.size();
    ll B = b.size();
    ll C = c.size();
    
    ll res = (1ll<<60);
    for(int i=0;i<=8000;i++){
      for(int j=0;j<=8000;j++){
        if(ab[i-4000+8000] and ac[j-4000+8000] and bc[j-i+8000]){
          ll left = min(4000, min(i, j));
          ll right = max(4000+A, max(i+B, j+C));
          chmin(res, right-left);
        }
      }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
N, M = list(map(int, input().split(' ')))
MOD = int(1e9 + 7)
primes = []
if M % 2 == 0:
  primes.append(2)

seeds = []
p = 2
while M > 1:
  while M % p == 0:
    seeds.append(p)
    M = M // p
  if p*p > M:
    if M != 1:
	    seeds.append(M)
    M = 0
  p += 1

def comb(n, k):
  ans = 1
  for i in range(1, k + 1):
    ans = (ans * (n + 1 - i) // i)
  return ans

ans = 1
hogehoge = set(seeds)
for i in hogehoge:
  a_ct = seeds.count(i)
  ans = (ans * comb(a_ct + N-1, min(a_ct, N-1))) % MOD
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	char buf[6];
	char *str;
	int a = 0;

	if (scanf("%3c", buf) != 1)
	{
		return 1;
	};
	str = buf;
	while (*str)
	{
		if (*str == '7')
		{
			printf("Yes\n");
			return 0;
		}
		str++;
	}
	printf("No\n");
	return (0);
}

Measured memory_bytes: 1600
import numpy as np

c = [list(map(int, input().split())) for i in range(3)]
c = np.array(c)
flag = False
for a1 in range(min(c[0]) + 1):
    b1 = c[0, 0] - a1
    b2 = c[0, 1] - a1
    b3 = c[0, 2] - a1
    if c[1, 0] - b1 == c[1, 1] - b2 == c[1, 2] - b3 and c[2, 0] - b1 == c[2, 1] - b2 == c[2, 2] - b3:
        print('Yes')
        flag = True
        break
if not flag:
    print('No')


Measured memory_bytes: 12508
#include <cassert>
#include <iostream>
#include <string>
#include <list>
// #include <vector>

class TDllist
{
    std::list<int> FList;
    // std::vector<int> FList;
public:
    void Insert(int X)
    {
        FList.push_front(X);
        // FList.insert(FList.begin(), X);
    }
    void Delete(int X)
    {
        for(auto It = FList.begin();
            It != FList.end();
            ++It)
        {
            if(*It == X){
                FList.erase(It);
                return;
            }
        }
    }
    void DeleteFirst()
    {
        FList.pop_front();
        // FList.erase(FList.begin());
    }
    void DeleteLast()
    {
        FList.pop_back();
    }
    void Show()const
    {
        auto It = FList.begin();
        std::cout << *It;
        for(++It; It != FList.end(); ++It)
        {
            std::cout << " " << *It;
        }
        std::cout << std::endl;
    }
};

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    TDllist List;
    int n, X;
    std::cin >> n;
    std::string Command;
    for(int i = 0; i < n; ++i){
        // std::string Command;
        std::cin >> Command;
        if(Command == "insert"){
            // int X;
            std::cin >> X;
            List.Insert(X);
        }else
        if(Command == "delete"){
            // int X;
            std::cin >> X;
            List.Delete(X);
        }else
        if(Command == "deleteFirst")
        {
            List.DeleteFirst();
        }else
        if(Command == "deleteLast")
        {
            List.DeleteLast();
        }else{
            assert(false);
        }
    }
    List.Show();
    return 0;
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int k = in();
  map<int, int> mp;
  REP(i,k) {
    int d = in();
    REP(j,d) {
      int tmp = in();
      ++mp[tmp-1];
    }
  }
  int ans = n;
  REP(i,n) {
    if(mp[i]) --ans;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
  int n, t, c, d;
  pair<int, int> p = make_pair(1000000,-1);
  cin >> n >> t;
  for(int i = 0;i<n;i++){
    cin >> c >> d;
    if(p.first > c && d <= t) p = make_pair(c, d);
  }
  if(p.first == 1000000) cout << "TLE" << endl;
  else cout << p.first << endl;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())

if a==b==c and a%2==0 and b%2==0 and c%2 == 0:
    print(-1)
else:
    ans = 0
    while True:
        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            break
        a,b,c = (b/2+c/2), (a/2+c/2), (a/2+b/2)
        ans += 1
    print(ans)

Measured memory_bytes: 8996
def rev?(s) return s.start_with?(s[(s.size/2)..-1].reverse) end

s = gets.chomp
sx = s.gsub('x', '')
res = rev? sx
if res
  x_num = []
  count = 0
  s.each_char{|c|
    if c == 'x'
      count += 1
    else
      x_num << count
      count = 0
    end
  }
  if sx.size == 0
    p 0
  else
    if s[-1] != 'x'
      x_num << 0 
    else
      x_num << count
    end
    lx = x_num[0...(x_num.size/2)]
    rx = x_num[-(x_num.size/2)..-1].reverse
    if lx.size == 1
      p (lx[0] - rx[0]).abs
    else
      p [lx, rx].transpose.map{|l, r| (l - r).abs}.inject :+
    end
  end
else
  p -1
end






Measured memory_bytes: 6404
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

ll MOD = 1e9 + 7;

const ll max_n = 505050;
ll fact[max_n];
bool fact_inited = false;

ll powmod(ll a, ll b){
	if(b == 0) return 1;
	if(b % 2 == 1) return a * powmod(a, b - 1) % MOD;

	ll d = powmod(a, b / 2) % MOD;
	return d * d % MOD;
}

void init_fact(){
	fact[0] = 1;
	fact[1] = 1;

	for(ll i = 2; i < max_n; i++){
		fact[i] = fact[i-1] * i % MOD;
	}

	fact_inited = true;
}

ll comb(ll n, ll k){
	if(!fact_inited) init_fact();

	ll ret = fact[n];
	ret *= powmod(fact[k],MOD-2);
	ret %= MOD;
	ret *= powmod(fact[n-k],MOD-2);
	ret %= MOD;
	return ret;

	// X^(-1) = X^(p-2) (mod p) (Fermat's little theorem)
}

ll perm(ll n, ll k){
	if(!fact_inited) init_fact();

	ll ret = fact[n];
	ret *= powmod(fact[n-k],MOD-2);
	ret %= MOD;
	return ret;
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, m;
	cin >> n >> m;

	ll ans = perm(m, n) * perm(m, n);
	ans %= MOD;

	ll s = -1;
	for(int x = 1; x <= n; x++){
		ll t = perm(m, n) * comb(n, x) % MOD * perm(m-x, n-x) % MOD;
		t %= MOD;
		t *= s;
		ans += MOD + t;
		ans %= MOD;

		s *= -1;
	}

	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

ll dp[2][3001][3001];

ll solve(ll a[], ll s, ll f, short chance) {

	if (s > f)
		return 0;

	if (dp[chance][s][f] != -1)
		return dp[chance][s][f];

	if (chance)
		return dp[chance][s][f] = max(a[s] + solve(a, s + 1, f, 0) , a[f] + solve(a, s, f - 1, 0));
	else
		return dp[chance][s][f] = min(solve(a, s + 1, f, 1) - a[s], solve(a, s, f - 1, 1) - a[f]);
}



int main() {

	memset(dp, -1, sizeof dp);

	ll n;
	cin >> n;

	ll a[n];
	for (ll i = 0; i < n; i++) cin >> a[i];

	cout << solve(a, 0, n - 1, 1) << endl;
	return 0;
}

Measured memory_bytes: 144608
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



const int MAX = 200;

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

int t, n, x, y;
bool obst[MAX][MAX];
int dist[MAX][MAX];

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    while (cin >> t >> n) {
        if (t == 0) break;
        memset(dist, -1, sizeof(dist));
        memset(obst, 0, sizeof(obst));
        
        for (int i = 0; i < n; ++i) {
            cin >> x >> y;
            obst[x+100][y+100] = true;
        }
        cin >> x >> y;
        x += 100, y += 100;
        
        int res = 1;
        dist[x][y] = 0;
        queue<pint> que;
        que.push(MP(x, y));
        while (!que.empty()) {
            pint p = que.front(); que.pop();
            
            //cout << p << " : " << dist[p.FI][p.SE] << endl;
            
            if (dist[p.FI][p.SE] == t) continue;
            
            for (int i = 0; i < 6; ++i) {
                int nx = p.FI + dx[i], ny = p.SE + dy[i];
                //if (nx < 20 || nx > 80 || ny < 20 || ny > 80) continue;
                if (dist[nx][ny] == -1 && !obst[nx][ny]) {
                    dist[nx][ny] = dist[p.FI][p.SE] + 1;
                    que.push(MP(nx,ny));
                    ++res;
                }
            }
        }
        
        cout << res << endl;
    }
    
    return 0;
}


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

const ll INF = 1LL << 60;
long long N;
long long M;
long long Q;
vector<ll> a, b, c, d;
ll ans = 0;

// i: 何回めか
// v: 配列
void dfs(int i, vector<int> v) {
    if (v.size() == N) {
        // 操作
        // rep(k, v.size()) {
        //     cout << v[k] << " ";
        // }
        // cout << endl;
        ll tmp = 0;
        rep(k, Q) {
            ll diff = v[b[k]] - v[a[k]];
            if (diff == c[k]) {
                tmp += d[k];
            }
        }
        ans = max(ans, tmp);
        return;
    }
    v.push_back(i);
    for (int m = i; m <= M; m++) {
        dfs(m, v);
    }
}

int main() {
    scanf("%lld",&N);
    scanf("%lld",&M);
    scanf("%lld",&Q);
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);

    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
        a[i]--;
        b[i]--;
    }

    for (int i = 1; i <= M; i++) {
        vector<int> tmp;
        dfs(i, tmp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
using namespace std;
const int INF = 1000000001;

int main() {
  int n; cin >> n;
  int dp[100001];
  fill(dp,dp+n,INF);
  int a[100001];
  for ( int i = 0; i < n; i++ ) cin >> a[i];
  for ( int i = 0; i < n; i++ ) {
    *lower_bound(dp,dp+n,a[i]) = a[i];
  }
   cout << lower_bound(dp,dp+n,INF)-dp << endl;
  return 0;
}

Measured memory_bytes: 1940
#include <iostream>
#include <set>
using namespace std;
int main(){
  string s;
  cin >> s;

  set<char> st;
  for(int i=0;i<s.size();i++){
    st.insert(s[i]);
  }

  string ans = "";
  if(s.size()==26){
    for(int i=s.size()-1;i>0;i--){
      if(s[i-1] < s[i]){
        char c = s[i];
        for(int j=i;j<s.size();j++){
          if(s[j] > s[i-1] && s[j] < c){
            c = s[j];
          }
        }
        ans = s.substr(0,i-1) + c;
        break;
      }
    }
  }else{
    for(int i=0;i<26;i++){
      auto itr = st.find('a'+i);
      if(itr == st.end()){
        s += 'a'+i;
        ans = s;
        break;
      }
    }
  }

  if(ans == ""){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    h,a = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = h // a
    if h%a == 0:
        print(ans)
    else:
        print(ans + 1)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9168
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <set>
#include <string>

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

  printf("%lld\n", (100LL*(N-M)+1900LL*M) << M);
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int aws = 0;
	int idx = -1;

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

	vector<int> b(n);
	for (int i = 0; i < n; i++)
	{
		cin >> b.at(i);
	}

	vector<int> c(n - 1);
	for (int i = 0; i < n - 1; i++)
	{
		cin >> c.at(i);
	}

	for (int i = 0; i < n; i++)
	{
		aws += b.at(a.at(i) - 1);
		
		if (1 <= i && i <= n - 1)
		{
			if (a.at(i) - 1 == idx + 1)
			{
				aws += c.at(a.at(i) - 2);
			}
		}

		idx = a.at(i) - 1;
	}

	cout << aws << endl;
}


Measured memory_bytes: 764
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PT = [list(map(int,input().split())) for i in range(M)]
ans = [0]*M
for i in range(M):
    for j in range(N):
        if PT[i][0]==j+1:
            ans[i]+=PT[i][1]
        else: ans[i]+=T[j]
for i in range(M):
    print(ans[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{


        ll n,k,sm=0;
        cin>>n;
        int ar[n];

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


        for(int i=1; i<=n-1; i++)
        {
            int x;
            cin>>x;
            ar[x]++;
        }

        for(int i=1; i<=n; i++)
        {
            cout<<ar[i]<<endl;
        }







    return 0;
}


Measured memory_bytes: 4400
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

double a, b;

void init() {

}

void input() {
  cin >> a >> b;
}

void solve() {
  printf("%.9f\n", a/b);
}

int main() {
	init();
	input();
	solve();
	return 0;
}


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

    return 0;
}


Measured memory_bytes: 2604
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

const double eps = 1e-10;

class Vector
{
public:
  double x;
  double y;

  Vector(){}
  Vector( double x, double y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const double k ) { return Vector( x * k, y * k ); }
  Vector operator / ( const double k ) { return Vector( x / k, y / k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double abs() { return sqrt( norm() ); }
  double norm() { return x * x + y * y; }

  static double dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static double cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }
};

class CounterClockwise
{
public:
  Vector p0, p1;
  CounterClockwise(){}
  CounterClockwise( double x0, double y0, double x1, double y1 ) : p0(x0, y0), p1(x1, y1) {}
  int solve( double x, double y );
};

int CounterClockwise::solve( double x, double y )
{
  Vector p10 = p1 - p0;
  Vector p20 = Vector( x, y ) - p0;

  double c = Vector::cross( p10, p20 );
  double d = Vector::dot( p10, p20 );
  
  if ( fabs( c ) < eps )
    {
      if ( d < 0 )
        cout << "ONLINE_BACK" << endl;
      else if ( p10.norm() < p20.norm() )
        cout << "ONLINE_FRONT" << endl;
      else
        cout << "ON_SEGMENT" << endl;
    }
  else if ( c > 0 )
    cout << "COUNTER_CLOCKWISE" << endl;
  else
    cout << "CLOCKWISE" << endl;
  
  return 0;
}

int main()
{
  double x0, y0, x1, y1;
  cin >> x0 >> y0 >> x1 >> y1;
  
  int q;
  cin >> q;

  CounterClockwise cc(x0, y0, x1, y1);

  for ( auto i = 0; i < q; ++i )
    {
      double x2, y2;
      cin >> x2 >> y2;
      cc.solve( x2, y2 );
    }

  return 0;
}

Measured memory_bytes: 1228
c=[p]*gets.to_i
l=$<.map{|t|n,a,b=t.split.map &:to_i;d=[];[[a,b],[b,a]].map{|i,j|i<0||(d<< i;c[i]=[i,n,j])};[n,d]}.sort
c[n=c.index(p)]=[n,-1,-1]
f=->n,d{c[n][3,0]=[l[n][1].size,d,h=(l[n][1].map{|i|f[i,d+1]}.max||-1)+1,d<1?:root:h<1?:leaf:"internal node"];h}
f[n,0]
puts c.map{|i|(("node %d: "+%w(parent sibling degree depth height)*s=" = %d, ")+s+"%s")%i}

Measured memory_bytes: 6128
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int ans = 0;
        int max = -1;
        for (int i = 1; i <= N; i++) {
            if (Integer.numberOfTrailingZeros(i) > max) {
                max = Integer.numberOfTrailingZeros(i);
                ans = i;
            }
        }
        System.out.println(ans);
    }

}


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

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

typedef long long int_t;

const int size = 500000;
int_t v, e, r;
int_t s[size];
int_t t[size];
int_t d[size];

bool input() {
  if (cin >> v >> e >> r) {
    rep(i, e) cin >> s[i] >> t[i] >> d[i];
    return true;
  }
  return false;
}

typedef tuple<int, int> node_t;
typedef queue<node_t> queue_t;

const int_t inf = numeric_limits<int_t>::max();
queue_t q;
int_t mincost[size];
vector<int> g[size];

void init() {
  fill(mincost, mincost+size, inf);
  fill(g, g+size, vector<int>());
  q = queue_t();
}

void solve() {
  // generate graph
  rep (i, e) {
    g[s[i]].push_back(i);
  }

  mincost[r] = 0;
  q.emplace(0, r);
  while (!q.empty()) {
    auto node = q.front();
    q.pop();

    auto cost = get<0>(node);
    auto v = get<1>(node);

    for (auto ni : g[v]) {
      int_t next_cost = cost + d[ni];
      int_t next_v = t[ni];

      if (next_cost >= mincost[next_v]) continue;
      mincost[next_v] = next_cost;
      q.emplace(next_cost, next_v);
    }
  }

  rep (i, v) {
    if (mincost[i] == inf) {
      cout << "INF" << endl;
    } else {
      cout << mincost[i] << endl;
    }
  }
}

int main() {
  while (input()) {
    init();
    solve();
  }
  return 0;
}



Measured memory_bytes: 35036
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<usize>();
  let mut k = read::<usize>();
  let s = read::<String>();

  let k = k - 1;

  // let mut s_vec: Vec<char> = s.chars().collect();
  println!(
    "{}{}{}",
    s[0..k].to_string(),
    s[k..k + 1].to_string().to_lowercase(),
    s[k + 1..].to_string()
  );
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, a[100000];
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &a[i]);
	}
	int count = 0;
	for (int i = 1; i <= N; i++) {
		if (a[a[i]] == i) {
			count++;
		}
	}
	printf("%d", count/2);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	long X;
	long K;
	long D;
	long ans = Long.MAX_VALUE;

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

	public void main(Scanner scan) {
		X = Long.parseLong(scan.next());
		K = Long.parseLong(scan.next());
		D = Long.parseLong(scan.next());
		scan.close();
		System.out.println(Walking());
	}

	public long Walking() {
		X = Math.abs(X);
		long k = Math.min(K,X/D);
		K -= k;
		X -= k*D;

		if (K % 2 == 0) {
			ans = X;
		} else {
			ans = Math.abs(X - D);
		}
		return ans;
	}

}


Measured memory_bytes: 35592
#include<iostream>

using namespace std;

int main(){
    int a, b ,k;
    cin >> a >> b >> k;
    int cnt=0;
    for(int i=min(a, b);i>=1;i--){
        if(a%i==0 && b%i==0){
            cnt++;
        }
        if(cnt==k){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char a,b;
//	a=getchar();
	//scanf("%c",&b);
	scanf("%c %c",&a,&b);
	if(a==b)
	{
		printf("H\n");
	}
	else
	{
		printf("D\n");
	}
//	printf("%c %c",a,b);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[110][110],tmp[110];
    int l,n,i,j;
    scanf("%d%d",&n,&l);
    for(i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(strcmp(s[i],s[j])>=1){
                strcpy(tmp,s[i]);
                strcpy(s[i],s[j]);
                strcpy(s[j],tmp);
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%s",s[i]);
    }
    printf("\n");
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define ALL(v) v.begin(), v.end()

int N;
int ans;

void resolve()
{
    int A, B, M;
    cin >> A >> B >> M;

    vector<int> a(A), b(B), x(M), y(M), c(M);
    RPT0(i, A) cin >> a[i];
    RPT0(i, B) cin >> b[i];
    RPT0(i, M) cin >> x[i] >> y[i] >> c[i];

    int minA = *min_element(ALL(a));
    int minB = *min_element(ALL(b));
    int ans = minA + minB;
    RPT0(i, M) ans = min(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);

    cout << ans << endl;
}

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


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

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

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

    sort(L.begin(), L.end());

    int ans = 0;
    for(int i=n-1; i>=0; --i){
        for(int j=i-1; j>=0; --j){
            int d = L.end() - lower_bound(L.begin(), L.end(), L[i]+L[j]);
            ans += n-1 - i - d;
        }
    }
    cout<< ans <<endl;

    return 0;
}

Measured memory_bytes: 3580
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let r: u16 = split.next().unwrap().parse().unwrap();
    let g: u16 = split.next().unwrap().parse().unwrap();
    let b: u16 = split.next().unwrap().parse().unwrap();
    writeln!(output,
             "{}",
             if (r * 100 + g * 10 + b) % 4 == 0 {
                 "YES"
             } else {
                 "NO"
             })
            .unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("4 3 2\n", "YES\n");
    }
    #[test]
    fn case2() {
        test("2 3 4\n", "NO\n");
    }
}



Measured memory_bytes: 4352
S = input()
s1 = int(S[0:2])
s2 = int(S[2:4])
def valid_month(n):
	return 1 <= n and n <= 12
def valid_year(n):
	return 0 <= n and n <= 99
if valid_year(s1) and valid_month(s2) and valid_year(s2) and valid_month(s1):
	print('AMBIGUOUS')
elif valid_year(s1) and valid_month(s2):
	print('YYMM')
elif valid_month(s1) and valid_year(s2):
	print('MMYY')
else:
	print('NA')


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> item(n);
	int total = 0;
	for (int i = 0; i < n; i++) {
		cin >> item.at(i);
		total += item.at(i);
	}

	sort(item.begin(), item.end());
	reverse(item.begin(), item.end());
	for (int i = 0; i < m; i++) {
		if ((item.at(i) * 4 * m) < total) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){
    int k,s;
    cin >> k >> s;
    int ans = 0;
    rep(i,k+1){
        rep(j,k+1){
            if(s-i-j >=0 && s-i-j <=k)ans++;
        }
    }
    
    

    cout << ans << endl;

    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc051.contest.atcoder.jp/tasks/abc051_b
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,i,j,min,data[100],count=0,tmp;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&data[i]);
  for(i=0;i<n;i++){
    min=i;
    for(j=i+1;j<n;j++)
      if(data[j]<data[min])
        min=j;
    if(data[i]>data[min]){
      tmp=data[i];
      data[i]=data[min];
      data[min]=tmp;
      count++;
    }
  }
  for(i=0;i<n;i++){
    if(i)
      printf(" ");
    printf("%d",data[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#temprate
from sys import setrecursionlimit
setrecursionlimit(10**6)
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#temprate
K,A,B = inputlist()
if A >= B:
    print(K + 1)
    exit()

tmp = K - (A - 1)
if tmp < 0:
    print(K + 1)
    exit()
cnt = tmp // 2
amari = tmp % 2

ans = cnt * B - (cnt - 1) * A + amari
ans = max(ans, K + 1)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    string S, T, U;
    ll A, B;
    cin >> S >> T >> A >> B >> U;
    if (S == U) {
        A--;
    } else {
        B--;
    }

    cout << A << " " << B << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
#define MAX 500000
Node root;
int S[MAX-1];
int cnt=0;
/*
Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}
*/

/*Node treeSearch(Node u, int k){
  if(x == NIL || k == x->key)return x;
  if(k < x->key)return treeSearch(x->left,k);
  else return treeSearch(x->right,k);

}
*/
/*
Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }
*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  S[cnt] = k;
  
  while(x != NIL){
  y=x;
  if(z->key < x->key) x = x->left;
  else x = x->right;
  }
  // z->p = y;
  
  if(y == NIL) root = z;
  else if( z->key < y->key) y->left = z;              // z を y の左の子にする
  else     y->right = z;               // z を y の右の子にする
  cnt++;
}

void inorder(Node u){
 if(u == NIL) return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);

  preorder(u->left);
  preorder(u->right);
}
Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)return u;
  if(k < u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
      else if ( com[0] == 'i' ){
	scanf("%d", &x);
	insert(x);
      }
      else if ( com[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }/* else if ( com[0] == 'd' ){
	  scanf("%d", &x);
	  treeDelete(treeSearch(root, x));
	  }*/
  }
    return 0;
  }
  



Measured memory_bytes: 22052