akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    string S;
    cin >> S;
    int A, B, C, D;
    A = S[0] - '0';
    B = S[1] - '0';
    C = S[2] - '0';
    D = S[3] - '0';
    
    vector<bool> flag(2);
    if(A == 0){
        if(B == 0){
            flag[1] = false;
        }
        else{
            flag[1] = true;
        }
    }
    else if(A == 1){
        if(B >= 0 && B <= 2){
            flag[1] = true;
        }
        else{
            flag[1] = false;
        }
    }
    else{
        flag[1] = false;
    }
    
    if(C == 0){
        if(D == 0){
            flag[0] = false;
        }
        else{
            flag[0] = true;
        }
    }
    else if(C == 1){
        if(D >= 0 && D <= 2){
            flag[0] = true;
        }
        else{
            flag[0] = false;
        }
    }
    else{
        flag[0] = false;
    }
    
    if(flag[0] && !flag[1]){
        cout << "YYMM\n";
    }
    else if(!flag[0] && flag[1]){
        cout << "MMYY\n";
    }
    else if(flag[0] && flag[1]){
        cout << "AMBIGUOUS\n";
    }
    else{
        cout << "NA\n";
    }
}

Measured memory_bytes: 256
#include <iostream>]
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
    string S, T;
    cin >> S >> T;

    int ans = 0;
    rep(i, 3) {
        if (S[i] == T[i]) {
            ans++;
        }
    }

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

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


