akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    for i in 1.. {
        let x: u32 = sc.next();
        if x == 0 {
            break;
        };
        println!("Case {}: {}", i, x);
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
}



Measured memory_bytes: 5048
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		
		if(c.equals ("a")||c.equals ("i") || c.equals("u")|| c.equals("e") || c.equals("o")) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		} 
		
			 
  	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String s = scan.next();
        
        int i=0;
        while(i<s.length())
        {
            System.out.print(s.charAt(i));
            i+=2;
        }
    }
}


Measured memory_bytes: 33684
#include<bits/stdc++.h>
using namespace std;
long long h;
long long num=1LL;
long long ans=0;
int main()
{
	cin>>h;
	while(1)
	{
		if(!h)
		{
			break;
		}
		h/=2LL;
		ans+=num;
		num*=2LL;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string w; cin >> w;
	vector<int> appear(26, 0);
	for (int i = 0; i < w.size(); i++)
	{
		appear[w[i] - 'a']++;
	}

	for (int i = 0; i < 26; i++)
	{
		if(appear[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	int a, b;
	cin >> a >> b;
	int cnt = 1;
	for (int ans = 0;; ans++)
	{
		if (cnt >= b)
		{
			cout << ans;
			return;
		}
		cnt += a - 1;
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

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

const ll INF = 1LL << 62;
const int EDGE_MAX = 2000;
const int VERT_MAX = 1001;

typedef struct Edge {
        int u;
        int v;
        ll cost;
} Edge;

Edge edges[EDGE_MAX];
bool negative[VERT_MAX];
ll dist[VERT_MAX];

int main() {

        int v_num, e_num;
        cin >> v_num >> e_num;

        for (int i=0; i<e_num; ++i) {
                int u, v;
                ll cost;
                cin >> u >> v >> cost;
                cost = -cost;
                edges[i].u = u;
                edges[i].v = v;
                edges[i].cost = cost;
        }

        for (int i=1; i<=v_num; ++i) {
                dist[i] = INF;
        }
        dist[1] = 0;

        for (int i=0; i<v_num-1; ++i) {
                for (int j=0; j<e_num; ++j) {
                        if (dist[edges[j].u]==INF) continue;
                        if (dist[edges[j].v] > dist[edges[j].u] +
                        edges[j].cost) {
                                dist[edges[j].v] = dist[edges[j].u] +
                                edges[j].cost;
                        }
                }
        }

        for (int i=0; i<v_num-1; ++i) {
                for (int j=0; j<e_num; ++j) {
                        if (dist[edges[j].u]==INF) continue;
                        if (dist[edges[j].v] > dist[edges[j].u] +
                        edges[j].cost) {
                                dist[edges[j].v] = dist[edges[j].u] +
                                edges[j].cost;
                                negative[edges[j].v] = true;
                        }
                        if (negative[edges[j].u] == true) {
                                negative[edges[j].v] = true;
                        }
                }
        }

        if (negative[v_num]) cout << "inf" << endl;
        else cout << -dist[v_num] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,ssss=0;
int a[200005],sum[200005],sumsss[200005];
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum[a[i]]++;
	}
	for(int i=1;i<=200000;i++){
		ssss=ssss+(sum[i]*sum[i]-sum[i])/2;
	}
	for(int i=1;i<=200000;i++){
		sumsss[i]=ssss-(sum[i]-1);
	}
	for(int i=1;i<=n;i++) 
		cout<<sumsss[a[i]]<<endl;
	return 0;
}

Measured memory_bytes: 6912
#!/usr/bin/env python3
import sys


def solve(N: int, Y: int):
    x, y, z = valid_nums2(N, Y)
    print("{} {} {}".format(x, y, z))
    return

def valid_nums(N, Y):
    for x in range(0, N+1):
        for y in range(0, N-x+1):
            z = N - x - y
            Y_ = 10000 * x + 5000 * y + 1000 * z
            if Y_ == Y:
                return x, y, z
    return -1, -1, -1

def valid_nums2(N, Y):
    for z in range(0, N+1):
        for y in range(0, N-z+1):
            x = N - z - y
            Y_ = 10000 * x + 5000 * y + 1000 * z
            if Y_ == Y:
                return x, y, z
    return -1, -1, -1

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    int H, W;
    while (1)
    {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0)
        {
            break;
        }
        for (int i = 1; i <= H; i++)
        {
            for (int j = 1; j <= W; j++)
            {
                if ((i + j) % 2 == 0)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2048
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]

x, y = gets.split.map(&:to_i)

if (a.include?(x) && a.include?(y)) ||
  (b.include?(x) && b.include?(y)) ||
  (x == 2 && y == 2)
  puts "Yes"
else
  puts "No"
end


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    string s;
    cin >> s;
    bool fN = false, fS = false, fE = false, fW = false;
    int n = s.size();
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'N') fN = true;
        if (s[i] == 'S') fS = true;
        if (s[i] == 'E') fE = true;
        if (s[i] == 'W') fW = true;
    }
    if ((fN ^ fS) || (fE ^ fW)) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 4100 + 100;
const int LOG = 22;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

int a[MAXN];
vector<pll> dp[20][20];

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n - 1; ++i) {
        dp[i][i + 1].pb({0, 0});
    }

    for (int len = 3; len <= n; ++len) {
        for (int l = 1; l <= n; ++l) {
            for (int r = l + len - 1; r <= n; ++r) {
                vector<pll> vals;
                for (int mid = l + 1; mid <= r - 1; ++mid) {
                    for (auto x:dp[l][mid]) {
                        for (auto y:dp[mid][r]) {
                            vals.pb({x.fi + x.se + y.fi + a[mid], x.se + y.fi + y.se + a[mid]});
                        }
                    }
                }
                sort(all(vals));
                dp[l][r].pb(vals[0]);
                ll mx = vals[0].se;
                for (int i = 1; i < sz(vals); ++i) {
                    if (vals[i].se >= mx) {
                        continue;
                    } else {
                        mx = vals[i].se;
                        dp[l][r].pb(vals[i]);
                    }
                }
            }
        }
    }

    ll ans = inf_ll;
    for(auto x:dp[1][n]){
        ans = min(ans, x.fi + x.se);
    }
    cout << ans + a[1] + a[n]<<"\n";
}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
    //  freopen("../output.txt", "w", stdout);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;
    while (t--)
        solve();

    if (debug)
        cerr << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 9636
#coding: utf-8

n, m, l = map(int, input().split())
mtxA = list()
mtxB = list()
for i in range(n):
    mtxA.append(list(map(int, input().split())))
for i in range(m):
    mtxB.append(list(map(int, input().split())))
for i in range(n):
    for j in range(l):
        if j > 0:
            print(' ', end = '')
        s = 0
        for k in range(m):
            s += mtxA[i][k] * mtxB[k][j]
        print(s, end = '')
        if j == l - 1:
            print('')


Measured memory_bytes: 6560
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll K;
ll A;
ll B;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> K;
    cin >> A;
    cin >> B;
    solve();
}

// 入力はすべて整数
// 1 <= A <= B <= 1000
// 1 <= K <= 1000

// ll K, ll A, ll B
// 目標の達成が可能であれば OK と、不可能であれば NG と出力せよ。
void solve(){
    ll C=B/K*K;
    cout<<(A<=C?"OK":"NG")<<endl;
}


Measured memory_bytes: 3648
import java.util.Scanner;


public class Main{

	static Scanner sc = new Scanner(System.in);
	
	static int a[] = new int[4], b[] = new int[4];
	static int s = 0, t = 0;
	
	public static void main(String[] args) {
		
		while(read()){
			solve();
		}

	}
	
	public static boolean read(){
		if(!sc.hasNext()) return false;
		
		for(int i=0; i < 4; i++){
			a[i] = sc.nextInt();
		}
		for(int i=0; i < 4; i++){
			b[i] = sc.nextInt();
		}
		
		return true;
	}
	
	public static void solve(){
		for(int i=0; i < 4; i++){
			s += a[i];
			t += b[i];
		}
		
		if(s >= t){
			System.out.println(s);
		}
		else{
			System.out.println(t);
		}
	}

}

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

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

	int n = scan.nextInt();
	int[] a = new int[n];
	for(int i = 0; i < n; i++){
	    a[i] = scan.nextInt();
	}

	Arrays.sort(a);

	System.out.println(a[n-1]-a[0]);
    }
}


