akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x,y=map(int,readline().split())

    l_min=2*x
    l_max=4*x
    if l_min<=y<=l_max and y%2==0:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

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

using namespace std;

int main(){
	int n;
	string inp;
	string ord;
	map<string,bool> m;

	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> inp;
		if(inp =="insert"){
			cin >> ord;
			m[ord] = 1;
		}else if(inp == "find"){
			cin >> ord;
			if(m[ord]){
				cout << "yes" << endl;
			}else{
				cout << "no" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 52456
// atcoder/abc146/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, mod;
  while (cin >> n >> mod) {
    vector<lli> a(n);
    cin >> a;

    lli sum = 0;
    vector<lli> v;
    v.push_back(0);
    for (int i = 0; i < n; ++i) {
      sum += a[i];
      v.push_back((sum - (i + 1)) % mod);
    }
    // cout << a << endl;
    // cout << v << endl;

    lli x = 0;
    map<lli, lli> cnt;
    queue<lli> q;
    for (int i = 0; i < v.size(); ++i) {
      while (mod <= q.size()) {
        --cnt[q.front()];
        q.pop();
      }

      x += cnt[v[i]];
      ++cnt[v[i]];
      q.push(v[i]);
    }
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 17520
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

const int N = 2e5+5;
int a[N];
int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int n;cin>>n;
    map<int,int>pos;
    _for(i,1,n+1){
        int x;cin>>x;
        a[i] = x+i;
        ++pos[i-x];
    }
    ll ans = 0;
    _for(i,1,n+1){
        ans += pos[a[i]];
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 21456
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	ll n;
	cin >> n;
	int sum = 0;
	ll now = n;
	while (now > 0) {
		sum += now % 10;
		now /= 10;
	}
	if (n%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* In the name of ALLAH */
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>

// MAXIMUM and MINIMUM elements
#define mx_ari(a)   *max_element(a , a+sizeof(a)/4)
#define mn_ari(a)   *min_element(a , a+sizeof(a)/4)
#define mx_arl(a)   *max_element(a , a+sizeof(a)/8)
#define mn_arl(a)   *min_element(a , a+sizeof(a)/8)
#define mx_vec(v)   *max_element(v.begin() , v.end())
#define mn_vec(v)   *min_element(v.begin() , v.end())
// COUNT the occurence of an element
#define cnt_ari(a,b)   count(a , a+sizeof(a)/4 , b)
#define cnt_arl(a,b)   count(a , a+sizeof(a)/8 , b)
#define cnt_vec(v,b)   count(v.begin() , v.end() , b)
// INPUTs
#define sci(a)        scanf("%d",&a)
#define scii(a,b)     scanf("%d %d",&a,&b)
#define sciii(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scl(a)        scanf("%lld",&a)
#define scll(a,b)     scanf("%lld %lld",&a,&b)
#define sclll(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define scf(a)        scanf("%f",&a)
#define scff(a,b)     scanf("%f %f",&a,&b)
#define scfff(a,b,c)  scanf("%f %f %f",&a,&b,&c)
#define scd(a)        scanf("%ld",&a)
#define scdd(a,b)     scanf("%lf %lf",&a,&b)
#define scddd(a,b,c)  scanf("%lf %lf %lf",&a,&b,&c)
// OUTPUTs
#define pri(a)        printf("%d ",a)
#define prii(a,b)     printf("%d %d ",a,b)
#define priii(a,b,c)  printf("%d %d %d ",a,b,c)
#define prl(a)        printf("%lld ",a)
#define prll(a,b)     printf("%lld %lld ",a,b)
#define prlll(a,b,c)  printf("%lld %lld %lld ",a,b,c)
#define prd(a)        printf("%.4lf ",a)
#define prdd(a,b)     printf("%.4lf %.4lf ",a,b)
#define prddd(a,b,c)  printf("%.4lf %.4lf %.4lf ",a,b,c)
#define prf(a)        printf("%.4f ",a)
#define prff(a,b)     printf("%.4f %.4f ",a,b)
#define prfff(a,b,c)  printf("%.4f %.4f %.4f ",a,b,c)
// LOOPs
#define foi(i,n)      for(int i=0;i<n;i++)
#define fol(i,n)      for(long long int i=0;i<n;i++)
#define fod(i,n)      for(double i=0;i<n;i++)
#define fof(i,n)      for(float i=0;i<n;i++)
// NEWLINEs
#define nwl           << "\n"
#define nl            printf("\n");
// PAIRs and PUSHbacks
#define mp            make_pair
#define pb            emplace_back
// IMPORTANTs
#define ll          long long
#define ull         unsigned long long int
#define mod         1000000007
#define lcm(a,b)     (a*b) / __gcd(a,b)

using namespace std;





int main()
{
   int n,k; cin >> n >> k;
   int a[n] , cost[n] , dp[n];
   foi(i,n){
      cin >> a[i];
   }

   cost[n-1] = 0;
   int cnt=0;
   for(int i=n-2;i>=0;i--){
      cost[i] = abs(a[i] - a[n-1]);
      cnt++;
      if(cnt == k){break;}
   }

   for(int i=n-k-2;i>=0;i--){
      int mn = INT_MAX;
      for(int j=i+1;j<=i+k;j++){
         mn = min(mn , cost[j] + abs(a[i] - a[j]));
      }
      cost[i] = mn;
   }

   cout << cost[0];

   return 0;
}

Measured memory_bytes: 4380
use std::vec::Vec;
use std::collections::HashMap;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_vec();
    let mut acc = HashMap::<i64, i64>::new();
    let mut ans = 0;
    for i in 0..n {
      let b = - (i as i64) - a[i];
      let c = a[i] - i as i64;
      if let Some(x) = acc.get(&c) {
        ans += x;
      }
      match acc.get_mut(&b) {
        Some(x)   => *x += 1,
        None => {acc.insert(b, 1);},
      }
    }

    println!("{}", ans);
}


Measured memory_bytes: 12400
#include <stdio.h>
#include <string.h>
int a[200], s[200];
int main(void)
{
    int i, j, n, m, k;
    scanf("%d%d", &n, &m);
    for (i=0; i<2*n; ++i) a[i] = i+1;
    for (i=0; i<m; ++i) {
        scanf("%d", &k);
        memcpy(s, a, sizeof(a));
        if (k == 0) {
            for (j=0; j<n; ++j) a[2*j] = s[j];
            for (j=0; j<n; ++j) a[2*j+1] = s[j+n];
        }
        else {
            for (j=k; j<2*n; ++j) a[j-k] = s[j];
            for (j=0; j<k; ++j) a[2*n-k+j] = s[j];
        }
    }
    for (i=0; i<2*n; ++i) printf("%d\n", a[i]);
    return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
 
     public static void main(String []args){
   Scanner sc = new Scanner(System.in);
   int a = sc.nextInt();
   int t = sc.nextInt();
   int sum =0;
   while(t-->0){
       int b = sc.nextInt();
       sum+=b;
      
   }
  int r=0;
   if(a<sum){
       System.out.println(-1);
   }else{
    r = a-sum;
     System.out.println(r);
     }
}}

Measured memory_bytes: 46256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	string s;cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
import collections
 
N = int(input())
#read strings and sort each one alpha!
s = ["".join(sorted(input())) for i in range(N)]

# count every word occurences
c = collections.Counter(s)

cnt = 0
for i in set(s):
    n = c[i]
    # erase repititions
    cnt += n*(n-1)//2
print(cnt) 

Measured memory_bytes: 23436
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

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

    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end()) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <vector>
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
const int MAX=2e3+5;
const int NAX=1e3+5;
const ll INF=1e18+5;
const double M=4e18;
using namespace std;
const int MOD=1e9+7;
typedef pair<int,int> pii;
const double eps=0.000000001;
int n,m;
ll dis[NAX];
int from[MAX],to[MAX];
bool neg[MAX];
ll cost[MAX];
ll an;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i)
    {
        scanf("%d%d%lld",&from[i],&to[i],&cost[i]);
        cost[i]=-cost[i];
    }
    fill(dis+1,dis+1+n,INF);
    dis[1]=0;
    for(int i=0;i<n-1;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(dis[from[j]]==INF)
                continue;
            if(dis[to[j]]>dis[from[j]]+cost[j])
            {
                dis[to[j]]=dis[from[j]]+cost[j];
            }
        }
    }
    an=dis[n];
    for(int i=0;i<n-1;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(dis[from[j]]==INF)
                continue;
            if(dis[to[j]]>dis[from[j]]+cost[j])
            {
                neg[to[j]]=true;
                dis[to[j]]=dis[from[j]]+cost[j];
            }
            if(neg[from[j]])
                neg[to[j]]=true;
        }
    }
    if(neg[n])
        printf("inf\n");
    else
        printf("%lld\n",-an);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n , X , a[N];
bool f[N];
int main() {
    cin >> n >> X;
    if (X == 1 || X == n + n - 1) {
        puts("No");
    } else {
        puts("Yes");
        if (n == 2 && X == 2) {
            puts("1\n2\n3");
        } else {
            a[n] = X;
            a[n - 1] = X - 1;
            a[n + 1] = X + 1;
            f[X] = f[X - 1] = f[X + 1] = 1;
            int p = n + n - 1;
            for (int i = n - 2 ; i > 0 ; -- i) {
                while (f[p]) p --;
                a[i] = p --;
            }
            for (int i = n + n - 1 ; i > n + 1 ; -- i) {
                while (f[p]) p --;
                a[i] = p --;
            }
            for (int i = 1 ; i <= n + n - 1 ; ++ i) {
                printf("%d\n" , a[i]);
            }
        }
    }
}


Measured memory_bytes: 2304
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int32_t N;
  cin >> N;
  constexpr int32_t kMaxValue = 100000;
  vector<int32_t> histogram(kMaxValue + 2, 0);
  for (int32_t i = 0; i < N; ++i) {
    int32_t a;
    cin >> a;
    ++histogram[a];
  }

  int32_t result = 0;
  for (int32_t i = 0; i <= kMaxValue; ++i) {
    int32_t c_count;
    if (i == 0) {
      c_count = histogram[i] + histogram[i + 1];
    } else {
      c_count = histogram[i - 1] + histogram[i] + histogram[i + 1];
    }
    if (c_count > result) {
      result = c_count;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 640
#include <math.h>
double x[99],y[99],X,Y;
n,i;main(){
	for(gets(x);~scanf("%lf %lf",x+n,y+n);n++);
	if(!(n&1))for(X=(x[0]+x[n/2])/2,Y=(y[0]+y[n/2])/2,i=1;
		i<n/2&&fabs((x[i]+x[n/2+i])/2-X)<1e-7&&fabs((y[i]+y[n/2+i])/2-Y)<1e-7;
	i++);
	printf(i==n/2?"%f %f\n":"NA\n",X,Y);exit(0);
}

Measured memory_bytes: 656
#include<bits/stdc++.h>
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair

using namespace std;

typedef long long ll;

string f(ll a){
	string ans = "000000";
	ll i = 5;
	while(a>0){
		ll d = a%10;
		ans[i--] = '0'+d;
		a = a/10;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	
	ll n,m;cin>>n>>m;

	vector<pii> input;
	vector<ll> a[n];
	while(m--){
		pii x;cin>>x.se>>x.fi;x.se--;
		a[x.se].pb(x.fi);
		input.pb(x);
	}

	For(i,0,n){
		if(a[i].size()==0) continue;
		sort(a[i].begin(),a[i].end());
	}

	vector<string> ans[n];

	For(i,0,n){
		ll x = 1;
		For(j,0,a[i].size()){
			string z = f(i+1)+f(x);
			x++;
			ans[i].pb(z);
		}
	}

	For(i,0,input.size()){
		ll index = lower_bound(a[input[i].se].begin(),a[input[i].se].end(),input[i].fi)-a[input[i].se].begin();
		
		// cout<<"#"<<index<<endl;
		cout<<ans[input[i].se][index]<<endl;
	}
}

Measured memory_bytes: 18672
# = int(input())
# = str(input())
D, T, S = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

if S*T - D >= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9144
N = int(input())
hs = list(map(int,input().split(" ")))
INF = 10 ** 15
dp = [INF] * N

dp[0] = 0
dp[1] = abs(hs[0] - hs[1])

for i in range(2,N):
    dp[i] = min(dp[i-1]+  abs(hs[i-1] - hs[i]) , dp[i])
    dp[i] = min(dp[i-2]+  abs(hs[i-2] - hs[i]) , dp[i])
print(dp[-1])

Measured memory_bytes: 13980
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};
//template<class T>vector<T> var_vec(size_t a){return vector<T>(a);}
//template<class T, class... Ts>auto var_vec(size_t a, Ts... ts){return vector<decltype(var_vec<T>(ts...))>(a, var_vec<T>(ts...));}

//}



main(){
	int a,b,c;cin>>a>>b>>c;
	dump(min(a*b,c));
}




Measured memory_bytes: 256
N = int(input())
ng = ["agc", "aagc", "acgc", "aggc", "atgc", "agac", "agcc", "aggc", "agtc", "acg", "gac"]

x = {"a": 1, "g": 1, "c": 1, "t": 1}

for _ in range(1,N):
    y = dict()
    for let,num in x.items():
        for a in ["a", "c", "g", "t"]:
            if let[-3:] + a in ng or (let[-3:] + a)[-3:] in ng:
                continue
            else:
                if let[-3:] + a in y.keys():
                    y[let[-3:] + a] += num
                else:
                    y[let[-3:]+a] = num
    x = y

print(sum(x.values()) % (10**9+7))

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

using namespace std;

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

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

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

	int a, b, c;
	cin >> a >> b >> c;

	int rem = a - b;

	c -= rem;
	cout << max(0, c) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int W,H;
	int x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if((0<=x-r)&&(x+r<=W)&&(0<=y-r)&&(y+r<=H)){
		printf("Yes\n");
	}
	else	printf("No\n");
	return 0;
}

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

static const int MAX_VALUE = 50000;

int main()
{
  int N;
  cin >> N;
  
  int table[MAX_VALUE + 1];
  for (int i = 1; i <= MAX_VALUE; i++)
  {
    if (floor(i*1.08) == N)
    {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << ":(" << endl;
  
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int x[5];
	for(int i=0;i<5;i++) cin>>x[i];
	for(int i=0;i<5;i++)
	if(!x[i]) cout<<i+1;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	long long H[N + 1];
	for (int i = 0; i < N; ++i) scanf("%lld", &H[i]);
	H[N] = 0;
	long long oldtable[K + 1][N + 1], newtable[K + 1][N + 1];
	for (int i = 0; i <= K; ++i) {
		for (int j = 0; j <= N; ++j) oldtable[i][j] = H[j] - H[N];
	}
	for (int i = N - 1; i >= 0; --i) {
		for (int j = 0; j <= K; ++j) {
			for (int k = 0; k <= N; ++k) {
				newtable[j][k] = oldtable[j][i];
				if (H[i] < H[k]) newtable[j][k] += H[k] - H[i];
				if (j != 0) {
					newtable[j][k] = min(newtable[j][k], oldtable[j - 1][N] + H[k] - H[N]);
					newtable[j][k] = min(newtable[j][k], oldtable[j - 1][k]);
					newtable[j][k] = min(newtable[j][k], oldtable[j - 1][i + 1] + (H[i + 1] < H[k] ? H[k] - H[i + 1] : 0));
				}
			}
		}
		for (int j = 0; j <= K; ++j) {
			for (int k = 0; k <= N; ++k) oldtable[j][k] = newtable[j][k];
		}
	}
	long long ans = newtable[0][N];
	for (int i = 1; i <= K; ++i) ans = min(ans, newtable[i][N]);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	s1="@"+s1;
	s2="@"+s2;
	int n=s1.size();
	int m=s2.size();
	int dp[n][m];
	r(i,n)dp[i][0]=i;
	r(i,m)dp[0][i]=i;
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			int cost=(s1[i]==s2[j]?0:1);
			dp[i][j]=min(dp[i-1][j-1]+cost,min(dp[i-1][j]+1,dp[i][j-1]+1));
		}
	}
	cout<< dp[n-1][m-1] <<endl;
}


Measured memory_bytes: 7092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int a,b;
  cin>>a>>b;
  
  int up=max(a,b);
  int low=min(a,b);
  
  int ans=0;
  
  for(int i=0;i<up;++i){
    ans+=low*pow(10,i);
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,m;
  int box[100005]={};//赤があれば１
  int i,j;
  int ball[100005]={};
  int x,y;

  cin>>n>>m;
  box[0]=1;

  rep(i,n)
    ball[i]=1;//ボールの数を１で初期化

  rep(i,m){
    cin>>x>>y;
    box[y-1]+=box[x-1];
    ball[x-1]--;
    ball[y-1]++;
    if(ball[x-1]==0)
      box[x-1]=0;
  }

  int sum=0;

  rep(i,n)
    if(box[i]>0 && ball[i]>0)
      sum++;

  cout<<sum<<endl;


}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
vector<int> bitPos(int);
vector<string> subStr(string, vector<int>);
int n;

int main()
{
	string s;
	cin >> s;
	n = s.size();
	ll ans = 0;
	rep(i, 1 << n - 1)
	{
		auto bitP = bitPos(i);
		auto subStrings = subStr(s, bitP);
		rep(i, subStrings.size())
		{
			ans += stoll(subStrings[i]);
		}
	}
	co(ans);
	return 0;
}

vector<int> bitPos(int a)
{
	vector<int> res;
	for (int i = 0; i < n - 1; i++)
	{
		if ((a>>i) % 2 == 1)
		{
			res.push_back(i);
		}
	}
	return res;
}

vector<string> subStr(string s, vector<int> pos)
{
	vector<string> res;
	pos.push_back(s.size() - 1);
	int last = -1;
	rep(i, pos.size())
	{
		res.push_back(s.substr(last + 1 , pos[i] - last));
		last = pos[i];
	}
	return res;
}

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

using namespace std;

#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long

int check(ll a, ll b, ll c, ll d, ll e, ll f, ll g, ll h, ll i, ll j) {
	if(a < e && b < f && c < g && d < h) {
		return j;
	} else if(e < a && f < b && g < c && h < d) {
		return i;
	} else {
		return 1001;
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int y, m, d;
	char x;
	cin >> y >> x >> m >> x >> d;
	if(m <= 4) {
		cout << "Heisei";
	} else {
		cout << "TBD";
	}
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a[100000],b,c,cmp,cmpp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> a[i];
           if(a[i]%2==0){
               cmp++;
           }
           else{
               cmpp++;
           }
       }
       if(cmpp%2!=0){
           Cout("NO");
           return 0;
       }
       else{
           if(cmpp/2==cmp){
               Cout("YES");
           }
           else{
               if(cmpp%2==0){
                   Cout("YES");
               }
               else{
               Cout("NO");
               }
           }
           
       }
return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC092C_TravelingPlan();

#if 1
int main()
{
	ABC092C_TravelingPlan();
	fflush(stdout);
	return 0;
}
#endif

static void ABC092C_TravelingPlan()
{
	int N;
	get1int(N);

	auto aPos = new int[N];
	for (int i = 0; i < N; i++) {
		get1int(aPos[i]);
	}

	int ttlSum = tp_abs(aPos[0]);
	for (int i = 1; i < N; i++) {
		ttlSum += tp_abs(aPos[i] - aPos[i - 1]);
	}
	ttlSum += tp_abs(aPos[N - 1]);

	printf("%d\n", ttlSum - (tp_abs(aPos[0]) + tp_abs(aPos[1] - aPos[0])) + tp_abs(aPos[1]));
	for (int i = 1; i < N - 1; i++) {
		printf("%d\n", 
			ttlSum
			- (tp_abs(aPos[i] - aPos[i - 1]) + tp_abs(aPos[i + 1] - aPos[i]))
			+ tp_abs(aPos[i + 1] - aPos[i - 1]));
	}
	printf("%d\n", ttlSum - (tp_abs(aPos[N - 1] - aPos[N - 2]) + tp_abs(aPos[N - 1])) + tp_abs(aPos[N - 2]));

	delete[] aPos;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
//#include<vector>
//#include<math.h>
#include<unordered_map>
using namespace std;

int A[100000];
int C[100000] = {0}; // correct answer

int main (void) {
  int N,K,Q;
  cin >> N >> K >> Q;
  for (int i = 0; i < Q; i++){
    cin >> A[i];
    A[i]--;
    C[A[i]]++;
  }
  for (int n = 0; n < N; n++){
    int point = K - Q + C[n];
    if (point <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int A,B;
	cin>>A>>B;
	cout<<max(A+B,max(A-B,A*B))<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	// Code for C - Unification
	var S string
	fmt.Scanf("%s", &S)

	ans := make(map[int]int, 2)
	for i := 0; i < len(S); i++ {
		temp, _ := strconv.Atoi(string(S[i]))
		ans[temp]++
	}

	A := int(math.Abs(float64(ans[0] - ans[1])))
	fmt.Println(len(S) - A)
}


Measured memory_bytes: 2580
import itertools
N = int(input())
talks = []
for i in range(N):
    temp = int(input())
    talks.append([list(map(int, input().split())) for _ in range(temp)])
bit = itertools.product([0, 1], repeat=N)
ans = 0
for b in bit:
    flag = True
    for i in range(N):
        if b[i] == 0:
            continue
        for talk in talks[i]:
            if b[talk[0]-1] != talk[1]:
                flag = False
                break
    if flag:
        ans = max(ans, (sum(b)))
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
void swap(int& a, int& b){
    int tmp;
    tmp = a;
    a = b;
    b = tmp;
}
 
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    if(y > z)
        swap(y, z);
    if(x > y)
        swap(x, y);
    if(y > z)
        swap(y, z);
    cout << x << ' ' << y << ' ' << z << endl;
    return 0;
}


Measured memory_bytes: 3080
from collections import deque

arr = deque()

for _ in range(int(input())):
    cmd = [int(x) for x in input().split()]

    if cmd[0] == 0:
        if cmd[1]:
            arr.append(cmd[2])
        else:
            arr.appendleft(cmd[2])
    elif cmd[0] == 1:
        print(arr[cmd[1]])
    else:
        if cmd[1]:
            arr.pop()
        else:
            arr.popleft()



Measured memory_bytes: 21960
s = input()

first = int(s[0:2])
second = int(s[2:4])

yymm = 0 < second <= 12
mmyy = 0 < first <= 12

if yymm and mmyy:
    print('AMBIGUOUS')
elif yymm:
    print('YYMM')
elif mmyy:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  ll n;
  ll a[200009];
  ll s = 0;
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) s ^= a[i];
  rep(i, n) a[i] ^= s;
  rep(i, n) cout << a[i] << endl;
  return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> vec(H+1,vector<char>(W+1));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> vec[i+1][j+1];
    }
  }
  vector<vector<int>> dp(H+1,vector<int>(W+1,0));
  if(vec[1][1]=='.')
    dp[1][1]=0;
  else
    dp[1][1]=1;
 
  for(int i=2;i<H+1;i++){
   if(vec[i-1][1]=='.'&&vec[i][1]=='#')
     dp[i][1]=dp[i-1][1]+1;
   else
     dp[i][1]=dp[i-1][1];
  }
 for(int i=2;i<W+1;i++){
   if(vec[1][i-1]=='.'&&vec[1][i]=='#')
     dp[1][i]=dp[1][i-1]+1;
   else
     dp[1][i]=dp[1][i-1];
  }
  
  for(int i=2;i<H+1;i++){
    for(int j=2;j<W+1;j++){
      int k=0;
      int t=0;
      if(vec[i-1][j]=='.'&&vec[i][j]=='#')
        k=1;
      if(vec[i][j-1]=='.'&&vec[i][j]=='#')
        t=1;
      dp[i][j]=min(dp[i-1][j]+k,dp[i][j-1]+t);
    }
  }
  
  cout << dp[H][W] << endl;
  
}

Measured memory_bytes: 380
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = 0
for i in range(n-1):
  if a[i]>k:
    s += a[i]-k
    a[i] = k
for i in range(n-1):
  if a[i]+a[i+1]>k:
    s += a[i]+a[i+1]-k
    a[i+1] = k-a[i]
print(s)

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    cout << a[2]*10+a[1]+a[0] << "\n";
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class CNotSoDiverse {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n,k;
	    in>>n>>k;
	    map<ll,ll> a;
	    rep(i,n){
	        ll t;
	        in>>t;
	        a[t]++;
	    }
	    vector<ll> cnt;
	    for(auto &i:a){
	        cnt.push_back(i.second);
	    }
	    sort(all(cnt));
	    ll ans=0;
	    rep(i,cnt.size()-k){
	        ans+=cnt.at(i);
	    }
	    out<<ans<<endl;




	}
};