void solve(long long A, long long B){
    if((A - 2 * B) <= 0) cout << 0 << endl;
    else cout << A - 2 * B << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<cstdio>
int main()
{
	int d,n;
	scanf("%d %d",&d,&n);
    if ((n!=0)&&(n!=100)){
    	if (d==0) printf("%d",n); else 
    	if (d==1)
		printf("%d00",n); else 
		printf("%d0000",n);
	} 
	else if (n==0)printf("0");
	else if (n==100) if (d==0) printf("101"); else 
    	if (d==1)
		printf("10100"); else 
		printf("1010000");
	return 0; 
} 

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main() {
	int i;
	char s[100000];
	for (i = 0; i < 100000; i++) {
		s[i] = 0;
	}
	cin >> s;
	for (i = 0; i < 100000; i++) {
		if ((s[i]!=0)&&((i % 2) == 0)) {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
	int n,a,b,s,max;
	int low[5000];
	for(;;){
		scanf("%d",&n);
		if(n==0){break;}
		max=-100000;
		for(a=0;a<n;a++){
			scanf("%d",&low[a]);
		}
		for(a=0;a<n;a++){
			s=low[a];
			if(max<s){max=s;}
			for(b=a+1;b<n;b++){
				s+=low[b];
				if(max<s){max=s;}
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
void ashi(int p0[2],int p1[2],int p2[2],double p3[2]){
  int x1=p1[0]-p0[0],x2=p2[0]-p0[0],y1=p1[1]-p0[1],y2=p2[1]-p0[1];
  p3[0]=1.0*(x1*x2+y1*y2)/(x1*x1+y1*y1)*x1+p0[0];
  p3[1]=1.0*(x1*x2+y1*y2)/(x1*x1+y1*y1)*y1+p0[1];
}
int cplc(int p0[2],int p1[2],int p2[2],int r,double s[2],double t[2]){
  double p3[2],x1=p1[0]-p0[0],y1=p1[1]-p0[1],l;
  ashi(p0,p1,p2,p3);
  l=r*r-(p3[0]-p2[0])*(p3[0]-p2[0])-(p3[1]-p2[1])*(p3[1]-p2[1]);
  if(l<0)return 0;
  s[0]=p3[0]+x1/hypot(x1,y1)*sqrt(l);
  s[1]=p3[1]+y1/hypot(x1,y1)*sqrt(l);
  t[0]=p3[0]-x1/hypot(x1,y1)*sqrt(l);
  t[1]=p3[1]-y1/hypot(x1,y1)*sqrt(l);
  return 1;
}
int main(){
  int p[4][2],n,i,r,j=0;
  double a[2][2],e=0.000005;
  scanf("%d %d %d %d",&p[2][0],&p[2][1],&r,&n);
  while(n--){
    for(i=0;i<4;i++)scanf("%d",&p[i/2][i%2]);
    cplc(p[0],p[1],p[2],r,a[0],a[1]);
    if(fabs(a[0][0]-a[1][0])<e)j=a[0][1]+e<a[1][1]?0:1;
    else                       j=a[0][0]+e<a[1][0]?0:1;
    printf("%.9f %.9f %.9f %.9f\n",a[j][0],a[j][1],a[1-j][0],a[1-j][1]);
  }
  return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin>>s;
	ll l=s.size();
	ll z=0;
	for(ll i=0; i<l; i++){
		if(s[i]=='o')
			z++;
	}
	ll x=700;
	cout<<x+(z*100);
}

Measured memory_bytes: 3496
import array
import collections
import heapq

AdjacentVertex = collections.namedtuple("AdjacentVertex", "vertex cost")
INF = 2**31 - 1
NO_VERTEX = -1

ans = [0 for i in range(10**5)]


# Prim法で頂点0からの最小全域木を求める
def compute_mst_prim(max_v, adj_list):
    # pred[u]は頂点uの「ひとつ前」の頂点を表す
    pred = collections.defaultdict(lambda: NO_VERTEX)
    # uとpred[u]を結ぶ辺の重みがkey[u]に入る
    key = collections.defaultdict(lambda: INF)
    key[0] = 0
    # 二分ヒープを優先度付きキューとして用いる
    pq = [(key[v], v) for v in range(max_v)]
    heapq.heapify(pq)
    # 優先度付きキューに頂点が入っているかを示す配列
    in_pq = array.array("B", (True for _ in range(max_v)))
    while pq:
        _, u = heapq.heappop(pq)
        in_pq[u] = False
        for v, v_cost in adj_list[u]:
            if in_pq[v]:
                weight = v_cost
                if weight < key[v]:
                    pred[v] = u
                    key[v] = weight
                    ans[v] = ans[pred[v]] + key[v]
                    heapq.heappush(pq, (weight, v))
                    in_pq[v] = True
    return (pred, key)


def main():
    max_v = int(input())
    max_e = max_v - 1
    adjacency_list = collections.defaultdict(set)
    for _ in range(max_e):
        s, t, w = map(int, input().split())
        s -= 1
        t -= 1
        adjacency_list[s].add(AdjacentVertex(t, w))
        adjacency_list[t].add(AdjacentVertex(s, w))
    (_, key) = compute_mst_prim(max_v, adjacency_list)
    for i in range(max_v):
        print(ans[i] % 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 89076
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	int a[N];
	int  i, j, k;
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	int max, min;
	for (i = 0, max = a[0]; i < N; i++) {
		if (max < a[i]) {
			max = a[i];
		}
	}
	for (i = 0, min = a[0]; i < N; i++) {
		if (min > a[i]) {
			min = a[i];
		}
	}
	printf("%d\n", max - min);
	return 0;
}


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

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;
    set<int> ss[26];
    
    for (int i=0; i<N; i++) {
        ss[S[i]-'a'].insert(i);
    }
    
    for (int q=0; q<Q; q++) {
        int ty; cin >> ty;
        
        if (ty==1) {
            int i; cin >> i;
            i--;
            char c; cin >> c;
            if (S[i]==c) continue;
            ss[S[i]-'a'].erase(i);
            ss[c-'a'].insert(i);
          	S[i] = c;
        }
        else {
            int l, r; cin >> l >> r;
            l--;
            r--;
            int ans = 0;
            
            for (int i=0; i<26; i++) {
                if (ss[i].size()==0) continue;
                if (l>*--ss[i].end()) continue;
                int m = *ss[i].lower_bound(l);
                //cout << l << " " << m << endl;
                if (m<=r) ans++;
            }
            
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 25628
import numpy as np
import sys

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = a[0]
list.sort(arr, reverse=True)

if arr[-1] == 0:
    print(arr[-1])
    sys.exit()

ans = 1
for i in range(n):
    ans = ans * arr[i]
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 40124
#include <cstdio>
#include <algorithm>
#pragma warning (disable : 4996)

int main()
{
	int q, h, s, d, n;
	long long ans = 0;
	scanf("%d%d%d%d%d", &q, &h, &s, &d, &n);
	if (s * 2 > d&&h * 4 > d&&q * 8 > d)
	{
		ans = (long long)(n / 2)*d;
		n &= 1;
	}
	int mi = std::min(s, std::min(h * 2, q * 4));
	ans += (long long)n*mi;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
{-# LANGUAGE BangPatterns #-}

solve :: [Int] -> Int
solve = f 0  0
  where
    f !m !n []     = n
    f !m !n (x:xs) = if x >= m then f x (n + 1) xs else f m n xs
    
main = print . solve . map read . words =<< (getLine >> getLine)


Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n; cin >> n;
	map<string,int> hash;
	for(int i = 0 ; i < n ; i++){
		string x;
		cin >> x;
		hash[x]++;
	}
	cout<<int(hash.size())<<"\n";
	
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T0;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 19204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    int n; cin>>n;
    int a[n], b[n], c[n-1];
    for(int i=0; i<n; i++)
        cin >> a[i];
    for(int i=0; i<n; i++)
        cin >> b[i];
    for(int i=0; i<n-1; i++)
        cin >> c[i];
    int ans = 0;
    for(int i=0; i<n; i++){
        ans += b[a[i]-1];
        if(i > 0 && a[i-1]+1 == a[i]){
            ans += c[a[i-1]-1];
        }
    }
    OUT(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using AR2 = array<int, 2>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int dx[4]{1, 0, -1, 0};
constexpr int dy[4]{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}
// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(0);

    int n, k;
    cin >> n >> k;

    int kk = (n - 1) * (n - 2) / 2;

    if (k > kk || k == 2)
    {
        cout << -1 << endl;
        return 0;
    }

    stack<pair<int, int>> lines;
    rep(i, n - 1)
    {
        lines.push(make_pair(0, i + 1));
    }

    if (kk != k)
    {
        rep(i, n)
        {
            rep(j, n - 1)
            {
                int u = j + 1;
                int v = u + i + 1;
                if (v >= n)
                {
                    v = v - n + 1;
                }
                lines.push(make_pair(u, v));
                kk--;
                if (kk == k)
                    break;
            }
            if (kk == k)
                break;
        }
    }

    cout << lines.size() << endl;
    while (!lines.empty())
    {
        auto l = lines.top();
        lines.pop();
        cout << l.first + 1 << " " << l.second + 1 << endl;
    }
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	sort(a.rbegin(),a.rend());
	ll ans = a[0];
	int t = n - 2;
	vector<ll> b;
	REP(i,n-1){
		b.push_back(a[i]);
		b.push_back(a[i]);
	}
	rep(i,t){
		ans += b[i];
	}
	cout << ans << endl;
	return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
  
  	if(N == 1) cout << abs(W-a[0]) << endl;
  	else cout << max(abs(W-a[N-1]), abs(a[N-1]-a[N-2])) << endl;
  
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int n,m,x;
int c[20];
int d[20][20];
int ans;
bool kg;
void search(){
	for (int i=0;i<(1<<n);i++){
		int cost=0,val[20]={};
		for (int j=0;j<n;j++)
			if ((i>>j)%2){
				cost+=c[j];
				for (int k=0;k<m;k++)
					val[k]+=d[j][k];
			}
		for (int j=0;j<m;j++)
			if (val[j]<x)
				goto ll;
		ans=min(ans,cost);
		kg=1;
		//cout<<"val= "<<val[0]<<' '<<val[1]<<' '<<val[2]<<' '<<val[3]<<' '<<val[4]<<endl;
		//cout<<"cost= "<<cost<<endl;
		//cout<<"choose= "<<i<<endl;
		ll:  i=i;//cout<<"ERROR"<<endl;
	}
}
signed main()
{
	cin>>n>>m>>x;
	ans=100000010;
	for (int i=0;i<n;i++){
		cin>>c[i];
		for (int j=0;j<m;j++)
			cin>>d[i][j];
	}
	search();
	if (!kg)  cout<<-1;
	else  cout<<ans;
	re 0;
}

Measured memory_bytes: 3604
import sys

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    ans = 0
    for i in range(K + 1, N + 1):
        ans += (N // i) * (i - K)
        if N % i == 0:
            continue
        ans += max(0, N % i - max(K - 1, 0))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
    int x,y,z,i;
    for(i=0;;i++){
        scanf("%d %d",&x,&y);
        if(x==0 && y==0){
            break;
        }
        if(x > y){
            z=x;
            x=y;
            y=z;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}



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

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

  int n;
  cin >> n;
  ll ans = 0;
  ll min = 10000000000;
  int count = 0;
  bool has_zero = false;
  rep(i, n) {
    ll l;
    cin >> l;
    if (l == 0) {
      has_zero = true;
    } else if (l < 0) {
      count++;
    }
    if (abs(l) < min) {
      min = abs(l);
    }
    ans += abs(l);
  }

  if (has_zero || count % 2 == 0) {
    cout << ans << endl;
  } else {
    cout << ans - 2 * min << endl;
  }
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    int x[n],i;
    for(i=0;i<n;i++)cin>>x[i];
	int min=1e9,j;
	long long s;
	for(i=1;i<=100;i++){
		s=0;
		for(j=0;j<n;j++){
			s+=pow(x[j]-i,2);
		}
		if(s<min)min=s;
	}
	cout<<min;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int W,H,T;
	scanf("%d %d %d",&W,&H,&T);

	int table[H][W];
	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			table[row][col] = 0;
		}
	}

	int P;
	scanf("%d",&P);

	int x,y,t;

	for(int loop = 0; loop < P; loop++){
		scanf("%d %d %d",&x,&y,&t);
		table[y][x]++;
	}

	int ans = 0;
	int tmp;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%d",&tmp);
			ans += table[row][col]*tmp;
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 3196
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, D, P, X, Y;
	cin >> A >> B >> C >> D >> P;

	X = P * A;
	
	if (P > C)
		Y = B + (P - C) * D;
	else
		Y = B;

	if (X > Y)
		cout << Y << endl;
	else
		cout << X << endl;

	return 0;
}

Measured memory_bytes: 3092
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define PR pair
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define REP(i, x, y)   for(int i = (int)(x); i <= (int)(y); i++)
#define FOR(i, x, y)   for(int i = (int)(x); i <  (int)(y); i++)
#define PER(i ,x, y)  for(int i = (int)(x); i >= (int)(y); i--)
#define CH	         ch = getchar()
#define Exit(...)    printf(__VA_ARGS__), exit(0)
#define dln()        fprintf(stderr,"\n")
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef double	  db;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI > VII;
typedef PR<int,int> PII;
typedef vector<PII> VPI;
const	int inf=2e9;
const	LL Inf=1e10;
const	int P=1e9+7;
const	int N=100005;

inline LL IN(){
	LL x = 0;
	int ch = 0, f = 0;
	for (CH; ch != -1 && (ch < 48 || ch > 57); CH) f = (ch == '-');
	for (; ch >= 48 && ch <= 57; CH) x = (x << 1) + (x << 3) + ch - '0';
	return f ? (-x) : x;
}
template<typename T> inline int chkmin(T &a, const T &b){if(b < a) return a = b, 1; return 0;}
template<typename T> inline int chkmax(T &a, const T &b){if(b > a) return a = b, 1; return 0;}

void renew(int &x, const int &y){
	x += y;
	if(x >= P) x -= P;
	if(x <  0) x += P;
}

int Pow(int x, int y, int p){
	int a = 1;
	for (; y; y >>= 1, x = (LL)x * x %p) if(y & 1) a=(LL)a * x%p;
	return a;
}

int n, m;
int f[N], g[N];
char str[N];

int main(){
	scanf("%d", &n);
	scanf("%s", str + 1);
	m = strlen(str + 1);
	f[0] = 1;
	REP(i, 1, n){
		g[0] = (f[0] + (LL)f[1] * 2) % P;
		REP(j, 1, n) g[j] = (f[j - 1] + (LL)f[j + 1] * 2) % P;
		memcpy(f, g, sizeof g);
	}
	printf("%d\n", f[m]);
	return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int l;
    cin >> l;
    cout << setprecision(6) << fixed << 1.0 * l/3.0 * l/3.0 * l/3.0 << '\n';
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
ans = "Yes"
for i in range(1, N):
    if H[i-1] == H[i]:
        continue
    elif H[i-1] <= H[i]-1:
        H[i] -= 1
    elif H[i-1] > H[i]:
        ans = "No"
        break

print(ans)


Measured memory_bytes: 20688
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long n;
vector<long>a;
long ans;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		long x;cin>>x;a.push_back(x);
	}
	while(1)
	{
		long s=0;
		for(int i=0;i<n;i++)s+=a[i]/n;
		if(s==0)break;
		ans+=s;
		for(int i=0;i<n;i++)a[i]-=a[i]/n*n-s+a[i]/n;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-08-22 20:52:00 +0900
# LastModified: 2020-08-22 21:12:19 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    A = list(map(int, input().split()))
    base = A[0]
    ans = 0
    for a in A:
        if base > a:
            ans += base-a
        if base < a:
            base = a
    print(ans)
    


if __name__ == "__main__":
    main()


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

int main()
{
	int n, k;
    cin >> n >> k;
	deque<int> juels;
	for (int i = 0; i < n; ++i)
	{
		int v;
		cin >> v;
		juels.push_back(v);
	}

	int maxsum = 0;
	for (int i = 0; i <= k; ++i)
	{
		//j: get from left
		for (int j = 0; j <= i; ++j)
		{
			vector<int> hand;
			deque<int> juelswork = juels;
			for (int l = 0; l < j; ++l)
			{
				if (juelswork.empty())
				{
					break;
				}
				hand.push_back(juelswork.front());
				juelswork.pop_front();
			}
			for (int r = 0; r < i - j; ++r)
			{
				if (juelswork.empty())
				{
					break;
				}
				hand.push_back(juelswork.back());
				juelswork.pop_back();
			}
			size_t trashop = k - i;
			int trashable = (min)(hand.size(), trashop);
			for (int t = 0; t < trashable; ++t)
			{
				auto it = min_element(hand.begin(), hand.end());
				if (*it < 0)
				{
					hand.erase(it);
				}
			}

			int sum = 0;
			for (const auto val : hand)
			{
				sum += val;
			}

			if (maxsum < sum)
			{
				maxsum = sum;
			}
		}
	}

	cout << maxsum;
}

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

int main() {
    int W,H,x,y,r ;
    cin >> W >> H >> x >> y >> r ;
    
    // まず横から
    if ( x + r > W){
        cout << "No" << endl;
        
    }
    else{
        if( x -r < 0){
            cout << "No" << endl;
        }
        else{
            if( y + r > H){
                cout << "No" << endl;
            }
            else {
                if(y - r < 0){
                    cout << "No" << endl;
                }
                else{
                    cout << "Yes" << endl;
                }
            }
        }
    }
    
}


Measured memory_bytes: 3108
import java.util.*;
public class Main{	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N+1];//cost
		int B[] = new int[N+1];//deadline
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();//initialized
			B[i]=sc.nextInt();//initialized
		}
		
		List<int[]> l = new ArrayList<int[]>();
		for(int i=0;i<N;i++) {
			int tmp[] = {A[i],B[i]};
			l.add(tmp);
		}
		Collections.sort(l,(l1,l2)->l1[1]-l2[1]);
		
		int total=0;
		for(int i=0;i<N;i++) {
			total += l.get(i)[0];
			if(total<=l.get(i)[1]) continue;
			else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
		
	}
}


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

int main(){

int a,b;
int d,r;
double f;

cin>>a>>b;

d=a/b;
r=a%b;
f=double(a)/b;
/* fixed 小数点以下を指定　set...　何桁までか指定*/
cout<<d<<" "<<r<<" "<<fixed<<setprecision(5)<<f<<endl;

return 0;
}


Measured memory_bytes: 3268
n, m, k = map(int, input().split())
gyoli = []
for i in range(n + 1):
  gyoli.append(i)
candiset = set()
for j in range(m + 1):
  for gyo in gyoli:
    candiset.add(gyo*j + (n-gyo)*(m-j))
if k in candiset:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 20876
#include <bits/stdc++.h>
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
    using namespace std;
    using ll = long long;
     
    int main() {
      ll X, K, D;
      cin >> X >> K >> D;
      ll x = abs(X);
      ll a = x / D;
      if (K <= a) {
        cout << abs(x - K * D) << endl;
      } else {
        x = x - a * D;
        if ((K - a) % 2 == 0) {
          cout << min(x, abs(x - 2 * D)) << endl;
        } else {
          cout << min({abs(x - D), abs(x - 3 * D), abs(x + D)}) << endl;
        }
      }
      return 0;
    }

Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

s64 pow_mod(s64 x, s64 n, s64 mod)
{
    s64 ret = 1;
    while (n)
    {
        if (n&1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

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

    s64 n;
    cin >> n;

    s64 ans = pow_mod(10, n, MOD);
    ans = (ans + (MOD - 2 * pow_mod(9, n, MOD) % MOD) % MOD) % MOD;
    ans = (ans + pow_mod(8, n, MOD)) % MOD;

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vi a(n);
		for(int i=0;i<n;i++) cin>>a[i];
		sort(a.begin(),a.end());
		int res=inf;
		for(int i=0;i<n-1;i++) res=min(res,a[i+1]-a[i]);
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3084
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        int c = 1;

        for (int i = 1; i < N; i++) {
            if (S.charAt(i) != S.charAt(i - 1)) {
                c++;
            }
        }

        System.out.println(c);
    }
}

Measured memory_bytes: 24404
N, T = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
ans, sav = 1001, 0
for i in A:
    if i[1] <= T:
        sav = i[0]
        if ans > sav:
            ans = sav
if ans > 1000:
    ans = "TLE"
print(ans)


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

using namespace std;

int N;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N;
    
    int sum = 0;
    int maxVal = 0;
    
    for (int i = 0; i < N; ++i) {
        int pi;
        cin >> pi;
        sum += pi;
        maxVal = max(maxVal, pi);
    }
    
    int res = sum - maxVal / 2;
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
static lld l,x,y,n,m,i,z,p,j,k,c,d,s,t;string s1,s2;
int sum(int i)
{
    p=i;z=0;
    while(i>0)
    {
       p=i%10;
       z=z+p;
       i=i/10;
    }
    return z;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>x>>y;z=x;
    while(z<=y)
    {
        p++;z=z*2;
    }
    cout<<p;
}

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

using namespace std;

const int Nmax = 1e6;
const int Mod = 1e9 + 7;
const int oo = 1e9;

int h1, m1, h2, m2, k;

int main()
{/**
    #ifndef ONLINE_JUDGE
        ifstream cin("test.in");
        ofstream cout("test.out");
    #endif // ONLINE_JUDGE
*/


    cin >> h1 >> m1 >> h2 >> m2 >> k;
    m1 += 60 * h1;
    m2 += 60 * h2;

    cout << m2 - m1  - k << "\n";


    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cmath>

using namespace std;


int main()
{
    //string S, T, U;
    int N, M;
//    int count = 0;

    //double K, S;
    //double x, y, z;


    cin >> N >> M;

  
    if (N == M) { 
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    
    }
    

     return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

struct UnionFind {
  vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
  vector<ll>
      sizes; // sizes[i]:根iの木に含まれるデータの数、根でない場合は無意味な値となる

  UnionFind(ll N) : par(N), sizes(N, 1) { //最初は全てが根であるとして初期化
    for(ll i = 0; i < N; i++)
      par[i] = i;
  }

  ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(ll x, ll y) { // xとyの木を併合
    ll rx = root(x);        // xの根をrx
    ll ry = root(y);        // yの根をry
    if(rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま
    if(sizes[rx] < sizes[ry]) swap(rx, ry); // xの木 > yの木にする
    par[ry] =
        rx; // xとyの根が同じでない(=同じ木にない)時：yの根ryをxの根rxにつける
    sizes[rx] += sizes[ry];
    sizes[ry] = 0; // 一応0にしておく
    return;
  }

  bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
    ll rx = root(x);
    ll ry = root(y);
    return rx == ry;
  }

  ll size(ll x) { // データxが含まれる木の大きさを返す
    return sizes[root(x)];
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M);
  vector<ll> B(M);
  REP(i, M) {
    ll x, y;
    cin >> x >> y;
    A[i] = x - 1;
    B[i] = y - 1;
  }
  vector<ll> ans(M);
  UnionFind uf(N);
  REPR(i, M - 1) {
    if(uf.same(A[i], B[i])) {
      continue;
    } else {
      ans[i] = uf.size(A[i]) * uf.size(B[i]);
      uf.unite(A[i], B[i]);
    }
  }
  REP(i, M - 1) { ans[i + 1] = ans[i] + ans[i + 1]; }
  REP(i, M) { cout << ans[i] << endl; }
  return 0;
}

Measured memory_bytes: 5248
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define repc(i, a, n) for (int i = (a); i <= (int)(n); i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) cerr << (str) << endl;
int main() {
  int k, s;
  cin >> k >> s;
  ll ans = 0;
  repc(x, 0, k) {
    repc(y, 0, k) {
      int z = s - x - y;
      if (x + y + z == s && 0 <= z && z <= k)
        ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int n;
void dfs(string s,int sum,char mx){
	if(sum==n){
		cout<<s<<endl;
		return ;
	}
	for(char z='a';z<=mx+1;z++){
		dfs(s+z,sum+1,max(mx,z));
	}
}
int main(){
	//fixed<<setprecision(3)
	cin>>n;
	dfs("a",1,'a');
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	vector<string> s(3);
	cinf(3,s);
	int nowa=0;int nowb=0; int nowc=0;
	int turn=0;
	while(1){
		if(turn==0&&nowa<s[0].size()){
			turn=(s[0][nowa]-'a');
			nowa++;
		}
		if(turn==1&&nowb<s[1].size()){
			turn=(s[1][nowb]-'a');
			nowb++;
		}
		if(turn==2&&nowc<s[2].size()){
			turn=(s[2][nowc]-'a');
			nowc++;
		}
		if(nowa==s[0].size()&&turn==0){cout << "A"<< endl; return 0;}
		if(nowb==s[1].size()&&turn==1){cout << "B"<< endl; return 0;}
		if(nowc==s[2].size()&&turn==2){cout << "C"<< endl; return 0;}
	}
} 

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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define nl '\n'
#define all(x) (x).begin(), (x).end()
#define int_max numeric_limits<int>::max()
#define int_min numeric_limits<int>::min()
#define ll_max numeric_limits<ll>::max()
#define ll_min numeric_limits<ll>::min()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define im(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// custom sort example
//sort(all(a), [ ]( const auto& c, const auto& d) {
	//if (c.fi.se != d.fi.se) {
		//return c.fi.se < d.fi.se; // lower first
	//}
	//if (c.fi.fi != d.fi.fi) {
		//return c.fi.fi > d.fi.fi; // higher first
	//}
	//return c.se > d.se; // higher first
//});

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n;
	cin >> n;
	int act = 0;
	bool ok = false;
	for (int i = 0; i< n; i++) {
		int a, b;
		cin >> a >> b;
		if (a == b) {
			act++;
		} else {
			act = 0;
		}
		if (act == 3) {
			ok = true;
		}
	}
	if (ok) {
		cout << "Yes" << nl;
	} else {
		cout << "No" << nl;
	}
}


Measured memory_bytes: 3636
import java.lang.StringBuilder

fun main(args: Array<String>) {
    val countStudent = readLine()!!.toInt()
    val map = mutableMapOf<Int, Int>()

    readLine()!!.split(" ").map { it.toInt() }.forEachIndexed { index, int ->
        map[index + 1] = int
    }

    val sb = StringBuilder()
    val sortedList = map.toList().sortedBy { it.second }.forEachIndexed{ index, int ->
        sb.append(int.first)
        if (index != countStudent) sb.append(" ")
    }

    print(sb)
}

Measured memory_bytes: 95640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans=0;
  
  if (a>=k) {
      cout << k << endl;
      return 0;
  }
  if (a+b>=k) {
      cout << a << endl;
      return 0;
  }
  cout << a-(k-a-b) << endl;
  return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;

    void solve(){
        ll a,b;
        cin>>a>>b;
        ll n = 1,tot=1,ans=0;
        while(tot<b){
                n = tot;
              for(int i=0;i<n;i++){
                tot += (a-1);ans++;//cout<<tot<<" ";
                if(tot>=b) break; 
              }  
        }
        cout<<ans;
    }
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        //int n;cin>>n; for(int i=0;i<n;i++)
        solve();
        return 0;
    } 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,k,ans=0;
    cin >> n >> k;
    bool flag[n];
    fill(flag,flag+n,false);
    for (ll i=0;i<k;i++){
        ll d;
        cin >> d;
        for (ll j=0;j<d;j++){
            ll a;
            cin >> a;
            flag[a-1]=true;
        }
    }
    for (ll i=0;i<n;i++){
        if (!flag[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	pair<int, int> a[n];
	for (int i = 0; i < n; i++){
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	sort(a, a+n);

	for (int i = 0; i< n-1; i++){
		cout << a[i].second << " ";
	}
	cout << a[n-1].second << endl;

}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, ans{};
	cin >> n;
	for (int i = 1, x; i <= n; i++) {
		cin >> x;
		if ((i&1) && (x&1)) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    double sum =0;
    rep(i, n) cin >> v[i];
    sort(all(v));

    for(int i=0; i<n-1; i++){
        if(i==0) sum = (v[i] + v[i+1]) / 2;
        else sum = (sum + v[i+1]) / 2;
    }
    out(sum);
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;

void main() {
	auto input = getStdin!(string[])()[0];
	int[] num = input.split(" ").to!(int[]);
	string sign = "";
	if (num[0] < num[1]) sign = "<";
	else if (num[0] > num[1]) sign = ">";
	else sign = "==";
	writefln("a %s b", sign);
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

Measured memory_bytes: 2516
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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; }

using ll = long long;

ll N, K;
ll A[200010], S[200010];
std::map<ll, ll> mp;
ll ans;

int main()
{
  std::cin >> N >> K;

  rep( i, N )
    std::cin >> A[i], --A[i];

  rep( i, N )
    S[i+1] = (S[i]+A[i]%K)%K;

  rep( i, N+1 )
  {
    ans += mp[S[i]%K];

    ++mp[S[i]%K];

    if( i-K+1 >= 0 )
      --mp[S[i-K+1]%K];
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
typedef long long ll;
using namespace std;
int main(){
    int m;cin>>m;
    ll sum=0;
    ll bit=0;
    for(int i=1;i<=m;i++){
        ll a,b;
        cin>>a>>b;
        sum+=a*b;
        bit+=b;
    }
    ll x=sum/9;   
    if(sum%9==0) x--;
    ll y=bit-1;    
    cout<<x+y<< endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])

i, j = len(s), len(t)
ans = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        ans += s[i - 1]
        i -= 1
        j -= 1
print(ans[::-1])

Measured memory_bytes: 113244
#include <iostream>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <cmath>
//#include <vector>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int upper;
    int lower;
    bool is_upper_m = true;
    bool is_lower_m = true;
    string s;
    cin >> s;
    upper = (s[0]-'0')*10+(s[1]-'0');
    lower = (s[2]-'0')*10+(s[3]-'0');
    if(upper<1 || upper>12){
        is_upper_m = false;
    }
    if(lower<1 || lower>12){
        is_lower_m = false;
    }
    if(is_lower_m && !is_upper_m){
        cout << "YYMM";
    }else if(!is_lower_m && is_upper_m){
        cout << "MMYY";
    }else if(is_lower_m && is_upper_m){
        cout << "AMBIGUOUS";
    }else{
        cout << "NA";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	string ss;
	int64 aa, bb;
	cin >> aa;
	if(aa == 1)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 1 << endl;
	}
	return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll a,b,c;
cin>>a>>b>>c;
ll l1 = max(max(a,b),c);
ll l2 = min(min(a,b),c);
ll l3 = a+b+c-l1-l2;
if(l1%2==0){
    cout<<0<<endl;
}
else{
    ll S1 = ((l1-1)/2)*l2*l3;
    ll S2 = (((l1-1)/2)+1)*l2*l3;
    cout<<abs(S1-S2)<<endl;
} 

return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
b=[]
c=0
d=0
for i in range(m):
    c,d=map(int,input().split())
    a.append(c)
    b.append(d)
c=max(a)
d=min(b)
if(c>d):
    print('0')
elif(d-c+1<=n):
    print('{0}'.format(d-c+1))
else:
    print('{0}'.format(n))

Measured memory_bytes: 11016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;

int forw[maxn][18];
int pos[maxn];
int l,Q,n;

int main() {
	FAST
	cin >> n;
	for (int i =1;i<=n;i++) cin >> pos[i];
	
	cin >> l >> Q;
	memset(forw,-1,sizeof forw);
	queue <int> q;
	for (int i =1;i<=n;i++) {
		while (!q.empty() and pos[i] - pos[q.front()] > l) {
			//cout << i << " " << q.front() << "\n";
			forw[q.front()][0] = i-1;
			q.pop();
		}
		q.push(i);
	}
	//cout << "HELLO";
	
	//while (!q.empty()) {
		//q.pop();
	//}
	for (int k=1;k<=17;k++) {
		for (int i =1;i<=n;i++) {
			if (forw[i][k-1] == -1) forw[i][k] = -1;
			else forw[i][k] = forw[forw[i][k-1]][k-1];
		}
	}
	//cout << "HELLO";
	
	
	for (int i=0;i<Q;i++) {
		int a,b; cin >> a >> b;
		if (a > b) swap(a,b);
		ll ans = 0;
	
		for (int k=17;k>=0;k--) {
			if (forw[a][k] != -1 and forw[a][k] <= b) {
				a = forw[a][k];
				ans |= (1 << k);
			}
		}
		if (a < b) ans += 1;
		cout << ans << "\n";
	}
	
}






Measured memory_bytes: 8320
<?php

while($line = fgets(STDIN)){
	$arrA = explode(" ", trim($line));
	
	$line = fgets(STDIN);
	$arrB = explode(" ", trim($line));
	
	$hit = 0;
	$brow = 0;
	for($i = 0; $i < count($arrA); $i++){
		if($arrA[$i] == $arrB[$i]){
			$hit++;
		}
		for($j = 0; $j < count($arrB); $j++){
			if($arrA[$i] == $arrB[$j]){
				$brow++;
			}
		}
	}
	
	$brow -= $hit;
	echo "{$hit} {$brow}\n";
}

Measured memory_bytes: 15320
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String string = scanner.next();
		char c[] = string.toCharArray();
		boolean b = false;
		for (int i = 0; i < c.length; i++) {
			if(!b && c[i] == 'C'){
				b = true;
			}
			if(b && c[i] == 'F'){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 10192