Measured memory_bytes: 21972
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	/** 使用される文字の一覧 */
	private static final char[] BASES = new char[] { '3', '5', '7' };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String n = scanner.next();
			int answer = IntStream.range(3, n.length()).map(i -> calc(i)).sum();
			int[] number = new int[n.length()];
			Arrays.fill(number, 0);
			while (increaseNumber(number)) {
				String string = getNumber(number);
				if (string.compareTo(n) > 0) {
					break;
				} else {
					if (is753(number)) {
						answer++;
					}
				}
			}
			System.out.println(answer);
		}
	}

	/**
	 * numberで表す数字を一つ上げる
	 * 
	 * @param number
	 * @return 上げられない場合はfalse
	 */
	private static boolean increaseNumber(int[] number) {
		return increaseNumber(number, 0);
	}

	/**
	 * numberで表す数字は753数字かどうかを判定する
	 * 
	 * @param number
	 * @return numberで表す数字は753数字かどうか
	 */
	private static boolean is753(int[] number) {
		return BASES.length == Arrays.stream(number).distinct().count();
	}

	/**
	 * numberのi番目の数字を一つ上げる
	 * 
	 * @param number
	 * @param i
	 * @return 上げられない場合はfalse
	 */
	private static boolean increaseNumber(int[] number, int i) {
		if (i < number.length) {
			number[i]++;
			if (number[i] >= BASES.length) {
				number[i] = 0;
				return increaseNumber(number, i + 1);
			}
			return true;
		}
		return false;
	}

	/**
	 * n桁の七五三数の数を計算する
	 * 
	 * @param n
	 * @return n桁の七五三数の数
	 */
	private static int calc(int n) {
		return pow(3, n) - 3 * pow(2, n) + 3;
	}

	/**
	 * numberの配列から3,5,7の文字列へ変換する
	 * 
	 * @param number 配列
	 * @return 3,5,7の文字列
	 */
	private static String getNumber(int[] number) {
		StringBuilder sb = new StringBuilder();
		for (int i = number.length - 1; i >= 0; i--) {
			sb.append(BASES[number[i]]);
		}
		return sb.toString();
	}

	/**
	 * nのｍ乗を計算する
	 * 
	 * @param n
	 * @param m
	 * @return nのｍ乗
	 */
	private static int pow(int n, int m) {
		int result = 1;
		while (m > 0) {
			if (1 == (m & 1)) {
				result *= n;
			}
			n *= n;
			m >>= 1;
		}
		return result;
	}
}


