akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m,a,b,c;
    vec dist(2000);
    pvvec x(3000);
    
    cin>>n>>m;
    rep(i,m){
        cin>>a>>b>>c;
        a--;b--;
        x[a].eb(b,c);
    }
    rep(i,n){
        dist[i]=-INF;
    }
    dist[0]=0;
    ll p=dist[n-1];
    rep(i,8*n){
        rep(j,n){
            for(P k:x[j]){
                dist[k.fs]=max(dist[k.fs],dist[j]+k.sc);
            }
        }
        if(p!=dist[n-1]&&i>=5*n){
            cout<<"inf"<<endl;
            return 0;
        }
        p=dist[n-1];
    }
    cout<<dist[n-1]<<endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, a, b;
    cin >> n >> a >> b;

    int res = 0;
    REP(i, 1, n + 1) {
        int t = 0;
        int x = i;
        while(x > 0) {
            t += x % 10;
            x /= 10;
        }
        if (t >= a && t <= b) res += i;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

vector<pair<char, int>> runLengthEncoding(string &s) {
    int n = s.size();

    vector<pair<char, int>> res;
    char pre = s[0];
    int cnt = 1;
    for(int i=1;i<n;i++) {
        if (pre != s[i]) {
            res.push_back({ pre, cnt });
            pre = s[i];
            cnt = 1;
        }
        else cnt++;
    }

    res.push_back({ pre, cnt });
    return res;
}

void solve(){
    string S;
    cin >> S;
    auto res = runLengthEncoding(S);
    cout << res.size() - 1 << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 1480
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main() {
  int n;
  readf (" %d", &n);
  auto a = new int[n];
  auto c = new int[n];
  foreach (i; 1 .. n) {
    readf (" %d", a[i]);
    ++c[a[i] - 1];
  }
  writefln!"%(%s\n%)"(c);
}



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

using namespace std;

int main(){
    int N;
    cin >> N;
    int h[N + 100];
    for (int i = 0; i < N; i++){
        int hito;
        cin >> hito;
        h[hito - 1] = i;
    }

    for (int j = 0; j < N; j++){
        cout << h[j] + 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
//1000未満切り上げ
int main(){
  int weeks;
  int debt = 100000;
  cin >> weeks;
  for(int i=0;i<weeks;i++){
    debt *= 1.05;
    if(debt%1000)
      debt += (1000 - debt%1000);
  }
  cout << debt <<endl;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define int long long
const int MOD=998244353;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
int blo[450],wa[450],s[223456],K[450];

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,q;cin>>n>>q;
  for(int i=0,tmp=0;i<n;i++){
    s[i]=1;
    tmp=((tmp*10)+1)%MOD;
    if(i%450==449||i==n-1){
      blo[i/450]=tmp;
      tmp=0;
    }
  }
  K[0]=1;
  for(int i=1;i<450;i++)K[i]=(K[i-1]*10)%MOD;
  const int A=pw(10,450);
  const int C=(A-1)*pw(9,MOD-2)%MOD;
  while(q--){
    int l,r,d;cin>>l>>r>>d;
    l=n-l+1,r=n-r;swap(l,r);
    int res=0;
    for(int i=0,CC=1;i<450;i++){
      if(l<=i*450&&(i+1)*450<=r){
        wa[i]=d;
        blo[i]=C*d;
      }
      else if((i*450<=l&&l<(i+1)*450)||(i*450<r&&r<=(i+1)*450)){
        int tmp=0;
        for(int j=i*450,t=0;j<(i+1)*450;j++,t++){
          if(wa[i])s[j]=wa[i];
          if(l<=j&&j<r)s[j]=d;
          tmp=(tmp+s[j]*K[t])%MOD;
        }
        blo[i]=tmp;
        wa[i]=0;
      }
      res=(res+blo[i]*CC)%MOD;
      (CC*=A)%=MOD;
    }
    cout<<res<<"\n";
  }
}


Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

ll solve(ll i, ll j,ll weig,vector<ll>&weight,vector<ll>&value,vector<vector<ll>>&dp )
{
  if(i>j)return 0;

  if(weig<=0) return 0;
  if(dp[i][weig]!=-1)
  {
    return dp[i][weig];
  }
  if(weight[i]>weig)
  {
       dp[i][weig]=solve(i+1,j,weig,weight,value,dp);
  }
   else
   {
     dp[i][weig]=max(value[i] + solve(i+1,j,weig-weight[i],weight,value,dp),solve(i+1,j,weig,weight,value,dp));
   }

  return dp[i][weig];

}

int main()
{
  ll n,w;
  cin>>n>>w;
  vector<ll>weight;
  vector<ll>value;
  
  vector<vector<ll>>dp(101,vector<ll>(100001,-1));
  for(ll i=0;i<n;i++)
  {
    ll a,b;
    cin>>a>>b;
    weight.push_back(a);
    value.push_back(b);
  }

  cout<<solve(0,n-1,w,weight,value,dp)<<endl;
}


Measured memory_bytes: 83252
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
    long N;
    std::cin >> N;
    long t[100000];
    long x[100000];
    long y[100000];
    for(long i=0; i<N; i++){
        std::cin >> t[i] >> x[i] >> y[i];
    }
    int flag=1;
    for(long i=0; i<N; i++){
        if(t[i]%2==0){
            if((x[i]+y[i])%2==1 || x[i]+y[i]>t[i]){
                flag=0;
                break;
            }
        }
        if(t[i]%2==1){
            if((x[i]+y[i])%2==0 || x[i]+y[i]>t[i]){
                flag=0;
                break;
            }
        }
    }
    if(flag==1){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2560
class Node():
    def __init__(self, key, p, l, r):
        self.key, self.p, self.l, self.r = key, p, l, r


class BinarySearchTree():
    def __init__(self):
        self.tree = []
        self.root = -1

    def insert(self, key):
        y = -1  # parent of x
        x = self.root
        while x != -1:
            y = x
            if key < self.tree[x].key:
                x = self.tree[x].l
            else:
                x = self.tree[x].r
        self.tree.append(Node(key, y, -1, -1))
        z = len(self.tree) - 1
        if y == -1:
            self.root = z
        elif key < self.tree[y].key:
            self.tree[y].l = z
        else:
            self.tree[y].r = z

    def preorder_traversal(self, u):
        if u == -1:
            return
        print(' ' + str(self.tree[u].key), end='')
        self.preorder_traversal(self.tree[u].l)
        self.preorder_traversal(self.tree[u].r)

    def inorder_traversal(self, u):
        if u == -1:
            return
        self.inorder_traversal(self.tree[u].l)
        print(' ' + str(self.tree[u].key), end='')
        self.inorder_traversal(self.tree[u].r)


def main():
    n = int(input())
    bst = BinarySearchTree()
    for _ in range(n):
        order = input().split()
        if order[0] == 'insert':
            key = int(order[1])
            bst.insert(key)
        elif order[0] == 'print':
            bst.inorder_traversal(0)
            print('')
            bst.preorder_traversal(0)
            print('')


if __name__ == '__main__':
    main()



Measured memory_bytes: 124892
n = int(input())
b = input()
ans = 0
for i in range(n):
    pre = 0
    temp = b[:i]
    for k in range(i, n):
        flag = True
        for dub in range(i, k):
            if b[dub] == b[k]:
                flag = False
                break
        if flag:
            for com in temp:
                if b[k] == com:
                    pre += 1
                    break
    if pre > ans:
        ans = pre
print(ans)


Measured memory_bytes: 40816
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> T {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}


fn main() {
    let s = stdin();
    let mut s = s.lock();
    let s = &mut s;

	let n = read::<usize>(s);
	let mut tt = Vec::<i64>::new();
	tt.resize(n , 0);
	let mut sm = Vec::<i64>::new();
	sm.resize(n, 0);

	for i in 0 .. n {
		tt[i] = read::<i64>(s);
	}

	let mut i: usize = n-1;
	let mut s: i64 = 0;
	while i != 0 {
		sm[i] = s + tt[i];
		s = sm[i];
		i -= 1;
	}


	let mut rem :i128 = 0;
	for i in 0 .. n-1 {
		rem = (tt[i] as i128 * sm[i+1] as i128 + rem) % 1000_000_007;
	}
	println!("{}", rem);


}


Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
vector<int> g[N];

bool vis[N];
int dp[N];
void dfs(int v){
	vis[v] = true;
	for(int to:g[v]){
		if (!vis[to]){
			dfs(to);
		}
		dp[v] = max(dp[v], dp[to] + 1);
	}
}
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
	}
	for(int i=1; i<=n; i++){
		if (!vis[i]) dfs(i);
	}
	int ans = 0;
	for(int i=1; i<=n; i++){
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8320
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

long long len;
vector<string> s;

long long solve(int i, int a, int b)
{
    if(b < a){
        long long x = len + 1 - i;
        if(x == 0)
            return 0;
        long long ans = 1;
        while(x % 2 == 0){
            x /= 2;
            ans *= 2;
        }
        return ans;
    }
    if(i == s[a].size())
        return 0;

    int c = a;
    while(c <= b && s[c][i] == '0')
        ++ c;
    return solve(i+1, a, c-1) ^ solve(i+1, c, b);
}

int main()
{
    int n;
    cin >> n >> len;
    s.resize(n);
    for(int i=0; i<n; ++i)
        cin >> s[i];
    sort(s.begin(), s.end());

    if(solve(0, 0, n-1))
        cout << "Alice" << endl;
    else
        cout << "Bob" << endl;

    return 0;
}


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

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)
#define pii pair<int, pair<int,int> >

int main() {
int N,M,t,s,d,i;
  while(cin>>N>>M, N|M) {
    vector<pii > v;
    vector<int> infected(N,0);
    infected[0] = 1;
    rep(i,M) {
      cin>>t>>s>>d;
      v.push_back(pii(t, pair<int,int>(s-1,d-1)));
    }
    sort(v.begin(), v.end());
    rep(i,M) {
      int ts = v[i].second.first,td = v[i].second.second;
      if(infected[ts] && !infected[td] && infected[ts] <= v[i].first)
	infected[td] = v[i].first+1;
    }
    int ans = 0;
    rep(i,N) {
      if(infected[i]) ans++;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1592
#include <iostream>

using namespace std;

const int Max = 1e6 + 5, Nmax = 2e5 + 5;
int H[Max],a[Nmax];
int N, ans;
bool OK;

int main()
{
    cin >> N;

    for(int i = 1; i <= N; ++i)
    {
        cin >> a[i];
        H[a[i]]++;
    }

    if(H[1])
        return cout << (H[1] == 1 ? 1 : 0), 0;

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

        if(H[a[i]] > 1)
            OK = 0;

        for(int j = 2; j * j <= a[i] && OK; ++j)
        {
            if(a[i] % j == 0 && H[j])
                OK = 0;

            if(a[i] % (a[i] / j) == 0 && H[a[i] / j])
                OK = 0;
        }

        ans += OK;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 8076
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
A,B=LI()
print(A*B)


Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0)
int main()
{
    double t,k;
    vector<ll>v;
    string s;
    cin>>t;
    k=2.0*pi*t;

    cout<<fixed<<setprecision(2)<<k<<endl;
}



Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define _min(x, y) x = min(x, y)
#define _max(x, y) x = max(x, y)
using namespace std;
#define NMAX 300005


double dp[605];

int main() {
  int N, M; cin >> N >> M;
  map<int, vector<int> > to;
  rep(i, M) {
    int s, t; cin >> s >> t;
    to[s].push_back(t);
  }
  dp[N] = 0;
  double ans = 1e18;
  for (int k = 0; k < N; k++) {
    for (int i = N - 1; i > 0; i--) {
      int n = 0;
      double maxdp = 0;
      double sum_dp = 0;
      for (int j: to[i]) {
        sum_dp += dp[j];
        _max(maxdp, dp[j]);
        n ++;
      }
      if (i == k && n >= 2) {
        sum_dp -= maxdp;
        n --;
      }
      dp[i] = sum_dp / n + 1;
    }
    _min(ans, dp[1]);
  }
  cout << setprecision(12) << ans << endl;

  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll ha,aa,hb,ab;
    cin>>ha>>aa>>hb>>ab;
    while(ha>0&&hb>0){
        hb-=aa;
        ha-=ab;
    }
    if(hb<=0)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define print(a) {\
    for (auto i : a) cout << i << ' ';\
    cout << '\n';\
}
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define pii pair<int,int> 
#define pll pair<lli,lli>
#define tiii tuple<int,int,int>
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int mod = 998244353, x = 864197532, N = 100000;

int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s == "ARC") cout << "ABC\n";
	else cout << "ARC\n";
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		double W = double.Parse(str[0]);
		double H = double.Parse(str[1]);
		long X = long.Parse(str[2]);
		long Y = long.Parse(str[3]);
		double ans = W*H/2;
		long t = 0;
		if(X*2==W && Y*2==H){
			t = 1;
		}
		Console.WriteLine(ans+" "+t);
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
const int maxn=1e5+9;

ll h[maxn];
ll n,a,b;

int check(ll mid)
{
    ll ans=mid;
    for(int i=1;i<=n;i++)
    {
        ll tt=h[i]-b*mid;
        if(tt>0)
        {
            ll cnt=tt/(a-b)+(tt%(a-b)==0?0:1);
            ans-=cnt;
            if(ans<0)return 0;
        }
    }
    return 1;
}

int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    for(int i=1;i<=n;i++)scanf("%lld",&h[i]);
    ll l=0,r=INF;
    ll ans=INF;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(check(mid))ans=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;
long N;
long a[105];
map<long, long> coun;
vector<pair<long, long> > vec;

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
		coun[a[i]]++;
	}
	for(auto c:coun){
		vec.push_back(make_pair(c.first, c.second));
	}
	sort(vec.begin(), vec.end());
	//for(int i = 0; i < vec.size(); i++){
	//	cout << vec[i].first << ":" << vec[i].second << endl;
	//}

	if(N == 1){
		return 1;
	}

	//直径偶数
	if(vec[vec.size() - 1].first % 2 == 0){
		//最小はvec[vec.size() - 1].first/2,1つ
		if(vec[0].first != vec[vec.size() - 1].first/2 || vec[0].second != 1){
			cout << "Impossible" << endl;
			return 0;
		}
	//直径奇数
	}else{
		//最小は(vec[vec.size() - 1].first+1)/2, 2つ
		//最小はvec[vec.size() - 1].first/2,1つ
		if(vec[0].first != (vec[vec.size() - 1].first+1)/2 || vec[0].second != 2){
			cout << "Impossible" << endl;
			return 0;
		}
	}

	//距離は連続する
	for(int i = 2; i < vec.size(); i++){
		if(vec[i-1].first + 1 != vec[i].first){
			cout << "Impossible" << endl;
			return 0;
		}
	}

	for(int i = 1; i < vec.size(); i++){
		if(vec[i].second < 2){
			cout << "Impossible" << endl;
			return 0;
		}
	}

	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    s=chomp(readline())
    ans="Yes"
    for i in 1:a+b+1
        if i==a+1
            if s[i]!='-'
                ans="No"
            end
        elseif !('0'<=s[i]<='9')
            ans="No"
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 111580
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N,i;
    cin >>N;
    cout << "Christmas";
    for(i=0;i<25-N;i++){
      cout <<" Eve";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N;
int A[100005];
long long sum;
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i], sum += A[i];
}

void Solve()
{
    if(sum % ((1LL * N * (N + 1)) / 2) != 0)
    {
        cout << "NO\n";
        return;
    }
    long long s = sum / (1LL * N * (N + 1) / 2);
    A[N + 1] = A[1];
    for(int i = 2; i <= N + 1; i++)
    {
        long long aux = A[i] - A[i - 1];
        aux = s - aux;
        if(aux % N != 0 || aux < 0)
        {
            cout << "NO\n";
            return;
        }
    }
    cout << "YES\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  int mod=1000000007;
  long long total=0;
  for (int i=0; i<n; i++){
    cin>>a[i];
    total+=a[i];
    total%=mod;
  }
  
  long long ans=0;
  
  for (int i=0; i<n; i++){
    total-=a[i];
    if (total<0) total+=mod;
    ans+=a[i]*total;
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

int main(){
        while(1){
         int x,y,t;
         cin >> x >> y;
         if(x == 0 && y == 0)break;
         if(x > y) {t = x;x = y;y = t;}
         cout << x << " " << y <<endl;
        }

        return 0;
}

Measured memory_bytes: 1160
def main():
    Q = int(input())
    XY = []
    for i in range(Q):
        X = input()
        Y = input()
        XY.append((X,Y))
    for X,Y in XY:
        
        LX,LY = len(X), len(Y)
        dp = [0 for _ in range(LY+1)]

        for i in range(LX):
            ex = dp[:]
            for j in range(LY):
                if X[i] == Y[j]:
                    dp[j+1] = ex[j] + 1
                elif dp[j+1] < dp[j]:
                    dp[j+1] = dp[j]
        print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 5664
n,m = map(int,input().split())
c = [[] for _ in range(n)]
for i in range(m):
    s,x = map(int,input().split())
    c[s-1].append(x)

r = 0
d = [-1 for _ in range(n)]

for i in range(n):
    if len(set(c[i])) > 1:
        r = -1
        break
    elif len(c[i]) == 0:
        continue
    else:
        if i == 0 and n > 1 and c[i][0] == 0:
            r = -1
            break
        d[i] = c[i][0]

if r == -1:
    print(r)
else:
    if n == 3:
        if d[0] == -1:
            d[0] = 1
        if d[1] == -1:
            d[1] = 0
        if d[2] == -1:
            d[2] = 0
    elif n == 2:
        if d[0] == -1:
            d[0] = 1
        if d[1] == -1:
            d[1] = 0
    else:
        if d[0] == -1:
            d[0] = 0
    print(''.join(map(str,d)))

Measured memory_bytes: 3064
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,x,t=mp()
print(((n-1)//x+1)*t)

Measured memory_bytes: 72708
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    int x,y;
    Pi red[N];
    REP(i,N) {
        cin>>x>>y;
        red[i] = Pi(x,y);
    }
    Pi blue[N];
    REP(i,N) {
        cin>>x>>y;
        blue[i] = Pi(x,y);
    }
    sort(red,red+N);
    sort(blue,blue+N);
    int ans = 0;
    int used[N]; REP(i,N) used[i]=0;
    REP(i,N) {
        vector<Pi> inds;
        REP(j,N) if (!used[j] && red[j].first<blue[i].first && red[j].second<blue[i].second) inds.push_back(Pi(red[j].second,j)); 
        if (!inds.empty()) {
            sort(inds.begin(),inds.end());
            used[inds[inds.size()-1].second] = true;
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
M = [[0]*n for _ in range(n)]

for _ in range(n):
    u, k, *V = map(int, input().split())
    if k == 0:
        continue
    else:
        for v in V:
            M[u-1][v-1] = 1

color = ['White']*n

time = 0
d = [0]*n
f = [0]*n
def dfs_visit(u=0):
    global time
    color[u] = 'Gray'
    time += 1
    d[u] = time
    for v in range(n):
        if M[u][v] == 0:
            continue
        if color[v] == 'White':
            dfs_visit(v)
    color[u] = "Black"
    time += 1
    f[u] = time

def dfs():
    for u in range(n):
        if color[u] == 'White':
            dfs_visit(u)
    for u in range(n):
        print('{} {} {}'.format(u+1, d[u], f[u]))


dfs()


Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); i++)
 
int main() {
 ll n,ans,l0,step;
  ans=1;
  l0=2;
  cin>>n;
  if(n>=2){
   rep(i,n-1){
    step=ans;
    ans=ans+l0;
     l0=step;
   }
  }
  cout<<ans<<endl;
}


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

using namespace std;

int a[300300];

int main()
{
	int N,Q;
	scanf("%d%d",&N,&Q);
	for(int i=0;i<N;i++) scanf("%d",a+i);
	sort(a,a+N);
	reverse(a,a+N);
	for(int q=0;q<Q;q++)
	{
		int n;
		scanf("%d",&n);
		int ans=0;
		if(n==1)
		{
			printf("0\n");
			continue;
		}
		for(int i=1;(i-1)*n<=300300;i++)
		{
			int num=i*n;
			int id=upper_bound(a,a+N,num,greater<int>())-a;
			if(id==N) continue;
			if(a[id]<=num-n) continue;
			ans=max(ans,a[id]-(i-1)*n);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2224
// C - Candles
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,K; cin>>N>>K;
	vector<int> X(N); rp(i,0,N) cin>>X[i];
	int ans = INT_MAX;
	rp(ir,K-1,N){
		int il = ir - (K-1), l = X[il], r = X[ir];
		if(0 < l) ans = min(ans, abs(r));
		else if(r < 0) ans = min(ans, abs(l));
		else{ // l < 0 && 0 < r
				if(abs(l) > abs(r)) swap(l, r); // l: small, r: large
				ans = min(ans, abs(l)*2 + abs(r));
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 640
n = int(input())
a = [0] + [int(i) for i in input().split()]
retval = [0] * (n+1)

for i in range(n,0,-1):
    p = sum([retval[x] for x in range(i+i,n+1,i)])
    retval[i] = (p%2) ^ a[i]

print(sum(retval))
print(" ".join(str(i) for i in range(1,n+1) if retval[i]))


Measured memory_bytes: 90568
r, g, b = map(int, input().split())
op = int(input())
while op > 0 and g <= r:
    g *= 2
    op -= 1
while op > 0 and b <= g:
    b *= 2
    op -=1
if r < g and g < b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
 
using namespace std;
 
const int MAXN = 200 + 10;
const int MOD = 998244353;
 
struct TPoint
{
	long long x, y;
};
 
long long CrossProduct(TPoint A, TPoint B, TPoint C)
{
	return (B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x);
}
 
int n;
long long twomod[MAXN];
long long C[MAXN][MAXN];
long long arr[MAXN];
TPoint p[MAXN];
int used[MAXN];
int redu[MAXN];
 
void Work()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i ++)
		scanf("%lld%lld", &p[i].x, &p[i].y);
	twomod[0] = 1;
	for (int i = 1; i <= n; i ++)
		twomod[i] = (twomod[i - 1] + twomod[i - 1]) % MOD;
	C[0][0] = 1;
	for (int i = 1; i <= n; i ++)
	{
		C[i][0] = 1;
		for (int j = 1; j <= i; j ++)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
	}
 
	for (int tt = 3; tt <= n; tt ++)
	{
		arr[tt] = 0;
		for (int i = 3; i <= tt; i ++)
			arr[tt] = (arr[tt] + C[tt][i]) % MOD;
	}
 
	long long ans = arr[n];
	
	for (int i = 0; i < n; i ++)
		for (int j = 0; j < n; j ++) if (i != j)
		{
			long long c = 2;
			for (int k = 0; k < n; k ++) if (i != k && j != k)
				if (CrossProduct(p[i], p[j], p[k]) == 0)
					c ++;
			//printf("%d %d %d\n", i, j, c);
			redu[c] ++;
		}
 
	for (int c = 3; c <= n; c ++)
	{
		if (redu[c] == 0) continue;
		long long times = redu[c] / (c * (c - 1));
		ans -= (arr[c] * times) % MOD;
		ans += MOD;
		ans %= MOD;
	}
 
	printf("%lld\n", ans);
}
 
int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 512
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var) \
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

template <typename Iter>
int merge(Iter begin, Iter mid, Iter end) {
  if (begin == mid || mid == end) {
    return 0;
  }
  vector<int> lbuf;
  vector<int> rbuf;
  copy(begin, mid, back_inserter(lbuf));
  copy(mid, end, back_inserter(rbuf));
  auto lit = lbuf.begin();
  auto rit = rbuf.begin();
  for (auto it = begin; it != end; ++it) {
    if (lit == lbuf.end() && rit == rbuf.end()) {
      throw std::logic_error("FAIL");
    }
    decltype(lit)* xit;
    if (lit == lbuf.end()) {
      xit = &rit;
    } else if (rit == rbuf.end()) {
      xit = &lit;
    } else {
      xit = (*lit > *rit) ? &rit : &lit;
    }
    *it = *(*xit);
    ++(*xit);
  }
  assert(lit == lbuf.end());
  assert(rit == rbuf.end());
  return distance(begin, end);
}

template <typename Iter>
int mergeSort(Iter begin, Iter end) {
  auto d = distance(begin, end) / 2;
  int count = 0;
  if (d > 0) {
    auto mid = next(begin, d);
    count += mergeSort(begin, mid);
    count += mergeSort(mid, end);
    count += merge(begin, mid, end);
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  vector<int> nums;
  for (int t, i = 0; i < n; ++i) {
    cin >> t;
    nums.push_back(t);
  }
  auto count = mergeSort(nums.begin(), nums.end());
  bool first = true;
  for (auto&& num : nums) {
    if (!first) {
      cout << " ";
    }
    cout << num;
    first = false;
  }
  cout << endl << count << endl;
}

Measured memory_bytes: 7792
# include <iostream>
# include <vector>
# include <cmath>

# define f first
# define s second
using namespace std;

const int N = 1e5 + 100;
const int B = 20;

int n, q, timer, len;
int depth[N], dist[N];
int edges[N][2], LCA[N][B+2];
int tin[N], tout[N], fth[N][2];
vector < pair< int, int > > gr[N];
vector < int > sdst[N], scnt[N], dst(N,0), cnt(N,0);

void dfs( int v, int p )
{
    tin[v] = ++timer;
    depth[v] = depth[p] + 1;

    LCA[v][0] = p;
    for( int i = 1; i < B; i ++ )
        LCA[v][i] = LCA[ LCA[v][i-1] ] [i-1];

    for( auto ed: gr[v] ){
        if( ed.f == p ) continue;
        dist[ ed.f ] = dist[ v ] + edges[ ed.s ][ 1 ];
        fth[ed.f][0] = v;
        fth[ed.f][1] = ed.s;
        dfs( ed.f, v );
    }
    tout[v] = ++timer;
}
bool upper( int v, int u )
{
    return  ( tin[v] < tin[u] && tout[u] < tout[v] );
}
int lca( int v, int u )
{
    if( upper( v, u ) )return v;
    if( upper( u, v ) )return u;

    for( int i = B-1; i >= 0; i -- )
        if( !upper( LCA[v][i], u ) ) v = LCA[v][i];
    //cout << "lca :" << v << ' ' << u << ' ' << LCA[v][0] << endl;
    return LCA[v][0];
}
void spec_ver( int v, int p )
{
    if( depth[v] % len == 1 ){
        sdst[v] = dst;
        scnt[v] = cnt;
    }
    for( auto ed: gr[v] ){
        if( ed.f == p ) continue;
        dst[ edges[ed.s][0] ] += edges[ed.s][1];
        cnt[ edges[ed.s][0] ] ++;
        spec_ver( ed.f, v );
        dst[ edges[ed.s][0] ] -= edges[ed.s][1];
        cnt[ edges[ed.s][0] ] --;
    }
}
int get( int v, int x, int y )
{
    if( sdst[v].size() )
        return y * scnt[v][x] - sdst[v][x];
    int ret = 0;
    if( edges[ fth[v][1] ][0] == x )
        ret = y - edges[ fth[v][1] ][1];
    return ret + get( fth[v][0], x, y );
}
int main()
{
    ios_base::sync_with_stdio( false );
    cin.tie();
    cout.tie();
    cin >> n >> q;
    for( int i = 1; i < n; i ++ ){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        edges[i][0] = c; edges[i][1] = d;
        gr[a].push_back( make_pair( b, i ) );
        gr[b].push_back( make_pair( a, i ) );
    }
    tin[0] = 0;
    tout[0] = 2*N;
    len = sqrt( n )+1;
    dfs( 1, 0 );
    spec_ver( 1, 0 );
    /*
    for( int i = 1; i <= n;i  ++ ){
        cout << i << ' ' << depth[i] << ' ' << tin[i] << ' ' << tout[i] << endl;
    }
    */
    while ( q-- ){
        int x, y, v, u;
        cin >> x >> y >> v >> u;
        int _lca = lca( v, u );
        int D = dist[v] + dist[u] - 2*dist[ _lca ];
        //cout << v << ' ' << u << ' ' <<  _lca << endl;
        int g1 = get( v, x, y );
        int g2 = get( u, x, y );
        int g3 = get( _lca, x, y );
        D = D + g1 + g2 - 2*g3;
        cout << D << endl;
    }
    return 0;
}
/*
15 100
1 2 1 10
1 3 1 10
1 4 1 10
2 5 1 10
2 6 1 10
3 7 1 10
3 8 1 10
3 9 1 10
4 10 1 10
4 11 1 10
8 12 1 10
8 13 1 10
8 14 1 10
9 15 1 10
queries...
*/


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

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

  a += a;

  if (a.find(b) != std::string::npos) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n = int(input())
q = list(map(int, input().split()))
ls = []
for i in range(n):
  ls.append(q[i])
#print(ls)

ls.sort()

ct = 0
for j in range(n):
  if ls[j] != q[j]:
    ct += 1
#print(ct)
if ct <= 2:
  print("YES")
else:
  print("NO")

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

int main() {
    int K;
    cin >>K;
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int ans = v.at(K-1);
    cout <<ans <<endl;
}

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

int n,m;
vector<int> Ke[100005];
bool ap[100005],chuaxet[100005];
int num[100005],low[100005],parent[100005],root,children,counter;

void Input(){
	int x,y;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		Ke[x].push_back(y);
		Ke[y].push_back(x);
	}
}

void Init(){
	for(int i=0;i<n;i++){
		chuaxet[i]=true;
		ap[i]=false;
		num[i]=0;
		low[i]=0;
		counter=0;
		parent[i]=0;
	}
}
void DFS(int u){
	chuaxet[u]=false;
	low[u]=num[u]=++counter;
	for(int i=0;i<Ke[u].size();i++){
		int v=Ke[u][i];
		if(chuaxet[v]){
			parent[v]=u;
			if(u==root){
				children++;
			}
			DFS(v);
			if(low[v]>=num[u]&&u!=root){
				ap[u]=true;
			}
			low[u]=min(low[u],low[v]);
		}
		else if(v!=parent[u]){
			low[u]=min(low[u],num[v]);
		}
	}
}


int count(){
	int res=0;
	for(int i=0;i<n;i++){
		if(ap[i]){
			res++;
		}
	}
	return res;
}

int main(){
	int t;
	t=1;
	while(t--){
		Input();
		Init();
		for(int i=0;i<n;i++){
			if(chuaxet[i]){
				root=i;
				children=0;
				DFS(i);
				//cout<<children<<endl;
				if(children>1){
					ap[root]=true;
				}
			}
		}
		//cout<<count()<<endl;
		for(int j=0;j<n;j++){
			if(ap[j]){
				cout<<j<<endl;
			}
		}
		for(int i=0;i<n;i++){
			Ke[i].clear();
		}
	}
}


Measured memory_bytes: 6708
from functools import reduce
from fractions import gcd
from collections import defaultdict,Counter
import copy

n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

dic = defaultdict(int)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

for i in a:
    c = Counter(prime_factorize(i))
    for j,k in c.items():
        if dic[j] < k:
            dic[j] = k

l = 1

for i,j in dic.items():
    l *= pow(i,j,mod)

point = 0

for i in a:
    point += l*pow(i,mod-2,mod)
    point %= mod

print(point%mod)

Measured memory_bytes: 6584
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	input = input.map(e => toIntArr(e.split(' ')));
	var d = input[0][0];
	var cs = input[1];
	var ss = input.slice(2);
	var ts = input.slice(d+2).map(e=>e[0]);
	
	var score = 0;
	var ans = '';
	let type;
	let lastday = [];
	lastday.length = 26;
	lastday.fill(-1);

	let scoreDay = [];

	for(let i = 0; i < d; i++){
		type = ts[i];
		//console.log(ss[i][type-1])
		score += ss[i][type-1];
		lastday[type-1] = i;
		for(let j = 0; j < 26; j++){
			//console.log(cs[j] * (i - lastday[j]))
			score -= cs[j] * (i - lastday[j]);
		}

		scoreDay[i] = score;

	}

	console.log(scoreDay.join('\n'));
}

Measured memory_bytes: 30792
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       
       while(true){
           int a=sc.nextInt();
           String op=sc.next();
           int b=sc.nextInt();
           if(op.equals("?"))break;
           switch(op){
               case "+":
                System.out.println(a+b);
                break;
               case "-":
                System.out.println(a-b);
                break;
               case "*":
                System.out.println(a*b);
                break;
               case "/":
                System.out.println(a/b);
                break;
               
           }
           
           
       }
    }
}



Measured memory_bytes: 26128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())
 
int main()
{
    int n,k;
    cin >> n >> k;

    set<int> having;
    rep(i,k){
      int d;
      cin >> d;

      rep(j,d){
        int a;
        cin >> a;
        having.insert(a);
      }
    }

    int cnt = 0;
    for(int i=1; i<=n; i++){
      if(having.find(i)==having.end()) cnt++;
    }
    
    cout << cnt << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t>ans(N);
  int x=1;
  while(x*x<N){
    int y=1;
    while(x*x+y*y+x*y<N){
      int z=1;
        while(x*x+y*y+z*z+x*y+x*z+y*z<=N){
          ans.at(x*x+y*y+z*z+x*y+x*z+y*z-1)++;
          z++;
        }
      y++;
    }
    x++;
  }
  for(int i=0;i<N;i++){
    cout << ans.at(i) << endl;
  }
}

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

int main() {
	int A , B;
  	cin >> A >> B;
    int C = 0;
	for(int i = A; i <= B ; i++){
    	if(i / 10000 == i % 10){
        	if(i % 10000 / 1000 == i % 100 / 10){
            	C++;
            }
        }
    }
    cout << C << endl;
}


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

using namespace std;

int main(){
    int n,r;
    while(scanf("%d%d",&n,&r),n!=0){
        int card[51];
        for(int i=0;i<51;i++){
            card[i] = n-i;
        }

        while(r--){
            int p,c;
            cin >> p >> c;
            int tmp[51];
            for(int i=0;i<p-1;i++){
                tmp[i] = card[i];
            }
            for(int i=0;i<c;i++){
                card[i] = card[p-1+i];
            }
            for(int i=c;i<c+p-1;i++){
                card[i] = tmp[i-(c)];
            }
        }

        cout << card[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      ma: usize,
      mb: usize,
      abcs: [(usize,usize,usize); n],
    }
    const INF: usize = 1 << 31;
    let mut dp = vec![vec![vec![INF; 411]; 411]; n+1];
    dp[0][0][0] = 0;
    for i in 0..n {
        let (a, b, c) = abcs[i];
        for ca in 0..401 {
            for cb in 0..401 {
                let na = ca + a;
                let nb = cb + b;
                dp[i+1][na][nb] = min(dp[i][ca][cb] + c, dp[i+1][na][nb]);
                dp[i+1][ca][cb] = min(dp[i][ca][cb], dp[i+1][ca][cb]);
            }
        }
    }
    let mut ans = INF;
    for i in 1.. {
        let ma = ma * i;
        let mb = mb * i;
        if ma > 400 || mb > 400 {
            break;
        }
        ans = min(dp[n][ma][mb], ans);
    }
    if ans >= INF {
        println!("{}", -1);
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 65788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007



int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin>>n;
  ll a=1;ll b=n;
  for(ll i=2;i*i<=n;i++)
  {
    if(n%i==0)
    {a=i;b=n/i;}
  }
  cout<<(a+b-2)<<"\n";
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np
import collections as col

x = int(input())

if x == 1:
    print(0)
else:
    print(1)

Measured memory_bytes: 26632
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

struct Seg {
    int ro[2];
    int in[2];
    int st[2];
    Seg(int) {
	ro[0] = in[0] = 0;
	ro[1] = in[1] = 1;
    }

    Seg() {
	in[0] = in[1] = ro[0] = ro[1] = 1<<29;
    }
    Seg inc(int init) const {
	Seg z;
	if (init) {
	    z.ro[1] = ro[1] + 2;
	    z.ro[0] = z.ro[1] + 1;
	    z.in[1] = in[0] + 1;
	    z.in[0] = z.in[1] + 1;
	    if (ro[0] == 0) {
		amin(z.ro[0], 0);
		amin(z.ro[1], 1);
		amin(z.in[0], 0);
		amin(z.in[1], 1);
	    }
	} else {
	    z.ro[1] = ro[0] + 2;
	    z.ro[0] = z.ro[1] + 1;
	    z.in[1] = in[1] + 1;
	    z.in[0] = z.in[1] + 1;
	}
	return z;
    }
};

Seg operator+(const Seg &x, const Seg &y) {
    Seg z;
    REP (a, 2) REP (b, 2) {
	int c = a^b;
	amin(z.ro[c], x.ro[a] + y.ro[b]);
	amin(z.in[c], x.ro[a] + y.in[b]);
	amin(z.in[c], x.in[a] + y.ro[b]);
    }

    REP (a, 2) {
	amin(z.ro[a], z.ro[a^1] + 1);
	amin(z.in[a], z.in[a^1] + 1);
    }
    return z;
}

const int MAXN = 100011;
int N;
VI G[MAXN];
char C[MAXN];

VI ord;
Seg ans[MAXN], up[MAXN], dw[MAXN];
vector<Seg> L[MAXN], R[MAXN];

void treeDP() {
    ord.clear(); ord.reserve(N);
    ord.push_back(0);
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) {
	    ord.push_back(*e);
	    G[*e].erase(remove(G[*e].begin(), G[*e].end(), v), G[*e].end()); // remove parent
	}
    }

    REP (i_, N) {
	int v = ord[N-1-i_];
	int m = G[v].size();
	L[v].assign(m+1, Seg());
	R[v].assign(m+1, Seg());
	L[v][0] = Seg(-1);
	R[v][m] = Seg(-1);
	REP (i, m)
	    L[v][i+1] = L[v][i] + up[G[v][i]];
	for (int i=m; i--; )
	    R[v][i] = up[G[v][i]] + R[v][i+1];
	up[v] = R[v][0].inc(C[v]);
    }

    dw[0] = Seg(-1);
    REP (i_, N) {
	int v = ord[i_];
	ans[v] = (R[v][0] + dw[v]); // when v == 0, dw[v] is an empty tree
	REP (i, G[v].size()) {
	    int w = G[v][i];
	    dw[w] = (R[v][i+1] + dw[v] + L[v][i]).inc(C[v]); // add v own
	}
    }
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }

    scanf("%s", C);
    REP (i, N) C[i] = (C[i] == 'B');

    treeDP();

    int out = 1<<29;
    REP (i, N) {
	amin(out, ans[i].in[1-C[i]]);
    }

    printf("%d\n", out);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 30464