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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(int i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int r,d,x;
    cin>>r>>d>>x;
    ll a[11];
    a[0]=x;
    for(int i=1;i<=10;i++) {a[i]=r*a[i-1]-d; cout<<a[i]<<'\n';}
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {





    class ClassMain {


       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }
                for (int i = 0; i < n; i++) {
                    line = Console.ReadLine();
                    int[] ints = line.Split(' ').Select(int.Parse).ToArray();

                    if (ints[0] <= 5 && ints[1] <= 5) {
                        for (int j = ints[0]; j != ints[1];) {
                            Console.Write(j);
                            Console.Write(" ");
                            if(ints[0]>ints[1]){j--;}
                            else{j++;}
                        } Console.WriteLine(ints[1]);
                        continue;
                    }
                    else if (ints[0] <= 5 && 5 < ints[1]) {
                        for (int j = ints[0]; j <= 5; j++) {
                            Console.Write(j + " ");
                        }
                        for (int j = 6; j < ints[1]; j++) {
                            Console.Write(j + " ");
                        }
                        Console.WriteLine(ints[1]);
                    }
                    else if (ints[0] > 5 && ints[1] <= 5) {
                        for (int j = ints[0]; j <= 9; j++) {
                            Console.Write(j + " ");
                        }
                        for (int j = 5; j > ints[1]; j--) {
                            Console.Write(j + " ");
                        }
                        Console.WriteLine(ints[1]);
                    }
                    else if (ints[0] < ints[1]) {
                        for (int j = ints[0]; j < ints[1]; j++) {
                            Console.Write(j + " ");
                        }
                        Console.WriteLine(ints[1]);
                    }
                    else {
                        for (int j = ints[0]; j <= 9; j++) {
                            Console.Write(j + " ");
                        }
                        Console.Write("5 4 3 2 1 0 1 2 3 4 5 ");
                        for (int j = 6; j < ints[1]; j++) {
                            Console.Write(j + " ");
                        }
                        Console.WriteLine(ints[1]);
                    }
                }
                break;


            }
        }
    
    }



    
}

Measured memory_bytes: 5916
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i, n) {
        int tmp_a;
        cin >> tmp_a;
        a[i+1] = tmp_a;
    }

    int ans = 0;
    rep(i, n) {
        int serch_rabbit = i + 1;
        if ( a[a[serch_rabbit]] == i + 1 ) {
            ++ans;
        }
    }
    cout << ans / 2 << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  ll ans = n/10;
  ll pow = 50;
  while(n >= pow){
    ans += n/pow;
    pow *= 5;
  }

  if(n%2 == 1) ans = 0;

  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let h = it.next().unwrap().parse::<usize>().unwrap();
    let w = it.next().unwrap().parse::<usize>().unwrap();
    let k = it.next().unwrap().parse::<usize>().unwrap();
    let s = (0..h).map(|_| it.next().unwrap().as_bytes()).collect::<Vec<_>>();
    let mut res = h*w;
    for i in 0..h {
        for j in 0..w {
            if s[i][j] != b'S' { continue; }
            let mut dist = vec![vec![h*w; w]; h];
            let mut qu = VecDeque::new();
            dist[i][j] = 0;
            qu.push_back((i, j));
            let dx = [-1, 0, 1, 0];
            let dy = [0, -1, 0, 1];
            while !qu.is_empty() {
                let (cx, cy) = qu.pop_front().unwrap();
                res = std::cmp::min(res, ([cx, h-cx-1, cy, w-cy-1].iter().min().unwrap() + k - 1)/k + 1);
                if cx == 0 || cx == h-1 || cy == 0 || cy == w-1 { continue; }
                if dist[cx][cy] == k { continue; }
                for dir in 0..4 {
                    let nx = (cx as i32 + dx[dir]) as usize;
                    let ny = (cy as i32 + dy[dir]) as usize;
                    if s[nx][ny] == b'#' { continue; }
                    if dist[cx][cy] + 1 >= dist[nx][ny] { continue; }
                    dist[nx][ny] = dist[cx][cy] + 1;
                    qu.push_back((nx, ny));
                }
            }
        }
    }
    println!("{}", res);
}


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