Measured memory_bytes: 53884
// Original: https://github.com/tanakh/competitive-rs
#[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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

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

fn main() {
    input!(s: chars);

    let left = format!("{}{}", s[0], s[1]);
    let right = format!("{}{}", s[2], s[3]);
    let a = "01".to_string();
    let b = "12".to_string();
    let yymm = if a <= right && right <= b {
        true
    } else {
        false
    };
    let mmyy = if a <= left && left <= b { true } else { false };
    let ans = if yymm && mmyy {
        "AMBIGUOUS"
    } else if yymm {
        "YYMM"
    } else if mmyy {
        "MMYY"
    } else {
        "NA"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

	int N = scan.nextInt();
	int A = scan.nextInt();
	int B = scan.nextInt();

	if(Math.abs(B-A)%2 == 0){
	    System.out.println("Alice");
	}else{
	    System.out.println("Borys");
	}
    }
}


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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first


const int M = 1e9+7;
int add(int a, int b){ return a+b < M ? a+b : a+b-M; }
int sub(int a, int b){ return a-b >= 0 ? a-b : a-b+M; }
int mul(int a, int b){ return int(ll(a)*b % M); }
ll pot(ll b, ll e){ // O(log e)
	if(!e) return 1;
	ll q = pot(b, e/2); q = mul(q, q);
	return (e & 1 ? mul(b, q) : q);
}
int inv(int x){ return pot(x, M-2); }
int divide(int a, int b) { return mul(a, inv(b)); }
int choose(int n, int c){
    int a = 1, b = 1;
    forn(i,c) a = mul(a,n-i), b = mul(b,i+1);
    return divide(a,b);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n,a,b; cin >> n >> a >> b;
    int r = sub(pot(2,n), 1);
    r = sub(r, choose(n,a));
    r = sub(r, choose(n,b));
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <functional>
#include <ios>
#include <istream>
#include <iterator>
#include <numeric>
#include <ctime>
#include <new>
#include <unordered_map>

using namespace std;

#pragma GCC optimize ("O1")
#pragma GCC optimize ("O2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")

#define Fin(io) freopen((io+".in").c_str(), "r", stdin)
#define Fout(io) freopen((io+".out").c_str(), "w", stdout)
#define Storaket(n) cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(n)

#define F first
#define S second

//#define WRNGS
//#define INIT
//#define PAUSE
//#define FILEIN
//#define FILEOUT
//#define FLOATPOINT
//#define MULTITEST1
//#define MULTITEST2

#ifdef WRNGS
#define _CRT_SECURE_NO_WARNINGS
#endif

typedef long long LL;
typedef pair<int, int> pi;
typedef long double LD;
typedef unsigned long long uLL;

const LL INF = LLONG_MAX/2;
const int mod = (1000*1000*1000+7);
const int inf = INT_MAX/2;
const int N = 200001;
const int M = 1000001;
const LL H = 31;
const double Pi=acos((-1));
const double EPS=1.0/(9999999.9*(double)inf);
const string io = "";

string s;
int i, ans;

void solve() {
	cin>>s;
	for (i=0;i<s.size();i++)
		ans+=(s[i]-'0');
	cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef INIT
    init();
    #endif
    #ifdef FILEIN
    Fin(io);
    #endif
    #ifdef FILEOUT
    Fout(io);
    #endif
    #ifdef FLOATPOINT
    Storaket(69);
    #endif
    #ifdef MULTITEST1
    int T;
    cin>>T;
    T--;
    while(T--)
        solve();
    #endif
    #ifdef MULTITEST2
    int TT;
    scanf("%d", &TT);
    for(TTT=1;TTT<=TT-1;TTT++)
        solve();
    #endif
    solve();
    #ifdef PAUSE
    system("PAUSE");
    #endif
    return 0;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    constexpr int N_MAX = 100000;
    constexpr int K_MAX = 100;
    int N, K;
    int h[N_MAX];
    cin >> N >> K;
    REP(i, N) cin >> h[i];

    int dp[N_MAX];
    dp[N - 1] = 0;
    RREP(i, N - 1) {
        int cost[K_MAX];
        FOR(step, 1, K + 1) {
            if (i + step < N) {
                cost[step - 1] = abs(h[i] - h[i + step]) + dp[i + step];
            } else {
                cost[step - 1] = INT_MAX;
            }
        }
        dp[i] = *min_element(cost, cost + K);
    }
    cout << dp[0] << endl;
    return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define forj(j,n) for(int j=n; j>=0; j--)
#define forx(x,v) for(auto &x:v)
#define sz(v) (int)(v).size()
#define rz(n) resize(n)
#define vec(x) vector < x >
using int64 = long long;
using vi = vector < int >;
using vi64 = vector < int64 >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
//const string yo = "Yes\n", no = "No\n";
int ans;
void dfs(vi v[], vec(bool) &vis, int i, int cnt = 1) {
	vis[i] = 1;
	ans++;
	forx(x, v[i]) {
		if (!vis[x]) {
			dfs(v, vis, x, cnt + 1);
		}
	}
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n, m;
	cin >> n >> m;
	vi v[n + 1];
	for1(i, m) {
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	int mx = 0;
	vec(bool) vis(n + 1);
	for1(i, n) {
		ans = 0;
		dfs(v, vis, i);
		mx = max(mx, ans);
	}
	cout << mx;


	return 0;
}


Measured memory_bytes: 26956
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))

d = {}
for i in range(1, N + 1):
  d[i] = []
for i in range(M):
  A, B = list(map(int, input().split()))
  d[A].append(B)
  d[B].append(A)

#print(d)
ans = 0
for i in range(1, N + 1):
  cnt = 0
  for j in d[i]:
    if H[j - 1] >= H[i - 1]:
      cnt +=1
      break
  if cnt ==0:
    ans +=1
print(ans)

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

int main () {

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

    if ((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    }
    else if ((A - B) % 2 == 0) {
        cout << (A - B) / 2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v;
map<string, vector<LL>>ma;
//set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	set<LL>st[3];
	rep(i, n) {
		LL x;
		cin >> x;
		st[0].insert(x);
	}
	cin >> m;
	rep(i, m) {
		LL x;
		cin >> x;
		st[1].insert(x);
	}
	set_intersection(st[0].begin(),st[0].end(), st[1].begin(), st[1].end(), inserter(st[2], st[2].begin()));
	for (auto& i: st[2]) {
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 28428
#include <iostream>

using namespace std; 

int main(){
  float N;
  cin >> N;
  float count = 0;
  for (int i = 1;i<N+1;i++){
    if (i%2 == 1){
      count++;
    }
  }
  float ans;
  ans = count / N ;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
ll a[505];
ll sum[505];
double dp[505][505];

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		sum[i+1]+=sum[i];
		sum[i+1]+=a[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			dp[i][j]=-1;
		}
	}
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(dp[i][j]<-(1e-5))continue;
			for(int k=i;k<n;k++){
				ll su=sum[k+1]-sum[i];
				dp[k+1][j+1]=max(dp[k+1][j+1],(double)su/(1+k-i)+dp[i][j]);
			}
		}
	}
	double ans=0;
	for(int i=1;i<=m;i++){
		ans=max(ans,dp[n][i]);
	}
	printf("%.10f\n",ans);
	return 0;
}


Measured memory_bytes: 5200
#include <stdio.h>
#include <math.h>

int main(){
    double x, y, x1, y1, x2, y2;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
    x = x2 - x1;
    y = y2 - y1;
    
    printf("%f\n", sqrt(x * x + y * y));
    
    return 0;
}


Measured memory_bytes: 2756
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int h,w,k;cin >> h >> w >> k;
    vvi ans(h,vi(w));
    int a=1;
    rep(i, h) {
        rep(j, w) {
            char c;cin >> c;
            if(c=='#') {
                ans[i][j]=a;
                a++;
            }
            else if(j!=0) ans[i][j]=ans[i][j-1];
        }
    }
    rep(i, h) {
        rev(j, w-1) {
            if(ans[i][j]==0) ans[i][j]=ans[i][j+1];
        }
    }
    rep(x,300){
        rep(j, w) {
            rep(i, h) {
                if(ans[i][j]==0) {
                    if(i==0) ans[i][j]=ans[i+1][j];
                    else ans[i][j]=ans[i-1][j];
                }
            }
        }
    }
    rep(x,300){
        rep(j, w) {
            rev(i, h) {
                if(ans[i][j]==0) {
                    if(i==h-1) ans[i][j]=ans[i-1][j];
                    else ans[i][j]=ans[i+1][j];
                }
            }
        }
    }
    rep(i, h) {
        rep(j, w) {
            cout << ans[i][j];
            if(j==w-1)cout << endl;
            else cout << ' ';
        }
    }
    return 0;
}


Measured memory_bytes: 4320
import sys
sys.setrecursionlimit(10**6)

N = int(input())

def dfs(S):
    if int(S) > N:
        return 0
    ret = 1 if all(S.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(S + c)
    return ret

print(dfs("0"))

Measured memory_bytes: 3060
from operator import mul
from functools import reduce

MOD = 10**9 + 7

def cmb(n, r):
    if n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    numer = reduce(mul, range(n, n-r, -1))
    denom = reduce(mul, range(1, r+1))
    return numer // denom % MOD

N, K = map(int, input().split())
for i in range(1, K+1):
    print(cmb(K-1, i-1) * cmb(N-K+1, i) % MOD)

Measured memory_bytes: 46940
import math
def gcd(a,b):
	if a==0:
		return b
	else:
		return gcd(b%a,a)
def lcm(a,b):
	return (a*b)//gcd(a,b)

def main():
	a ,b,c,d = map(int,input().split())
	lc = lcm(c,d)
	cnt = (((b)//c)-((a-1)//c))+(((b)//d)-((a-1)//d))- (((b)//(lc))-((a-1)//(lc)))
	print((b-(a-1))-cnt)
	

main()


# 1 2 3 4 5
# 1 3 3 4 5
# 1 4 3 4 5 


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

#define MOD 1000000007
#define mp make_pair
#define pb push_back

using namespace std;

const int N = 100005;
int n;

int main ()
{
	scanf("%d",&n);
	if (n == 1)
	{
		return printf("Hello World"),0;
	}
	int x = 0, y = 0;
	scanf("%d %d",&x,&y);
	printf("%d", x + y);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int H, W, i, j;
	
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0){
			break;
		}
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				if((i + j) % 2 == 0){
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;	
}

Measured memory_bytes: 3104
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e5;

int m[10];

int main()
{
  FastIO();
  int tc, ca = 0;
  int n, d, el;
  cin >> n >> d;
  for (int i = 0;i < d;i++){
    cin >> el;
    m[el]++;
  }
  bool ok = true;
  while (ok){
    int tm = n;
    bool check = false;
    while (tm){
      if (m[tm%10]){
        check = true;
        break;
      }
      tm /= 10;
    }
    ok = check;
    n++;
  }
  cout << n-1 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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 under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main(){
	int k;
	cin >> k;
	int ans = 0;
	rep1(i, k) rep1(j, k) rep1(K, k) {
		ans += gcd(gcd(i, j), K);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll a[n],v[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i]>>v[i];
    }
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
    	for(int j=0;j<=w;j++)
    	{
    		if(i==0||j==0)
    		{
    			dp[i][j]=0;
    		}
    		else
    		if(a[i-1]<=j)
    		{
    			dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-a[i-1]]);
    		}
    		else
    		dp[i][j]=dp[i-1][j];
    	}
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 82456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n)  for(int i=0;i<(n);++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> A(N, vector<bool>(M, false));
  REP(i, N) {
    int K;
    cin >> K;
    REP(j, K) {
      int a;
      cin >> a;
      A.at(i).at(a - 1) = true;
    }
  }
  
  int count = 0;
  REP(i, M) {
    bool flag = true;
    REP(j, N) {
      if (!(A.at(j).at(i))) {
        flag = false;
        break;
      }
    }
    if (flag) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
(function main() {
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8'));
  const cache = [1, 1,2,3,5,8,13,21,34,55,89,144,233];
  const fib = (n) => cache[n] || (cache[n] = fib(n - 1) + fib(n - 2));
  console.log(fib(n));
})();


Measured memory_bytes: 15136
import sys
from collections import deque


def main():
    n, m = map(int, sys.stdin.readline().split())

    out_list = [[] for _ in range(n + 1)]
    in_cnt = [0] * (n + 1)
    in_cnt[0] = -1
    for _ in range(n - 1 + m):
        a, b = map(int, sys.stdin.readline().split())
        out_list[a].append(b)
        in_cnt[b] = in_cnt[b] + 1
    root = in_cnt.index(0)
    ans = [0] * (n + 1)
    que = deque([])
    que.append(root)

    while que:
        p = que.popleft()
        for i in out_list[p]:
            in_cnt[i] = in_cnt[i] - 1
            if in_cnt[i] == 0:
                que.append(i)
                ans[i] = p

    for i in ans[1:]:
        print(i)


if __name__ == "__main__":
    main()

Measured memory_bytes: 59312
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    if s == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


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

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String num="";
		int x=0;
		int sannzyou=0;

		  try{
			 num = input.readLine();
			  x=Integer.parseInt(num);
			  sannzyou=x*x*x;

			 System.out.println(sannzyou);

			  


		    }catch(IOException e)
		    {   System.out.println("Exception : " + e);
		    }


	}

}

Measured memory_bytes: 24408
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007
#define N 2000007
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
void solve() {
    ll n,k,a,x;
    cin>>n>>k;
    vector<ll> freq(n+1);
    for(int i=0;i<k;i++) {
        cin>>x;
        for(int i=0;i<x;i++) {
            cin>>a;
            freq[a]++;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++) {
        if(freq[i]==0) ans++;
    }
    cout<<ans;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


Measured memory_bytes: 3644
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    N, M = i2nn()
    S = i2nn()
    T = i2nn()

    rui = [[0] * (M + 1) for _ in range(N + 1)]
    #cnt = [[0] * (M) for _ in range(N)]

    n = 1
    for i, s in enumerate(S):
        for j, t in enumerate(T):
            c = 0
            if s == t:
                c += rui[i][j] + 1
            #cnt[i][j] = c
            rui[i+1][j+1] = (rui[i+1][j] + rui[i][j+1] - rui[i][j] + c) % MOD
            n = (n + c) % MOD

    #for v in cnt:
    #    n = (n + sum(v)) % MOD

    #print(rui)
    #print(cnt)
    print(n)

main()


Measured memory_bytes: 72284
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define p pair <int,int>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
ll q,l[100005],r[100005],table[100005];

bool is_prime(int n)
{
  if(n<=1) return false; 
  for(int i = 2; i * i <= n; ++i){
    if(n%i ==0)
      {
	return false;
      }
  }
  return true;
}


int main(int argc,char const* argv[])
{
  cin >> q;
  rep(i,q)
    {
      scanf("%lld %lld",&l[i],&r[i]);
    }
  for(int i=1;i<=100000;i++)
    {
      if(is_prime(i) && is_prime((i+1)/2)) table[i]++;
    }
  for(int i=1;i<=100000;i++)
    {
      table[i]+=table[i-1];
    }
  rep(i,q)
    {
      printf("%lld\n",table[r[i]]-table[l[i]-1]);
    }
  return 0;
}
  


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

int main() {

	int n; cin >> n;
	vector<int> b(n - 1);
	for (int i = 0; i < (n - 1); i++) {
		cin >> b[i];
	}
	vector<int> a(n);
	a[0] = b[0];
	for (int i = 1; i < (n - 1); i++) {
		a[i] = min(b[i - 1], b[i]);
	}
	a[n - 1] = b[n - 2];

	cout << accumulate(a.begin(), a.end(), 0) << endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int H, W;
string smap[30];

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

	cin >> H >> W;
	rep(i, 0, H)cin >> smap[i];

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

	int ans = 0;
	rep(i, 0, H)rep(j, 0, W)
	{
		if (smap[i][j] == '#')continue;
		queue<pair<pii,int>> q;
		bool used[30][30] = { false };
		q.push(mp(mp(j, i), 0));
		int d = 0;
		used[i][j] = true;
		while (!q.empty())
		{
			auto p = q.front();
			q.pop();
			chmax(d, p.second);
			rep(k, 0, 4)
			{
				int nx = p.first.first + dx[k];
				int ny = p.first.second + dy[k];
				if (0 <= nx && nx < W && 0 <= ny && ny < H&&smap[ny][nx]!='#'&&!used[ny][nx])
				{
					used[ny][nx] = true;
					q.push(mp(mp(nx, ny), p.second + 1));
				}
			}
		}
		chmax(ans, d);
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		string s;
		cin>>s;
		if(s.size()%2!=0){
			cout<<"No";
			return 0;
		}
		int i=0,j=s.size()/2;;
		while(j<s.size()){
			if(s[i]!=s[j]){
				cout<<"No";
				return 0;
			}
			i++;
			j++;
		}
		cout<<"Yes";
	}
	return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

int main(void){
   int m, nmin, nmax;
   
   while(1){
        cin >> m >> nmin >> nmax;
        if(m == 0) break;
        int ans = 0;
        int dif = 0;
        int p[m];
        rep(i,0,m){
            cin >> p[i];
        }
        sort(p,p+m);
        rep(i,nmin, nmax+1){
            int pmin = MOD;
            int pmax = 0;
            rep(j,0,m-i){
                pmax = max(pmax,p[j]);
            }
            rep(j,m-i, m){
                pmin = min(pmin, p[j]);
            }
            if((pmin-pmax) >= dif && i > ans){
                dif = pmin-pmax;
                ans = i;
            }
        }
        cout << ans << "\n";
   }
}


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

int main(){
  int N,i;
  cin >> N;
  vector<double> v(N);

  for(i=0;i<N;i++)
  cin >> v.at(i);
  sort(v.begin(),v.end());

  for(i=0;i<N-1;i++)
  v.at(i+1) = (v.at(i) + v.at(i+1))/2;
  cout << v.at(N-1) << endl;
}


Measured memory_bytes: 256