akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000
typedef long long LL;
typedef pair<int,int>P;
struct edge{int to,cost;};
 
vector<edge>G[3390];
int dis[3390];
 
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> >Q;
    fill(dis,dis+3389,INF);
    dis[s]=0;
    Q.push(P(0,s));
     
    while(Q.size()){
        P p=Q.top();
        Q.pop();
        int v=p.second;
        if(dis[v]<p.first)continue;
         
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(dis[e.to]>dis[v]+e.cost){
                dis[e.to]=dis[v]+e.cost;
                Q.push(P(dis[e.to],e.to));
                }
            }
        }
    }
 
int main(){
    int n,m,k;
    cin>>n>>m>>k;
     
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        G[a-1].push_back({b-1,c});
        G[b-1].push_back({a-1,c});
        }
         
    for(int i=0;i<k;i++){
        int a;
        cin>>a;
        G[3235].push_back({a-1,0});
        }   
         
    dijkstra(3235);
     
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<G[i].size();j++){
            ans=max(ans,max(dis[i],dis[G[i][j].to]));
            int ct=0;
            ct=G[i][j].cost;
             
                ct+=dis[i];
                ct+=dis[G[i][j].to];
                ct++;
                ct/=2;
                ans=max(ans,ct);
            }
        }   
        cout<<ans<<endl;
        return 0;
    }

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