int main()
{
	int b[3];

	cin >> b[0] >> b[1] >> b[2];

	if((b[0] == 1 && b[1] == 1 && b[2] == 0) ||
		(b[0] == 0 && b[1] == 0 && b[2] == 1)){
			cout << "Open" << endl;
	}
	else
		cout << "Close" << endl;

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n,k,mx=-1;
	cin>>n;
	ll a[n][3];
	for(ll i=0;i<n;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
	ll dp[n+1][3];
	memset(dp,0,sizeof(dp));
	dp[1][0]=a[0][0];
	dp[1][1]=a[0][1];
	dp[1][2]=a[0][2];
	for(ll i=2;i<=n;i++){
		dp[i][0]=max(dp[i-1][1]+a[i-1][0],dp[i-1][2]+a[i-1][0]);
		dp[i][1]=max(dp[i-1][0]+a[i-1][1],dp[i-1][2]+a[i-1][1]);
		dp[i][2]=max(dp[i-1][0]+a[i-1][2],dp[i-1][1]+a[i-1][2]);
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 4992
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let M: usize = read();
    if M % N == 0 {
        println!("{}", M / N);
        return;
    }
    let mut factors = vec![];
    for i in 1..((M as f64).sqrt().ceil() as usize) {
        if M % i == 0 {
            factors.push(i);
            factors.push(M / i);
        }
    }
    let mut ans = 0;
    for v in factors {
        if v <= M / N {
            ans = std::cmp::max(ans, v);
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2620
#include <iostream>
using namespace std;
int main(){
        int oh[4][3][10]={0};
        int N;
        cin >> N;
        int b,f,r,v;
        for(int i=0 ; i<4 ; i++ )
                for(int j=0 ; j<3  ; j++ )
                        for(int k=0 ; k<10 ; k++ )
                                oh[i][j][k]=0;
        for(int i=0 ; i<N ; i++ ){
                cin >> b >> f >> r>> v;
                b--;f--;r--;
                oh[b][f][r]+=v;
        }
        for(int i=0 ; i<4 ; i++ ){
                for(int j=0 ; j<3 ; j++ ){
                        for(int k=0 ; k<10 ; k++ ){
                                cout<<" "<<oh[i][j][k];
                        }
                        cout<<endl;
                }
                if(i!=3)
                        cout<<"####################"<<endl;
        }
        return 0;
}


Measured memory_bytes: 3080
import sys
input=sys.stdin.readline
import collections

def main():
    S = input().strip()
    mi = len(S)
    for c in collections.Counter(S).keys():
        s = list(S)
        n = 0
        while 1:
            if len(collections.Counter(s).keys()) <= 1:
                break
            for j in range(len(s)-1):
                if s[j+1] == c:
                    s[j] = c
            s.pop()
            n += 1
        mi = min(mi, n)
    print(mi)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
# include <iostream>
# include <algorithm>
# include <vector>
# include <functional>
# include <string>
using namespace std;

int main() {
	int N;
	long long int val=1;

	cin >> N;
	for (int i = 1;i<=N; ++i) {
		val *= i;
		val %= 1000000007;
	}

	cout << val << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x)*t;
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    string s;
    cin >> s;

    for(char c : s){
        if(c == '?') cout << 'D';
        else cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    mint ans = 0;
    vector<mint> dp(k+1,0);
    for(int i=k; i>=1; i--){
        dp[i]=(mint(k/i)).pow(n);
        for(int j=2; i*j<=k; j++){
            dp[i]-=dp[i*j];
        }
        ans += dp[i]*i;
    }
    cout<<ans.x<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n, a, b;
  cin >> n >> a >> b;

  vector<ll> vv(n);
  map<ll, int> cnts;
  for (int i = 0; i < n; ++i) {
    cin >> vv[i];
    cnts[vv[i]]++;
  }

  auto ncr = [&](ll n, ll r) -> ll {
    if (n < r) {
      return 0;
    }

    ll nume = 1, deno = 1;
    for (int i = 0; i < r; ++i) {
      nume *= n - i;
      deno *= r - i;
      ll g = gcd(nume, deno);
      nume /= g;
      deno /= g;
    }

    return nume / deno;
  };

  sort(vv.begin(), vv.end(), greater<ll>());
  vector<ll> psum{0};
  partial_sum(vv.begin(), vv.end(), back_inserter(psum));
  ll s = psum[a];
  ll ans = 0;
  for (int i = a; i <= b; ++i) {
    if (s * i % a != 0) {
      continue;
    }

    ll sum = s * i / a;
    if (sum != psum[i]) {
      continue;
    }

    // 各数が何個含まれるか
    map<ll, int> cnts2;
    for (int j = 0; j < i; ++j) {
      cnts2[vv[j]]++;
    }

    ll ans2 = 1;
    for (auto &p : cnts2) {
      ans2 *= ncr(cnts[p.first], p.second);
    }

    ans += ans2;
  }

  double ds = s, da = a;
  cout << fixed << setprecision(9) << ds / da << '\n';
  cout << ans << '\n';
}

Measured memory_bytes: 3836
#include<iostream>
int n,Rating,ans;
int color[10];
int getcolor(int rating) {
	if (rating < 400) return 1;
	else if (rating < 800) return 2;
	else if (rating < 1200) return 3;
	else if (rating < 1600) return 4;
	else if (rating < 2000) return 5;
	else if (rating < 2400) return 6;
	else if (rating < 2800) return 7;
	else if (rating < 3200) return 8;
	else return 0;
}
int main(void) {
	std::cin>>n;
	for (int i=1;i<=n;i++) {
		std::cin>>Rating;
		color[getcolor(Rating)]++;
	}
	for (int i = 1; i <= 8; i++)
		if (color[i]) 
			ans++;
	if(ans)
		std::cout<<ans<<' '<<ans+color[0]<<std::endl;
	else
		std::cout<<1<<' '<<color[0]<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  int h,m,s;
  h = n/3600;
  n %= 3600;
  m = n/60;
  n %= 60;
  s = n;
  cout << h << ':' << m << ':' << s << endl;
  return 0;
}



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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n);
    for (int i = 0; i < n; i++) a[i] = s[i] == 'R' ? i + 1 : i - 1;
    for (int i = 0; i < 100; i++) {
        vector<int> b = a;
        for (int j = 0; j < 9; j++) {
            vector<int> c(n);
            for (int i = 0; i < n; i++) {
                c[i] = a[b[i]];
            }
            b = c;
        }
        a = b;
    }
    vector<int> res(n);
    for (int i = 0; i < n; i++) res[a[i]]++;
    for (int i = 0; i < n; i++) cout << res[i] << " ";

    return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vvint a(2,vint(n));
    rep(i,n) cin >> a[0][i];
    rep(i,n) cin >> a[1][i];


    int res=0;
    rep(i,n){
        int tmp=0;
        int add=0;
        rep(j,n){
            tmp+=a[add][j];
            if(i==j){
                add++;
                tmp+=a[add][j];
            }
        }
        chmax(res,tmp);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3640
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    }
    let mut x=0;
    for i in 0..=a {
        let z=i/10000+i/1000%10+i/100%10+i/10%10+i%10;
        if b<=z&&z<=c {x+=i;}
    }
    println!("{}",x)
}

Measured memory_bytes: 2160
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int IN()
{
  int x=0,plus=1;char c=getchar();
  while(c>'9'||c<'0'){if(c=='-')plus=-1;c=getchar();}
  while(c>='0'&&c<='9')x=(x*10)+(c^48),c=getchar();
  return plus*x;
}
int main(void)
{
  int N,M,A,B,count,H[100001]={0},low[100001]={0};
  N=IN(),M=IN();
  rep(i,N)H[i]=IN();
  rep(i,M){A=IN()-1,B=IN()-1;if(H[A]<=H[B])low[A]=1;if(H[A]>=H[B])low[B]=1;}
  count=0;
  rep(i,N)count+=!low[i];
  return printf("%d\n",count),0;
}

Measured memory_bytes: 2384
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for (int i=0;i<3;i++){
    if (s.at(i)=='1')
      s.at(i)='9';
    else
      s.at(i)='1';
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;



int main()
{
    unsigned long long a;
    cin >> a;
    int output = 0;
    if (a == 1) {
        cout << 0;
        return 0;
    }
    unsigned long long b;
    b = sqrt(a);
    for (int i = 2; i < b; i++) {
        if (a % i == 0) {
            int count = 1;
            while (a != 1) {
                bool right = true;
                for (int j = 0; j < count; j++) {
                    if (a % i == 0) {
                        a = a / i;
                    }
                    else {
                        right = false;
                        break;
                    }
                }
                if (right) {
                    output++;
                }
                else {
                    break;
                }
                count++;
            }
        }
        if (a == 1) {
            break;
        }
    }
    if (a != 1)output++;
    cout << output;


    return 0;
}

Measured memory_bytes: 3220
#include<iostream>
#include<cstring>
#include<numeric>

int d[11][11];

int main(){
  int n;
	while( std::cin>>n , n ){
		memset(d,0,sizeof(d));
		for( int i=0; i<n; ++i ){
		  for( int l=0; l<n; ++l ){
			  std::cin>> d[l][i];
			}
		}
		for(int i=0; i<=n; ++i){
			for(int l=0;l<=n; ++l){
			  if(l==n && i!=n){
					for( int m=0;m<n;++m )
						d[l][i]+=d[m][i];
					std::cout.width(5);
					std::cout<<d[l][i]<<std::endl;
				}else{
					if(i==n){std::cout.width(5);std::cout<<std::accumulate(d[l],d[l]+n,0)<<(l!=n?"":"\n");}
					else{std::cout.width(5);std::cout<<d[l][i];}
				}
			}
		}
	}
}

Measured memory_bytes: 1180
BAD = /AGC|GAC|ACG|A.GC|AG.C/
MOD = 10 ** 9 + 7
CHARS = 'ACGT'.each_char

# memoized DFS
def dfs(i, last3, n, memo)
  return 1 if i == n
  # p [i, last3, memo]
  m = memo[i][last3]
  return m if m

  a =
    CHARS
      .reject { |c| last3 + c =~ BAD }
      .map { |c| dfs(i + 1, last3[1..-1] + c, n, memo) }
      .reduce(:+)

  memo[i][last3] = a % MOD
end

n = gets.to_i
p dfs(0, 'TTT', n, Array.new(n) { {} })


Measured memory_bytes: 2812
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


template<class T>
vector<T> divisor(T n) {
    vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n / i) ret.push_back(n / i);
        }
    }
    return move(ret);
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> d = divisor(N);
    vector<ll> ansArray;
    for(ll x:d){
        ll y = N/x;
        ansArray.push_back(max(x-1LL,0LL)+max(y-1LL,0LL));
    }
    cout << *min_element(All(ansArray)) << nn;
    return 0;
}

Measured memory_bytes: 384
import math

k = input()
a = map(int, raw_input().split())

prime = []
#find prime numbers in 1-sqrt(n)
m = int(math.sqrt(1000))
for i in range(m+1):
    prime.append(True)

prime[0] = False
prime[1] = False

for i in range(2, int(math.sqrt(m))):
    if not prime[i]:
        continue
    else:
        for j in range(i+1, int(math.sqrt(m))):
            if j % i == 0:
                prime[j] = False

lcm = {}

for n in a:
    s = []
    i = 2
    num = n
    while True:
        if i == int(math.sqrt(num))+1:
            s.append(str(n))
            break
        if not prime[i] or n % i != 0:
            i += 1
            continue

        if n % i == 0:
            s.append(str(i))
            n /= i
            if n == 1:
                break
    tmp_dict = {}


    for c in s:
        if not c in tmp_dict.keys():
            tmp_dict[c] = 1
        else:
            tmp_dict[c] += 1
    for key in tmp_dict.iterkeys():
        if not key in lcm.keys():
            lcm[key] = tmp_dict[key]
        elif lcm[key] < tmp_dict[key]:
            lcm[key] = tmp_dict[key]

L = 1
for key in lcm.iterkeys():
    if lcm[key] != 0:
            L *= int(key) ** lcm[key]

print "%d" % L

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

using namespace std;

int main()
{
  int H,A;
  cin>>H>>A;
 if(H!=0&&A!=0&&H<=10000&&A<=10000){
  if(H%A==0){
      cout<<H/A;
  }
  if(H%A!=0){
      cout<<(H/A)+1;
  }
 }
   return 0;
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    m, d = LI()
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            if int(str(j)[0]) < 2 or int(str(j)[1]) < 2:
                continue
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
    print(ans)
    return

#B
def B():
    n, l = LI()
    a = LI()
    d0 = defaultdict(int)
    d1 = defaultdict(int)
    for i in a:
        d0[i] += 1
    for i in range(n):
        b = 0
        for k in range(i+1, n):
            if a[i] > a[k]:
                b += 1
        d1[i] = b
    ans = 0
    d2 = list(d0.items())
    d2.sort()
    d3 = defaultdict(int)
    d = 0
    for key, value in d2:
        d3[key] = d
        d += value
    for i in range(n):
        ans += d3[a[i]] * l * (l-1) // 2 + d1[i] * l
        ans %= mod
    print(ans % mod)
    return

#C
def C():
    n = II()
    s = itertools.product([1, 0], repeat=2 * n)
    a = list(itertools.combinations(range(2*n), 2))
    d = defaultdict(int)
    def dfs(a):
        if len(a) == n:
            lis.append(a)
            return True
        for i in range(n):
            if d[i] == 0:
                d[i] = 1
                for k in range(n):
                    if d[k] == 0:
                        d[k] = 1
                        a.append((i, k))
                        dfs(a)
                        a.remove((i, k))
    lis = []
    dfs([])
    for si in s:
        for di in lis:
            b = list(si[::1])
            for x, y in di:
                for i in range(x, y + 1):
                    b[i] ^= 1
            if sum(b) < 1:
                print(si, di)
                break

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 44252
n = int(input())
d, x = map(int, input().split())
ans = x
for _ in range(n):
    a = int(input())
    if d > a:
        if d % a == 0:
            ans += int(d // a)
        else:
            ans += int(d // a + 1)
    else:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int64 a[N];
int64 dp[N][2];
bool visit[N][2];

int n;
int64 solve(int pos, int flip) {
  if (pos == n) return 0;
  int64& ret = dp[pos][flip];
  if (visit[pos][flip]) return ret;
  visit[pos][flip] = true;
  ret = solve(pos + 1, 0) + a[pos];
  if (pos > 0) {
    int64 cur = solve(pos + 1, 1) - a[pos];
    if (flip) {
      cur += 2 * a[pos - 1];
    } else {
      cur -= 2 * a[pos - 1];
    }
    ret = max(ret, cur);
  }
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  int64 ret = solve(0, 0);
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 9088
//private fun getInts(): IntArray {
//    return readLine()!!.split(" ").map {it.toInt()}.toIntArray()
//}

fun main() {
    readLine()
    val arr = readLine()!!.toCharArray()
    var leftIdx = 0
    var rightIdx = arr.size-1
    var count = 0
    while (true) {
        // 最左Wの位置を探す。走りきった場合、sizeとなる。
        while(true){
            if (leftIdx == arr.size || arr[leftIdx]=='W') {
                break
            }
            leftIdx++
        }
        // 最右Rの位置を探す。走りきった場合、-1となる。
        while(true){
            if (rightIdx == -1 || arr[rightIdx]=='R') {
                break
            }
            rightIdx--
        }
        // 走りきった場合、ここで終了
        if (leftIdx == arr.size || rightIdx == -1 || leftIdx >= rightIdx) {
            print(count)
            return
        }
        // 走りきって無い場合。入れ替えを行う。(ただし操作回数を数えるだけ)
        count++
        leftIdx++
        rightIdx--
    }
}

Measured memory_bytes: 38228
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    string S; cin>>S;
    reverse(S.begin(),S.end());

    string divide[4] = {"dream","dreamer","erase","eraser"};
    for (int i = 0; i < 4; ++i) {
        reverse(divide[i].begin(),divide[i].end());
    }

    bool ok = false;
    for (int i = 0; i < S.length();) {

        ok = false;
        for (int j = 0; j < 4; ++j) {
            string tmp = S.substr(i,divide[j].length());
            if(tmp == divide[j]){
                ok = true;
                i += divide[j].length();
                continue;
            }
        }
        if(!ok){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;

    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rs64() {
	int64_t n;
	scanf("%" SCNd64, &n);
	return n;
}


int main() {
	int n = ri(), q = ri();
	int a[n];
	for (auto &i : a) i = ri();
	for (int i = 0; i < q; i++) {
		int m = ri();
		int first = ri();
		int mod = ri();
		first %= mod;
		int b[n];
		int inc[n];
		for (int j = 0; j < n; j++) {
			b[j] = a[j] % mod;
			inc[j] = !!b[j];
		}
		int big = (m - 1) / n;
		
		
		int res = 0;
		int64_t sum = first;
		sum += std::accumulate(b, b + n, 0LL) * big;
		res += std::accumulate(inc, inc + n, 0LL) * big;
		sum += std::accumulate(b, b + (m - 1) % n, 0LL);
		res += std::accumulate(inc, inc + (m - 1) % n, 0LL);
		printf("%" PRId64 "\n", res - sum / mod);
		// 
	}
	return 0;
}


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

using namespace std;

int main() {
    double r;

    // input
    cin >> r;

    // process
    double a = r * r * M_PI;
    double c = r * 2 * M_PI;

    // output
    printf("%f %f\n", a, c);

    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
//using P = pair<int, int>;
using T = tuple<int, int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    //これはbit全探索で行けそう
    int N;
    cin>>N;
    vector<int> perm_vec(N);
    rep(i, N)
    {
        perm_vec.at(i) = i + 1;
    }

    vector<int> P(N);
    vector<int> Q(N);
    rep(i, N){
        cin>>P.at(i);
    }

    rep(i, N){
        cin>>Q.at(i);
    }

    int index=0;
    int indP,indQ;


    do{
        int flagP=1;
        rep(i,N){
            if(perm_vec.at(i)!=P.at(i))flagP=0;
        }

        int flagQ=1;
        rep(i,N){
            if(perm_vec.at(i)!=Q.at(i))flagQ=0;
        }
        if(flagP==1)indP = index;
        if(flagQ==1)indQ = index;

        index++;


    } while(next_permutation(perm_vec.begin(),perm_vec.end()));


cout<<abs(indP-indQ)<<endl;





}

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

long long a[100005];
long long b[100005];
int main(){
	long long sum=0;
	long long remain;
	int N; cin >> N;
	for(int i=0;i<N+1;i++){
		cin >> a[i];
	}
	for(int i=0;i<N;i++){
		cin >> b[i];
	}
	for(int i=0;i<N;i++){
		if(b[i]<=a[i]){
			sum+=b[i];
			b[i]=0;
		}
		else{
			sum+=a[i];
			b[i]=b[i]-a[i];
		}
		if(b[i]<=a[i+1]){
			sum+=b[i];
			a[i+1]=a[i+1]-b[i];
			b[i]=0;
		}
		else{
			sum+=a[i+1];
			a[i+1]=0;
		}
	}
	cout << sum;
}

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

ll m[2020][2020];
int n,a[2020];

ll s(int p, int l){
  if(p>=n)p-=n;
  if(m[p][l]>0)return m[p][l];
  if(l <= 1)return 0;

  int L = p, R = p+l-1;
  if(R>=n)R-=n;
  if(a[L]<a[R]){ R--; if(R<0)R+=n; }
  else{ L++; if(L>=n)L-=n; }

  return m[p][l] = max(s(L+1,l-2)+a[L],s(L,l-2)+a[R]);
}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);

  ll r = 0;
  for(int i=0;i<n;i++)r = max(r, s(i+1,n-1) + a[i]);
  printf("%lld\n",r);
}

Measured memory_bytes: 32784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n=1;
  vector<int>a(1000);
  while(n!=0){
    cin >>n;
    if(n==0)return 0;
    int sum=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
    }
    double heikin=(double)sum/(double)n;
    double hensa=0;
    for(int i=0;i<n;i++){
      hensa+=(a[i]-heikin)*(a[i]-heikin);
    }
    hensa/=(double)n;
    cout<<fixed<<setprecision(12)<<sqrt(hensa)<<endl;
  }
  return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
typedef long double ll;
typedef pair<int,int> pii;
#define PB push_back
#define be(v) v.begin(), v.end()
#define endl "\n"
void solve(){
	ll d, t, s;
	cin>>d>>t>>s;
	ll tt = d/t;
	if(tt<=s) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	// cin>>t;
	while(t-->0){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3676
import java.util.Iterator;
import java.util.Scanner;


public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();//nCrのnにあたる
        int M=sc.nextInt();   //nCrのrにあたる
        int Q=sc.nextInt();
        int[][] qs=new int[Q][4];
        for(int i=0; i<Q; i++){
            for(int j=0; j<4; j++){
                qs[i][j]=sc.nextInt();
            }
        }
        long max = 0;
        for (long l : new Combination(N+M,N)) {
            int[] a=vconv(l,N);
            long tmp=0;
            if(a[0] != 0) {
                //l(a);
                for(int j =0; j<Q; j++){
                    if(a[qs[j][1]-1] - a[qs[j][0]-1] == qs[j][2]){
                        tmp+=qs[j][3];
                    }
                }
                max = Math.max(max,tmp);
            }
        }
        System.out.println(max);
    }
    static int[] vconv(long l,int N){
        int[] ret =new int[N];
        for(int i=0; i<N; i++){
            ret[i] = 0;
        }
        int tmp=0;
        int counter=0;
        while(l > 0 ){
            if( l % 2 == 0){
                counter++;
                l /=2;
            }else{
                ret[tmp]=counter;
                tmp++;
                l /=2;
            }
        }
        return ret;
    }
    static void l(int[] k){
        for(int i=0; i<k.length; i++){
            System.out.print(k[i]+" ");
        }
        System.out.println();
    }

    private static class Combination implements Iterable<Long> {
        private final int max;
        private final int select;
        public Combination(int max, int select) {
            if (max < 1 || 62 < max) {
                throw new IllegalArgumentException();
            }
            this.max = max;
            this.select = select;
        }
        public Iterator<Long> iterator() {
            return new CombinationIterator(max, select);
        }
    }
    private static class CombinationIterator implements Iterator<Long> {
        private long value;
        private final long max;

        public CombinationIterator(int max, int select) {
            this.value = (1L << select) - 1L;
            this.max = 1L << max;
        }
        public boolean hasNext() {
            return value < max;
        }
        public Long next() {
            long stock = value;
            value = next(value);
            return stock;
        }
        public void remove() {
            throw new UnsupportedOperationException();
        }
        private long next(long source) {
            long param1 = smallestBitOf(source);
            long param2 = param1 + source;
            long param3 = smallestBitOf(param2);
            long param5 = (param3 / param1) >>> 1;
            return param5 - 1 + param2;
        }
        private long smallestBitOf(long source) {
            long result = 1L;
            while (source % 2 == 0) {
                source >>>= 1;
                result <<= 1;
            }
            return result;
        }
    }
}


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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    rep(i, 0, 3)
    {
        if (s[i] == '9')
            s[i] = '1';
        else if (s[i] == '1')
            s[i] = '9';
    }
    cout << s << endl;
}

Measured memory_bytes: 3572
using System;
using System.Linq;
using System.Text;

namespace ALDS1_2_C {
    struct Card {
        public char suit;
        public int num;

        public Card(char suit,int num) {
            this.suit = suit;
            this.num = num;
        }

        public override string ToString() {
            return string.Format("{0}{1}", suit, num);
        }
    }

    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            Card[] A = Console.ReadLine().Split(' ')
                .Select(c => new Card(c[0], int.Parse(c[1].ToString())))
                .ToArray();
            Card[] B = (Card[])A.Clone();
            Card[] stable = A.OrderBy(c => c.num).ToArray();

            // BubbleSort(A)
            for (int i = 0; i < n; i++) {
                for (int j = n - 1; j > i; j--) {
                    if (A[j].num < A[j - 1].num) {
                        Card temp = A[j];
                        A[j] = A[j - 1];
                        A[j - 1] = temp;
                    }
                }
            }

            // SelectionSort(B)
            for (int i = 0; i < n; i++) {
                int minj = i;
                for (int j = i; j < n; j++) {
                    if (B[j].num < B[minj].num)
                        minj = j;
                }
                Card temp = B[i];
                B[i] = B[minj];
                B[minj] = temp;
            }
            
            Print(A);
            Console.WriteLine(A.SequenceEqual(stable) ? "Stable" : "Not stable");
            Print(B);
            Console.WriteLine(B.SequenceEqual(stable) ? "Stable" : "Not stable");
        }

        static void Print(Card[] arr) {
            StringBuilder sb = new StringBuilder();
            sb.Append(arr[0].ToString());
            for (int i = 1; i < arr.Length; i++) {
                sb.AppendFormat(" {0}", arr[i].ToString());
            }
            Console.WriteLine(sb.ToString());
        }
    }
}

Measured memory_bytes: 10200
K = int(raw_input())

MAXX = 10**5*3
#gen lunlun

list = []
def genLunlun(dep, last, res):
    if dep <= 0:
        list.append(res)
        return 1

    cnt = 0
    if res == 0:
        for d in range(1, 10):
            cnt = cnt + genLunlun(dep-1, d, d)
        return cnt


    for d in range(-1,2):
        num = last + d
        if (num >= 0) and (num <= 9):
            cnt = cnt + genLunlun(dep-1, num, res*10 + num)
    return cnt

def findX(list, K):
    last = -1
    cnt = 0
    for item in list:
        if item != last:
            cnt = cnt + 1
            last = item
            if cnt == K:
                return last
    return -1

total = 0
num = 0
dep = 0
while True:
    dep = dep + 1
    cnt = genLunlun(dep, -1, 0)
    total = total + cnt
    if total >= K:
        num = list[K-1]
        #list.sort()
        #num = findX(list, K)
        break

print(num)


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

int main()
{
	long long a, b, n;
	cin >> n >> a >> b;
	if (a > b) cout << 0 << endl;
	else if (n == 1) cout << (a == b) << endl;
	else cout << (a+(n-1)*b)-(b+(n-1)*a)+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
int main(){
    int n;cin>>n;
    if(n==7||n==5||n==3){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}   

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

int main() {
    int n, k, a, ans = 0;
    cin >> n >> k;
    rep(i, n) {
        cin >> a;
        ans += 2 * min(a, k - a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
import sys
import math
read = sys.stdin.readline

n , k = map(int,input().split())
A = []
for i in range(k):
    d = int(input())
    [A.append(list(map(int,input().split()))) for _ in range(1) ]

ans = [1] * n

for a in A:
    for j in a:
        ans[j-1] = 0

print(sum(ans))



Measured memory_bytes: 27172
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int S, W;

int main()
{
    cin >> S >> W;
    if (W >= S)
    {
        cout << "unsafe" << endl;
        return 0;
    }
    cout << "safe" << endl;
}

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

int main(int argc,char* argv[]){
  double x_array[20];
  double y_array[20];
  int count = 0;
  int i;
  double sum = 0;

  for(;;){
    double x,y;
    if(scanf("%lf,%lf",&x,&y) == EOF){
      break;
    }
    x_array[count] = x;
    y_array[count] = y;
    count++;
  }
  
  for(i = 1;i < (count-1); i++){
    double ra = sqrt((x_array[ 0 ] - x_array[ i ])*(x_array[ 0 ] - x_array[ i ]) + (y_array[ 0 ] - y_array[ i ])*(y_array[ 0 ] - y_array[ i ]));
    double rb = sqrt((x_array[ i ] - x_array[i+1])*(x_array[ i ] - x_array[i+1]) + (y_array[ i ] - y_array[i+1])*(y_array[ i ] - y_array[i+1]));
    double rc = sqrt((x_array[i+1] - x_array[ 0 ])*(x_array[i+1] - x_array[ 0 ]) + (y_array[i+1] - y_array[ 0 ])*(y_array[i+1] - y_array[ 0 ]));
    double z = (ra + rb + rc)/2;
    double S = sqrt(z*(z - ra)*(z - rb)*(z - rc));
  
    sum += S;
  }

  printf("%.6lf\n",sum);

  return 0;
  
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>

int scan() {
  int r = 0;
  int c;
  while ((c = getchar_unlocked() - '0') >= 0)
    r = r * 10 + c;
  return r;
}

int main() {
  const int n = scan();
  std::vector<std::vector<int>> t(n);
  for (int i = 0; i != n - 1; i += 1) {
    const int a = scan() - 1;
    const int b = scan() - 1;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  const int m = scan();
  const int s = 1 << m;
  std::vector<int> z(s, 0);
  {
    std::vector<int> x(n, 0);
    for (int i = 0; i != m; i += 1) {
      const int u = scan() - 1;
      const int v = scan() - 1;
      x[u] ^= 1 << i;
      x[v] ^= 1 << i;
    }
    const auto dfs = [&](const auto &dfs, int v, int p) -> void {
      for (int e : t[v]) {
        if (e != p) {
          dfs(dfs, e, v);
          z[x[e]] += 1;
          x[v] ^= x[e];
        }
      }
    };
    dfs(dfs, 0, n);
  }
  for (int w = 1; w != s; w <<= 1) {
    for (int i = 0; i != s; i += w << 1) {
      const int end = i + w;
      for (int j = i; j != end; j += 1) {
        z[j + w] += z[j];
      }
    }
  }

  long long ans = 0;
  for (int i = 0; i != 1 << m; i += 1) {
    auto res = 1LL << z[s - 1 ^ i];
    if (__builtin_parity(i))
      res = -res;
    ans += res;
  }
  printf("%lld", ans);
}

Measured memory_bytes: 4984
/*ex4_3
ryo_1129*/
#include<stdio.h>
//プロトタイプ宣言、引数は2つの塔の見えている高さ
int snowhight(int height_a,int height_b);

int main(void){
    //変数宣言
    int height_a,height_b,ans;
    //入力
    scanf("%d %d",&height_a,&height_b);
    //積雪量を出す関数の呼び出し
    ans = snowhight(height_a,height_b);
    //出力
    printf("%d\n",ans);

    return 0;
}
//n番目の木の高さを出す関数、等差数列の和
int snowhight(int height_a,int height_b){
    int tower_a,n,snowhight;
    //n番目とn+1番目の木の高さの違い(b-a)はn+1である。
    n = height_b-height_a-1;
    //aの高さを出す。n番目の高さは
    tower_a = (n)*(n+1)/2;
    //積雪量は（aの高さ-埋まらずに見えている高さ）
    snowhight = tower_a-height_a;
    return snowhight;
}

Measured memory_bytes: 128