int main() {
	CNotSoDiverse solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 14960
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=1e6+100;
const int N=1e5+10;
const int M=1e6+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int main()
{
#ifdef local
      freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;cout.tie(0);
    ll n;cin>>n;
    ll dx=(n+999)/1000;
    cout<<dx*1000-n<<endl;
    return 0;
}


Measured memory_bytes: 3588
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    if n==1:
        print(1)
        return
    H=list(map(int,input().split()))
    M=[0]*n
    M[1]=H[0]
    for i in range(2,n):
        M[i]=max(M[i-1],H[i-1])
    print(sum(1 for i in range(n) if H[i]>=M[i]))
resolve()

Measured memory_bytes: 38256
import java.util.Scanner;
class Main {
    private static Scanner sc;

	public static void main(String[] args) {
        sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        System.out.println(String.format("%d %d %.5f", d, r, f));
    }
}

Measured memory_bytes: 26544
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
int a[110];
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1,d;i<=k;++i){
		scanf("%d",&d);
		while(d--){
			int x;
			scanf("%d",&x);
			a[x]=1;
		}
	}
	for(int i=1;i<=n;++i){
		if(!a[i]) ++ans;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
const int N = 1010,mod = 1e9+7;
int n,m,a[N],b[N],c1[N*N],c2[N*N],ans=1;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),c1[a[i]]++;
	for(int i=1;i<=m;++i)scanf("%d",&b[i]),c2[b[i]]++;
	for(int i=n*m;i;--i){
		if(c1[i]>1||c2[i]>1){puts("0");return 0;}
		c1[i]+=c1[i+1],c2[i]+=c2[i+1];
	}
	for(int i=n*m;i;--i){
		int x1=c1[i]-c1[i+1],x2=c2[i]-c2[i+1];
		if(x1&&x2)continue;
		if(x1)ans=1ll*ans*c2[i]%mod;
		else if(x2)ans=1ll*ans*c1[i]%mod; 
		else ans=1ll*ans*max(0,c1[i]*c2[i]+i-n*m)%mod; 
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 8192
#include <iostream>
using namespace std;
int main()
{
int a,b,c,d,e,f,g,h;
cin>>a;
b=a%10;
c=a/10;
c=c%10;
d=a/100;
d=d%10;
e=a/1000;
if(b==c && c==d || b==c && c==d || c==d && d==e)
cout<<"Yes";
else
cout<<"No";
}


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

#define MOD 1000000007
LL powmod(LL a, LL n){
    if(n == 0) return 1;
    if(n % 2) return (a*powmod(a,n-1)) % MOD;
    LL c = powmod(a, n/2);
    return (c*c) % MOD;
}

int main(){
    string s;
    cin >> s;
    LL numq = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '?') numq++;
    }
    LL ans = 0;
    vector<vector<LL> > q;
    q.resize(2); q[0].resize(3, 0); q[1].resize(3, 0);
    
    vector<vector<LL> > dp = q;
    dp[0][0] = 1;
    for(int i = 0; i < s.size(); i++){
        vector<vector<LL> > newdp = q;
        if(s[i] == '?') numq--;
        for(int a = 0; a < 2; a++){
            for(int b = 0; b < 3; b++){
                int cur = a - b;
                for(int num = 0; num < 2; num++){
                    if(num == 0 && s[i] == '1') continue;
                    if(num == 1 && s[i] == '0') continue;
                    int newcur = cur;
                    if(num == 1) newcur++;
                    if(num == 0) newcur--;

                    int newmax = max(a, newcur);
                    while(newcur + 2 < newmax) newcur += 2;
                    if(newmax >= 2){
                        ans += dp[a][b] * powmod(2, numq);
                        ans %= MOD;
                    } else {
                        newdp[newmax][newmax - newcur] += dp[a][b];
                        newdp[newmax][newmax - newcur] %= MOD;
                    }
                }
            }
        }
        dp = newdp;
    }
    for(int a = 0; a < 2; a++){
        for(int b = 0; b < 3; b++){
            int cur = a-b;
            if(cur > 0){
                ans += dp[a][b];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 900
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	p := []int{}
	q := []int{}
	for i := 0; i < n; i++ {
		p = append(p, stdin.ReadInt())
	}
	for i := 0; i < n; i++ {
		q = append(q, stdin.ReadInt())
	}

	permutations := Permutation(p)
	sort.Sort(Matrix(permutations))

	a := 0
	b := 0
	for i, permutation := range permutations {
		if eql(permutation, p) {
			a = i
		}

		if eql(permutation, q) {
			b = i
		}
	}

	stdout.Println(Abs(a - b))
}

func Permutation(digits []int) [][]int {
	digits = clone(digits)
	permutations := [][]int{}
	permutations = append(permutations, clone(digits))

	n := len(digits)
	p := []int{}
	for i := 0; i < n+1; i++ {
		p = append(p, i)
	}

	for i := 1; i < n; {
		p[i]--
		var j int
		if i%2 == 0 {
			j = 0
		} else {
			j = p[i]
		}

		digits[i], digits[j] = digits[j], digits[i]
		permutations = append(permutations, clone(digits))
		for i = 1; p[i] == 0; i++ {
			p[i] = i
		}
	}

	return permutations
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func clone(digits []int) []int { return append([]int{}, digits...) }

func eql(a, b []int) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

type Matrix [][]int

func (m Matrix) Len() int      { return len(m) }
func (m Matrix) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
func (m Matrix) Less(i, j int) bool {
	for x := 0; x < len(m[i]); x++ {
		if m[i][x] == m[j][x] {
			continue
		}
		return m[i][x] < m[j][x]
	}
	return false
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 8064
a, b = (int(i) for i in input().split())
s = input()
for i in range(a+b+1):
    if i == a:
        if not s[i] == '-':
            print('No')
            exit()
    else:
        if not s[i] >= '0' or not s[i] <= '9':
            print('No')
            exit()
print('Yes')

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

int main() {
    int H, W, N;
    cin >> H >> W >> N;

    int black = 0;
    int ma = max(H, W);
    int mi = min(H, W);
    int ans = 0;

    for (int i = 1; i <= mi; ++i) {
        black += ma;
        if (black >= N) {
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, m;
    cin >> n >> m;

    int hw = 0;
    for(int i=0; i<m; i++){
        int tmp_a; cin >> tmp_a;
        hw += tmp_a;
    }

    if(hw <= n){
        cout << n - hw << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
n, k = map(int, input().split())
dp_a = [0]*(n+1)
dp_b = [n]*(n+1)
mod = 10**9 + 7
l = [i for i in range(n+1)]
ll = [i for i in range(n, -1, -1)]
for i in range(1, n+1):
    dp_a[i] = (dp_a[i-1] + l[i])%mod
    dp_b[i] = (dp_b[i-1] + ll[i])%mod
ans = 0
for i in range(k, n+2):
    ans += (dp_b[i-1]-dp_a[i-1]+1)%mod
print(ans%mod)

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

using namespace std;

int L[200200], R[200200], to[200200];
int n;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	vector<int> vx;
	for (int i = 0; i < n; i++) {
		int x, l;
		cin >> x >> l;
		int s = x - l, t = x + l;
		L[i] = s, R[i] = t;
		vx.push_back(s); vx.push_back(t);
	}
	
	sort(vx.begin(), vx.end());
	vx.erase(unique(vx.begin(), vx.end()), vx.end());
	
	for (int i = 0; i < (int) vx.size(); i++) to[i] = (int) vx.size();
	for (int i = 0; i < n; i++) {
		L[i] = lower_bound(vx.begin(), vx.end(), L[i]) - vx.begin();
		R[i] = lower_bound(vx.begin(), vx.end(), R[i]) - vx.begin();
		to[L[i]] = min(to[L[i]], R[i]);
	}
	for (int i = (int) vx.size() - 2; i >= 0; i--) to[i] = min(to[i], to[i + 1]);
	
	int cnt = 0, cur = 0;
	while (cur < (int) vx.size()) {
		cnt++;
		cur = to[cur];
	}
	cout << cnt - 1 << '\n';
}



Measured memory_bytes: 2676
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdio> 
using namespace std;
int main(){
   char a[5];
   int x=0;
   for(int i=0;i<4;i++)
   {   
      cin>>a[i];
       if(a[i]=='-')
         x--;
      else
         x++;
   }
   cout<<x;
   system("pause");
   return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>

using namespace std;

int main(void){
  string str;
  cin >> str;
  char pre;
  for(int i=0;i<str.length();i++){
    if(str[i] == '?'){
      str[i] = 'D';
    }
  }
  cout << str << endl;
  return 0;
}


Measured memory_bytes: 3708
from collections import defaultdict as ddic
N = int(input())
AA = list(map(int,input().split()))

adic = ddic(int)
for a in AA:
    adic[a] += 1
    
patdic = {}
asum = 0
for key in adic.keys():
    num = adic[key]
    seki = num * (num-1)//2
    
    patdic[key] = seki
    asum += seki
    
# print(adic)
# print(adic.keys())
    
# for key in patdic.keys():
#     print(key)
#     print(adic[key])
#     print(patdic[key])
#     print('---')

for a in AA:
    ans = asum - (patdic[a] ) + (patdic[a] - adic[a]+1)
    print(ans)
    
    
    

Measured memory_bytes: 30776