int main(void) {
    string S,T;cin>>S>>T;
    int result = 0;
    if (S[0] == T[0]) result++;
    if (S[1] == T[1]) result++;
    if (S[2] == T[2]) result++;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
from itertools import accumulate
n = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
a1 = list(accumulate(A1))
ans = 0
for i in range(n):
  sums = a1[i]
  A3 = A2[i:]
  a2 = list(accumulate(A3))
  sums += max(a2)
  ans = max(ans,sums)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
struct fix_point: private T {
  explicit constexpr fix_point(T &&func): T(std::forward<T>(func)) { }
  template <class... Args>
  constexpr decltype(auto) operator () (Args &&... args) const {
    return T::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class T>
constexpr decltype(auto) make_fix_point(T &&func) {
  return fix_point<T>{std::forward<T>(func)};
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> degree(N);
  std::vector<std::vector<int>> graph(N);
  for (int i: range(0, N - 1)) {
    int x, y;
    std::cin >> x >> y;
    --x; --y;
    graph[x].push_back(y);
    graph[y].push_back(x);
    ++degree[x];
    ++degree[y];
  }
  bool answer = true;
  if (make_fix_point([&](auto &&dfs, int u, int p) -> bool {
    int count = 0;
    for (int v: graph[u]) {
      if (v != p) {
        if (dfs(v, u)) {
          ++count;
        }
      }
    }
    if (count >= 2) {
      answer = false;
    }
    return count == 0;
  })(0, -1)) {
    answer = false;
  }
  std::cout << (answer ? "Second" : "First") << '\n';
  return 0;
}


Measured memory_bytes: 6272
n, m = map(int, input().split())
lis = [True] *n
h = list(map(int, input().split()))
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] == h[b]:
        lis[a] = False
        lis[b] = False
    elif h[a] < h[b]:
        lis[a] = False
    else:
        lis[b] = False
ans = 0
for l in lis:
    if l:
        ans += 1
print(ans)

Measured memory_bytes: 20908
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
ll anslen = 1e15;
const int N = 4005;
void solve()
{

    ll i, j, n;
    vector<string> ss(3);
    std::vector<int> v {0, 1, 2};
    rep(i, 3)
    cin >> ss[i];
    auto ok = [](const string & a, const string & b, int j)
    {
        rep(i, b.size())
        {
            if(i + j < a.size() and a[i + j] != '?' and b[i] != '?' and a[i + j] != b[i])
                return 0;

        }
        return 1;

    };

    do
    {
        // cout<<"1";
        string a[3];
        rep(i, 3) a[i] = ss[v[i]];

        std::vector<bool> x(N);
        rep(i, N) x[i] = ok(a[0], a[1], i);

        std::vector<bool> y(N);
        rep(i, N) y[i] = ok(a[0], a[2], i);

        std::vector<bool> z(N);
        rep(i, N) z[i] = ok(a[1], a[2], i);

        rep(i, N)
        if(x[i])
            for(ll j = i; j < N; j++)
                if(y[j] and z[j - i])
                    anslen = min(anslen, max({si(a[0]), si(a[1]) + i, si(a[2]) + j}));

    }
    while(next_permutation(all(v)));


    cout << anslen;
}

int main()
{



    // ios_base::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    int t = 1;
    // cin >> t;


    while(t--)
    {
        solve();
        // cout << endl;
    }


}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;

void solve(){
	cout << ((N - 1) / 111) * 111 + 111 << endl;
}

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


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

#define fastio                  \
  ios_base::sync_with_stdio(0); \
  cin.tie(0)
#define LL long long
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define pr(v) pair<v, v>
#define pb push_back
#define FOR(i, j, k) for (auto i = j; i < k; i++)
#define ROF(i, j, k) for (auto i = j; i >= k; i--)
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for (long blockTime = 0; (blockTime == 0 ? (blockTime = clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

const long long INF = 1e18;
const long long MAX = 2e5 + 10;
vector<vector<LL>> dp(101, vector<LL>(MAX, -1));
LL f(LL *w, LL *v, int n, LL mv)
{
  if (dp[n][mv] != -1)
    return dp[n][mv];
  dp[n][mv] = f(w, v, n - 1, mv);
  if(mv - v[n] >= 0)
    dp[n][mv] = min(dp[n][mv], w[n]+ f(w, v, n - 1, mv - v[n]));
  
    //cout<<n<<" "<<mv<<" "<<dp[n][mv]<<" ;"<<endl;

    return dp[n][mv];
}
int main()
{
  fastio;
  int t = 1; // cin>>t;
  while (t--)
  {
    LL n, w;
    cin >> n >> w;
    LL a[n + 1], b[n + 1];
    FOR(i, 1, n + 1)
    cin >> a[i] >> b[i];
    LL ans = 0;
    FOR(i, 0, MAX)
    dp[0][i] = INT_MAX;
    FOR(i, 0, n + 1)
    dp[i][0] = 0;
    ROF(i, MAX - 1, 1)
    {
      ans = f(a, b, n, i);
     // cout<<ans<<" ,";
      if (ans > 0 && ans <= w)
      {
        ans = i;
        break;
      }
      ans = 0;
    }
    cout<<ans;
  }
}


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

struct Match {
    int n, m;
    vector<vector<int>> G;
    vector<bool> used;
    vector<int> from, to;

    Match(int n, int m): n(n), m(m) { G.resize(n); }
    void add_edge(int from_, int to_) { G[from_].push_back(to_); }

    bool dfs(int v) {
        if (used[v]) return false;
        used[v] = true;
        for (auto nv : G[v]) {
            if (to[nv] == -1 || dfs(to[nv])) {
                from[v] = nv;
                to[nv] = v;                
                return true;
            }
        }
        return false;
    }

    int solve() {
        int res = 0;
        used.assign(n,false);
        from.assign(n,-1);
        to.assign(m,-1);
        bool update = true;
        while (update) {
            update = false;
            for (int i = 0; i < n; i++) if (from[i] == -1 && dfs(i)) { update = true; res++; }
            if (update) used.assign(n,false);
        }
        return res;
    }
};

int main(){
    int n; cin >> n;
    int a[n], b[n], c[n], d[n];
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,n) cin >> c[i] >> d[i];
    Match data(n,n);
    rep(i,n) rep(j,n) if(a[i] < c[j] && b[i] < d[j]) data.add_edge(i,j);
    cout << data.solve() << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

int N;

int main(){
	cin>>N;
	N%=1000;
	N=1000-N;
	N%=1000;
	cout<<N<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	int n;
	cin >> n;
		
	vector<int> a(n + 1);
	vector<int> b(n);

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

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

	ll ans = 0;

	for (int i = 0; i < n; i++) {
		int num = min(a[i], b[i]);
		ans += num;
		b[i] -= num;
		a[i] -= num;
		num = min(a[i + 1], b[i]);
		ans += num;
		b[i] -= num;
		a[i + 1] -= num;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int D; cin >> D;
	cout << "Christmas";
	REP(i, (25 - D)) {
		cout << " Eve";
	}
	cout << endl;
}

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


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

int main()
{
    ll i, j, m, t, k, ans = 0, q1 = 0, q2 = 0;
    cin >> t;
    map < string, ll > mp;
    m = t;
    while(t--)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    ll mx = INT_MIN;
    for(auto it : mp){
        if(it.second > mx){
            mx = it.second;
        }
    }
    for(auto it : mp){
        if(it.second == mx)
            cout << it.first << endl;
    }

    return 0;
}


Measured memory_bytes: 25216
#include <stdio.h>
#define MOD 1000000007
typedef long long ll;
ll modpow(ll a, ll n) {
	if (n == 0)
		return 1;
	if (n == 1)
		return (a % MOD);
	if (n % 2 == 1)
		return (a * modpow(a, n - 1) % MOD);
	ll t = modpow(a, n / 2);
	return (t * t % MOD);
}
ll comb(ll n, ll r) {
	ll res = 1;
	for (int i = n; i > n - r; i--) {
		res *= i;
		res %= MOD;
	}
	ll y = 1;
	for (int i = 2; i <= r; i++) {
		y *= i;
		y %= MOD;
	}
	y = modpow(y, MOD - 2);
	res = res * y % MOD;
	return res;
}
int main() {
	int n, a, b;
	ll ans = 1;
	scanf("%d%d%d", &n, &a, &b);
	ans = modpow(2, n) - 1 - comb(n, a) - comb(n, b);
	while (ans < 0) {
		ans += MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
a1 = gets.split(' ').map(&:to_i)
a2 = gets.split(' ').map(&:to_i)
a3 = gets.split(' ').map(&:to_i)
n = gets.chomp.to_i

b_numbers = []
result = []

n.times{|i|
    b_number = gets.chomp.to_i
    b_numbers << b_number
}

# あたりパターン全部書く
p1 = a1
p2 = a2
p3 = a3
p4 = [a1[0],a2[0],a3[0]]
p5 = [a1[1],a2[1],a3[1]]
p6 = [a1[2],a2[2],a3[2]]
p7 = [a1[0],a2[1],a3[2]]
p8 = [a1[2],a2[1],a3[0]]

patarns = [p1,p2,p3,p4,p5,p6,p7,p8]

patarns.each{|patarn|
    if (patarn + b_numbers).uniq.length == n
        result << 'Yes'
    else
        result << 'No'
    end
}

if result.include?("Yes")
    puts 'Yes'
else
    puts 'No'
end

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

double l;
void solve() {
    cin >> l;
    auto tmp = l / 3;
    cout << tmp * tmp * tmp << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
    int na(int a)
    {int k=0;
    while(a%2==0)
    {a=a/2;
    k++;
    }
    return k;
    }
    int main()
    {
    int n,x,k,c=100;
    scanf("%d",&n);
    while(n>0)
    {
    scanf("%d",&x);
    k=na(x);
    if(k<c)
    c=k;
n--;
    }
    printf("%d",c);
    }

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int length = S.length();
        int cnt = 0;
        for(int i = 0; i < length / 2; i++){
            if(S.charAt(i) != S.charAt(length - i - 1)){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23124
//https://atcoder.jp/contests/dp/tasks/dp_a
//shauryakr

#include<bits/stdc++.h>
using namespace std;
int arr[200010];
int dp[200010];
int n;
int solve(int ind)
{
    if(ind == n-1)
        return 0;
    if(dp[ind] != -1)
        return dp[ind];
    int ans = 0;
    ans = solve(ind+1) + abs(arr[ind+1] - arr[ind]);
    if(ind+2 <= n-1)
        ans = min(ans, solve(ind+2) + abs(arr[ind+2] - arr[ind]));
    dp[ind] = ans;
    return ans;
}
int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0) << endl;
    return 0;
}

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

#pragma GCC optimize("O3")

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main() {
    int n;
    cin >> n;
    map<string, int> data;
    int bigger = 1;
    for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		data[s] += 1;
		if(data.at(s) > bigger) bigger = data.at(s);
		
	}
	vector<string> strs;
	for(auto it = data.begin(); it != data.end(); ++it) {
		if(it->second == bigger) {
			cout << it->first << "\n";
		}
	}
	
    return 0;
}


Measured memory_bytes: 19284
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

void solve() {
	int n; string s; cin >> n >> s;
    int res = 0;

    rep(i, n) {
        string t = s.substr(i);
        auto lcp = Zalgo(t);

        rep(j, (int)t.size()) {
            int l = min(lcp[j], j);
            res = max(res, l);
        }
    }

    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
INF = 10**9+7

def F(j,i):
    return (i*(j-i))%INF
dx = []
px = 0
sx = 0
for x in map(int,input().split()):
    dx.append(x-px)
    px = x
dy = []
py = 0
sy = 0
for y in map(int,input().split()):
    dy.append(y-py)
    py = y

for i in range(1,n):
    sx = (sx+(dx[i]*F(n,i))%INF)%INF 
for i in range(1,m):
    sy = (sy+(dy[i]*F(m,i))%INF)%INF
print((sx*sy)%INF)


Measured memory_bytes: 19452
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	table := make([]int, n)
	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var a int
			fmt.Scan(&a)
			table[a-1] = 1
		}
	}

	count := 0
	for i := 0; i < n; i++ {
		if table[i] == 0 {
			count++
		}
	}
	fmt.Printf("%d\n", count)
}


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

int A[55];

int main(){
    int n, mx = 0, mn = 0; cin >> n;
    for(int i=0;i<n;i++) cin >> A[i];

    mx = *max_element(A, A+n); mn = *min_element(A, A+n);
    cout << 2 * n - 1 << endl;
    if(abs(mn)<=abs(mx)){
        int x = distance(A, max_element(A, A+n)) + 1;
        for(int i=1;i<=n;i++) cout << x << ' ' << i << endl;
        for(int i=1;i<=n-1;i++) cout << i << ' ' << i + 1 << endl;
    }else{
        int x = distance(A, min_element(A, A+n)) + 1;
        for(int i=1;i<=n;i++) cout << x << ' ' << i << endl;
        for(int i=n;1<i;i--) cout << i << ' ' << i - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

def func(x):
    return x - 1

def main():
    N, M = map(int, input().split())
    P = list(map(func, map(int, input().split())))
    uni = UnionFind(N)
    for _ in range(M):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        uni.union(x, y)

    cnt = 0
    for i, p in enumerate(P):
        if uni.same(i,p):
            cnt += 1
    
    print(cnt)


if __name__ == "__main__":
    main()

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

using namespace std;

#define endl "\n"

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

   string s;
   cin>>s;
   
   long long int i,sum=0;
   
   for(i=0;i<s.length();++i)
    {
        sum+=(s[i]-48);
    }
    
    if(sum%9==0)
       cout<<"Yes";
       
    else
      cout<<"No";
   

     return 0;
}

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

using namespace std;

const int MAX_M=1000,MAX_N=1000;

int M,N;
char flg[MAX_M][MAX_N+1];
char emb[2][2+1];

int count(int m,int n){
	//上からm行目,下からn行目に含まれるJOI紋章
	int i,j;
	bool flag;
	int cnt=0;
	if (m!=0 && n!=0){
		flag=true;
		for (i=0;i<2;i++){
			for (j=0;j<2;j++){
				if (emb[i][j]!=flg[m-1+i][n-1+j]){
					flag=false;
				}
			}
		}
		if (flag) cnt++;
	}
	if (m!=0 && n!=N-1){
		flag=true;
		for (i=0;i<2;i++){
			for (j=0;j<2;j++){
				if (emb[i][j]!=flg[m-1+i][n+j]){
					flag=false;
				}
			}
		}
		if (flag) cnt++;
	}
	if (m!=M-1 && n!=0){
		flag=true;
		for (i=0;i<2;i++){
			for (j=0;j<2;j++){
				if (emb[i][j]!=flg[m+i][n-1+j]){
					flag=false;
				}
			}
		}
		if (flag) cnt++;
	}
	if (m!=M-1 && n!=N-1){
		flag=true;
		for (i=0;i<2;i++){
			for (j=0;j<2;j++){
				if (emb[i][j]!=flg[m+i][n+j]){
					flag=false;
				}
			}
		}
		if (flag) cnt++;
	}
	return cnt;
}

int main(){
	int i,j;
	scanf("%d %d",&M,&N);
	for (i=0;i<M;i++){
		scanf("%s",flg[i]);
	}
	for (i=0;i<2;i++){
		scanf("%s",emb[i]);
	}
	int all=0;	//古い旗に含まれる紋章の数
	for (i=0;i<M-1;i++){
		for (j=0;j<N-1;j++){
			bool flag=true;
			for (int s=0;s<2;s++){
				for (int t=0;t<2;t++){
					if (emb[s][t]!=flg[i+s][j+t]){
						flag=false;
					}
				}
			}
			if (flag) all++;
		}
	}
	int ma=all;
	for (i=0;i<M;i++){
		for (j=0;j<N;j++){
			//flg[i][j]をJ,O,Iに変える
			char f=flg[i][j];
			int c=count(i,j);
			flg[i][j]='J';
			int c2=count(i,j);
			ma=max(ma,all-c+c2);
			flg[i][j]='O';
			c2=count(i,j);
			ma=max(ma,all-c+c2);
			flg[i][j]='I';
			c2=count(i,j);
			ma=max(ma,all-c+c2);
			flg[i][j]=f;
		}
	}
	printf("%d\n",ma);
	return 0;
}

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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)
#define endl '\n'

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
inline int in() { int x; std::cin >> x; return x; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

bool f[8];
int c, cnt;
signed main()
{
  int n = in();
  rep(i, n) {
    int a = in();
    if (3200 <= a) c++;
    else if (!f[a / 400]) {
      f[a / 400]++;
      cnt++;
    }
  }

  cout << (cnt == 0 ? 1 : cnt) << " " << cnt + c << endl;
  return (0);
}

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

public class Main {
	int l, k;
	long[] dp;
	void run() {
		Scanner scan = new Scanner(System.in);
		l = scan.nextInt();
		k = scan.nextInt();
		dp = new long[l+1];
		System.out.println(dfs(l));
	}
	long dfs(int d) {
//		System.out.println("l: " + d + " " +Arrays.toString(dp));
		if (l == d) return dfs(d - 1) + dfs(d - k);
		if (d < 0) return 0;
		if (d < 2) return 1;
		if (dp[d] != 0)
			return dp[d];
		dp[d] = dfs(d - 2) + dfs(d - k - 1) + 1;
		return dp[d];
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



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

int main() {
  string str;
  cin >> str;
  if(str == "SUN") {
    cout << "7" << endl;
  }else if(str == "MON") {
    cout << "6" << endl;
  }else if(str == "TUE") {
    cout << "5" << endl;
  }else if(str == "WED") {
    cout << "4" << endl;
  }else if(str == "THU") {
    cout << "3" << endl;
  }else if(str == "FRI") {
    cout << "2" << endl;
  }else {
    cout << "1" << endl;
  }
}

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

int N, M;
int a[100010], b[100010];
map<pii, int> mp;

int check(int i, int s) {
  auto p = mp.lower_bound(pii(i + 1, i - s + 1))->first;
  return (p.first == i + 1 && p.second >= i - s + 1 && p.second <= i);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    mp[pii(b[i], a[i])]++;
  }
  int s = 1, ans = 0;
  for (int i = 0; i < N - 1; i++) {
    if (check(i, s)) ans++, s = 1;
    else s++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(abs(a-b)>pow(10,18))
        cout<<"'nfair"<<"\n";
    else if(k%2==0)
        cout<<a-b<<"\n";
    else
        cout<<b-a<<"\n";
        
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <utility> //pairを使う
using namespace std;

typedef unsigned long long ll;

const ll inf = 1000000000000;
const ll mod = 10007;

int main(){
	int a, b;
	cin >> a >> b;
	if(a + b >= 10){
		cout << "error" << endl;
	}else{
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
Option Explicit On
Option Strict On

Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")

        Dim A As Long = CLng(tmp(0))
        Dim B As Long = CLng(tmp(1))
        Dim K As Long = CLng(tmp(2))

        If A >= 1 Then
            If A <= K Then
                K -= A
                A = 0
            Else
                A -= K
                K = 0
            End If
        End If

        If B >= 1 Then
            If B <= K Then
                K -= B
                B = 0
            Else
                B -= K
                K = 0
            End If
        End If

        Console.WriteLine(A & " " & B)
        'Console.ReadLine()

    End Sub

End Module



Measured memory_bytes: 13536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  int d,t,s; cin>>d>>t>>s;
  cout<< (t*s<d? "No":"Yes") <<endl;
}


Measured memory_bytes: 3628
#最大値とその半分
#index不要

n= int(input())
a = list(map(int, input().split( )))
a.sort()
tmp = a[0]
for i in range(1,n-1):
    ##他参照
    if min(a[i],a[-1]-a[i])>min(tmp, a[-1]-a[i]):
        tmp = a[i]
print(a[-1],tmp)



Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vs = vector<string>;
using pint = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    ll k  = (a + b) / 2;

    if(abs(a-k) != abs(b-k)) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << k << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int MOD = 1e9 + 7;
inline int mul (int a, int b) {
    return ((ll)a * b) % MOD;
}
inline void add (int &a, int x) {
    a += x;
    if (a < 0) a += MOD;
    if (a >= MOD) a -= MOD;
}
inline int binpow (int a, int n) {
    int ans = 1;
    while (n) {
        if (n & 1) {
            ans = mul(ans, a);
        }
        a = mul(a, a);
        n >>= 1;
    }
    return ans;
}
inline int inv (int x) {
    return binpow(x, MOD - 2);
}
const int N = 2e5 + 11;
int f[N] = {}, fi[N] = {};
inline int C (int n, int k) {
    if (k > n) rr;
    return mul(f[n], mul(fi[k], fi[n - k]));
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < N; i++) f[i] = mul(f[i - 1], i);
    fi[N - 1] = inv(f[N - 1]);
    for (int i = N - 2; i >= 0; i--) {
        fi[i] = mul(fi[i + 1], i + 1);
    }
    int n, k, ans = 0;
    cin >> n >> k;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    sort(all(a));
    for (int i = 0; i < n; i++) {
        add(ans, mul(a[i], C(i, k - 1)));
        add(ans, -mul(a[i], C(n - 1 - i, k - 1)));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

using namespace std;
int main()
{
  long long W, H, x, y;
  cin >> W >> H >> x >> y;
  long long s = (long long)W * (long long)H;
  int flg = 0;
  if (W % 2 == 0 && W / 2 == x && H %2 == 0 && H / 2 == y) flg = 1;
  cout << s / 2;
  if (s % 2 == 1) cout << ".5";
  cout << ' ' << flg << endl;
  return 0;
}


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

using namespace std;
const int N = 51, MAXN = 387420489, LOG = 18;
int pw[LOG] = {1}, dp[1<<LOG], a[N];
long long C[N][N], F[N], ans;
char cnt[MAXN];

int bit(int a, int i) {return (a>>i)&1;}
void BT(int i, int mask, int c) {
    if (i == -1) {
        if (c % 2 == 0) ans += F[(int)cnt[mask]];
        else ans -= F[(int)cnt[mask]];
        return ;
    }
    for (int j = 0; j < 3; j++) BT(i - 1, mask + j * pw[i], c + (j > 0));
    return ;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k, A, O; cin >> n >> k >> A >> O;
    for (int i = 1; i < LOG; i++) pw[i] = pw[i - 1] * 3;
    for (int i = 0; i < N; i++) C[i][0] = 1;
    for (int i = 1; i < N; i++)
        for (int j = 1; j < N; j++) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= min(i, k); j++) F[i] += C[i][j];
    // --------------------------------------------------------------------
    for (int i = 0; i < LOG; i++) if (bit(A, i) && (!bit(O, i))) return cout << 0 << "\n", 0;
    vector <int> vec, B;
    for (int i = 0; i < n; i++) {
        int x, val = 1; cin >> x;
        for (int j = 0; j < LOG; j++) {
            if (bit(x, j)) {
                if (!bit(O, j)) val = 0;
            } else {
                if (bit(A, j)) val = 0;
            }
        }
        if (val) vec.push_back(x);
    }
    n = vec.size();
    for (int i = 0; i < LOG; i++) if (bit(O, i) && (!bit(A, i))) B.push_back(i);
    int log = B.size();
    if (log > 18) assert(0);
    for (int i = 0; i < n; i++) {
        for (int j = log - 1; j >= 0; j--) a[i] = (a[i]<<1) | bit(vec[i], B[j]);
        memset(dp, 0, sizeof dp), cnt[0]++;
        for (int mask = 1; mask < (1<<log); mask++) {
            int b = __builtin_ctz(mask);
            dp[mask] = dp[mask^(1<<b)] + pw[b] * (bit(a[i], b) + 1);
            cnt[dp[mask]]++;
        }
    }
    BT(log - 1, 0, 0);
    cout << ans << "\n";
}


Measured memory_bytes: 186940
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    int h, w, g;
    cin >> h >> w >> g;
    
    const int MOD = 1e9 + 7;
    vector<vector<int>> dp(h+1, vector<int>(8, 0));
    
    dp[0][0] = 1;
    repeat_from_to (i, 1, h) {
        repeat (k, (1 << (w-1))) {
            bitset<8> bs(k);
            
            if (bs[0] and bs[1]) continue;
            if (bs[1] and bs[2]) continue;
            if (bs[2] and bs[3]) continue;
            if (bs[3] and bs[4]) continue;
            if (bs[4] and bs[5]) continue;
            if (bs[5] and bs[6]) continue;
            
            if (bs[0]) {dp[i][0] += dp[i-1][1]; dp[i][1] += dp[i-1][0]; dp[i][0] %= MOD; dp[i][1] %= MOD;}
            if (bs[1]) {dp[i][1] += dp[i-1][2]; dp[i][2] += dp[i-1][1]; dp[i][1] %= MOD; dp[i][2] %= MOD;}
            if (bs[2]) {dp[i][2] += dp[i-1][3]; dp[i][3] += dp[i-1][2]; dp[i][2] %= MOD; dp[i][3] %= MOD;}
            if (bs[3]) {dp[i][3] += dp[i-1][4]; dp[i][4] += dp[i-1][3]; dp[i][3] %= MOD; dp[i][4] %= MOD;}
            if (bs[4]) {dp[i][4] += dp[i-1][5]; dp[i][5] += dp[i-1][4]; dp[i][4] %= MOD; dp[i][5] %= MOD;}
            if (bs[5]) {dp[i][5] += dp[i-1][6]; dp[i][6] += dp[i-1][5]; dp[i][5] %= MOD; dp[i][6] %= MOD;}
            if (bs[6]) {dp[i][6] += dp[i-1][7]; dp[i][7] += dp[i-1][6]; dp[i][6] %= MOD; dp[i][7] %= MOD;}
            if (!bs[0])            {dp[i][0] += dp[i-1][0]; dp[i][0] %= MOD;}
            if (!bs[0] and !bs[1]) {dp[i][1] += dp[i-1][1]; dp[i][1] %= MOD;}
            if (!bs[1] and !bs[2]) {dp[i][2] += dp[i-1][2]; dp[i][2] %= MOD;}
            if (!bs[2] and !bs[3]) {dp[i][3] += dp[i-1][3]; dp[i][3] %= MOD;}
            if (!bs[3] and !bs[4]) {dp[i][4] += dp[i-1][4]; dp[i][4] %= MOD;}
            if (!bs[4] and !bs[5]) {dp[i][5] += dp[i-1][5]; dp[i][5] %= MOD;}
            if (!bs[5] and !bs[6]) {dp[i][6] += dp[i-1][6]; dp[i][6] %= MOD;}
            if (!bs[6])            {dp[i][7] += dp[i-1][7]; dp[i][7] %= MOD;}
            
            //dump(i); cout << " k=" << bs << " ";
            //vdump(dp[i]); el;
            
            repeat_from_to (j, w, 7) dp[i][j] = 0;
         }
    }
    cout << dp[h][g-1] << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a % 2 == b % 2){
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

# define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define cases cin >> tests; while(tests--)
# define int long long
# define ch cout << "no rest for the wicked\n\n";
# define ch1(x) cout << '\n' << #x" : " << x << '\n';
# define ch2(x, y) cout << '\n' <<  #x" : " << x << " || " << #y" : " << y << '\n';
# define lcm(a, b) (((a) * (b))/__gcd(a, b))
# define fore(i, n) for(auto i = 0; i < n; i++)

void solve()
{
    int a, b;
    cin >> a >> b;
    int arr[16] = {0};
    int i = 0;
    if(a > 8 || b > 8)
        cout << ":(";
    else
        cout << "Yay!";
    
}

signed main()
{
    fast;
    
    int tests = 1;
    
    // cases
    solve();
    
    return 0;
}

Measured memory_bytes: 256
import sys
n=input()
kaisuu = 0
ans = 0
if int(n) == 1:
    print(1)
    sys.exit()
for i in range(1,int(n)+1):
    count = 0
    num = i
    while(num % 2 == 0):
        count = count + 1
        num /= 2
    if kaisuu < count:
        kaisuu = count
        ans = i

print(ans)


Measured memory_bytes: 3060
# 0114

def gcd(a, b):
	if b == 0: return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

while True:
	try:
		x, y, z = 1, 1, 1
		c1, c2 ,c3 = 0, 0, 0
		a1, m1, a2, m2, a3, m3 = map(int, input().split())
		
		if sum([a1, m1, a2, m2, a3, m3]) == 0:
			break

		while True:
			x = a1 * x % m1
			c1 += 1
			if x == 1:
				break

		while True:
			y = a2 * y % m2
			c2 += 1
			if y == 1:
				break

		while True:
			z = a3 * z % m3
			c3 += 1
			if z == 1:
				break

		print(int(lcm(c1, lcm(c2, c3))))

	except EOFError:
		break

Measured memory_bytes: 6740
def main():
    L, R = map(int, input().split())
    ans = 9999
    for i in range(L, min(R+1, L+2019)):
        for j in range(i+1, min(R+1, L+2019)):
            if (i*j%2019) < ans:
                ans = i*j%2019
    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;


int main()
{
   int n;
   scn(n);

   vector<vector<double>> dp(n+1, vector<double>(n+1, 0.0));
   // dp[i][j] : Probability of getting j heads from first i turns.

   dp[0][0] = 1.0; // Probability of getting 0 heads from 0 turns is 1.0.

   rep(i, 1, n+1) {
      double p;
      scanf("%lf", &p);

      rep(j, 0, i+1) {
         if(j > 0)
         dp[i][j] = p * dp[i-1][j-1];

         dp[i][j] += (1-p) * dp[i-1][j];
      }
   }

   double ans = 0.0;

   rep(i, (n+1)/2, n+1)
      ans += dp[n][i];

   printf("%.12lf", ans);
   return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    ll ans=0;
    vector<ll> l(n+1);
    l[0]=2;
    l[1]=1;
    for(int i=2;i<=n;i++){
        l[i]=l[i-2]+l[i-1];
    }
    cout<<l[n]<<endl;
}

Measured memory_bytes: 256
(N,M,K),A,B = $<.map{|ln| ln.split.map(&:to_i) }

a,b,k = 0,0,K
(k-=A[a]; a+=1) while a<A.size && A[a]<=k
(k-=B[b]; b+=1) while b<B.size && B[b]<=k
nmax = a+b
while 0<a && b<B.size
	(a-=1; k+=A[a]) while 0<a && k<B[b]
	(k-=B[b]; b+=1) while b<B.size && B[b]<=k
	nmax = a+b if nmax<a+b
end
p nmax


Measured memory_bytes: 41604
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int a, b; cin >> a >> b;
    cout << b / 2 + a << endl;
}

Measured memory_bytes: 3536
n,m,c = map(int,input().split())

b = list(map(int, input().split()))
a = []

for i in range(n):
    a.append(list(map(int, input().split())))
sum = 0
count = 0

for i in range(n):
    for j in range(m):
        sum = sum + b[j]*a[i][j]


    if(sum+c>0):
        count = count + 1
    sum = 0

print(count)


Measured memory_bytes: 3064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> K;
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	if (K == 2) {
		long long int ans = 0;
		int num = 0;
		for(auto i:s) {
			if ((i - '0') % 2 == 0){
				num++;
			}
			ans += num;
		}
		cout << ans << endl;
		return 0;
	}
	if (K == 5) {
		long long int ans = 0;
		int num = 0;
		for (auto i : s) {
			if ((i - '0') % 5 == 0) {
				num++;
			}
			ans += num;
		}
		cout << ans << endl;
		return 0;
	}
	vector<int>num(K + 1);
	num[0] = 1;
	long long int ans = 0;
	long long int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += power(10, i, K)*(s[i] - '0') % K;
		sum %= K;
		ans += num[sum];
		num[sum]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
#include<cstring>

using namespace std;

int main()
{
	long long h;
	long long n;
	vector<pair<long long, long long>> arr;

	scanf("%lld %lld", &h, &n);

	for (long long i = 0; i < n; i++)
	{
		long long input1, input2;

		scanf("%lld %lld", &input1, &input2);

		arr.push_back({ input1,input2 });
	}

	long long dp[10001];

	memset(dp, -1, sizeof(dp));

	dp[0] = 0;

	for (long long i = 0; i < h; i++)
	{
		if (dp[i] == -1)
		{
			continue;
		}

		for (long long j = 0; j < n; j++)
		{
			long long nstate, cost;

			nstate = i + arr[j].first < h ? i + arr[j].first : h;

			cost = dp[i] + arr[j].second;

			if (dp[nstate] == -1 || cost < dp[nstate])
			{
				dp[nstate] = cost;
			}
		}
	}

	printf("%lld\n", dp[h]);

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B;
	cin >> A >> B;

	cout << (A * B) - (A + B) + 1;

	return 0;
}


Measured memory_bytes: 3584