akhauriyash/Code-Regression huggingface dataset:
import sys

X, Y, A, B, C = map(int, sys.stdin.readline().strip().split())

P = list(map(int, sys.stdin.readline().strip().split()))
Q = list(map(int, sys.stdin.readline().strip().split()))
R = list(map(int, sys.stdin.readline().strip().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

P = P[:X]
P.sort()
Q = Q[:Y]
Q.sort()

ans = 0
i, j, k = 0, 0, 0
while C > k:
    if X > i and Y > j:

        if P[i] >= Q[j]:
            if R[k] > Q[j] and Y > j:
                Q[j] = R[k]
                j += 1
                k += 1
            elif R[k] > P[i] and X > i:
                P[i] = R[k]
                i += 1
                k += 1
            else:
                break
 
        elif P[i] < Q[j]:
            if R[k] > P[i] and X > i:
                P[i] = R[k]
                i += 1
                k += 1
            elif R[k] > Q[j] and Y > j:
                Q[j] = R[k]
                j += 1
                k += 1
            else:
                break
    elif X > i:
        if R[k] > P[i]:
            P[i] = R[k]
            i += 1
            k += 1
        else:
            break
    elif Y > j:
        if R[k] > Q[j]:
            Q[j] = R[k]
            j += 1
            k += 1
    else:
        break

# print(P)
# print(Q)
print(sum(P) + sum(Q))

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

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

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}


int main() {
    int n;
    cin >> n;
    int flag = 0;

    while (n) {
        int temp = n % 10;
        if (temp == 7) {
            flag = 1;
        }
        n = n / 10;
    }

    if (flag == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n,m = map(int,input().strip().split()) # nコの展望台，m本の道
    h = list(map(int, input().strip().split())) # h[i]は展望台iの「高さ」
    # g=[]
    S=set([i for i in range(n)])
    for i in range(m): # 「m本の道」についてのループ # 道 j は展望台 Aj と展望台 Bj を結んでいる
        a,b = map(lambda x:int(x)-1,input().strip().split())
        if h[a]>h[b]:
            S.discard(b)
        elif h[a]<h[b]:
            S.discard(a)
        else:
            S.discard(a); S.discard(b)
    print(len(S))

if __name__ == '__main__':
    main()

Measured memory_bytes: 110144
H, W = map(int, input().split())
fields = [list(map(lambda c: c == '#', input())) for _ in range(H)]

checking = []
for i, row in enumerate(fields):
    for j, elem in enumerate(row):
        if elem:
            checking.append( (i, j) )

counter = 0
while True:
    to_check = []
    for y, x in checking:
        for dy, dx in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            if 0 <= x+dx < W and 0 <= y+dy < H and not fields[y+dy][x+dx]:
                fields[y+dy][x+dx] = True
                to_check.append( (y+dy, x+dx) )

    if not to_check:
        break
    checking = to_check
    counter += 1

print(counter)


Measured memory_bytes: 106860
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

using namespace std;

int main()
{
    int n ;
    cin >>n;
    cout << n*n*n << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int p[4][3][10] = {0};
 	int n,b,f,r,v;
	int i,j,k;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		p[b - 1][f - 1][r - 1] += v;	
	}
	
	for(i = 0;i < 4;i++){
		for(j = 0;j < 3;j++){
			for(k = 0;k < 10;k++){
					printf(" %d",p[i][j][k]);
			}
			putchar('\n');
		}
		if(i < 3)
			puts("####################");
	}

	
	return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
string x;
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	cin>>x;
	int cnt=0;
	int len=x.length();
	int cnt0=0;
	int cnt1=0;
	rep(i,0,len)
	{
		if(x[i]=='1')
		{
			cnt1++;
		}else
		{
			cnt0++;
		}
	}
	cnt=min(cnt0,cnt1);
	cout<<cnt+cnt<<endl;
	
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll nax = 1e5 + 5;
const int M = 1e9 + 7;
ll mod(ll x)
{
  return ((x % M + M) % M);
}

ll add(ll a, ll b)
{
  return mod(mod(a) + mod(b));
}

ll mul(ll a, ll b)
{
  return mod(mod(a) * mod(b));
}

void solve()
{
  ll sum = 0, ans = 0, n;
  cin >> n;
  ll a[n];
  for (auto &x : a)
    cin >> x, sum += x;
  ll pre[n] ;
   pre[0] = a[0];
  for (ll i = 1; i < n; i++)
    pre[i] = add(pre[i - 1], a[i]);
  for (ll i = 0; i < n; i++)
  {
    ll temp = mul(a[i] , sum - pre[i]);
    ans = add(ans, temp);
  }
  cout << ans;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 6752
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    //入力
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    
    //移動時間の最小値を求める
    long long MinTime = min({A, B, C, D, E});
    
    //都市６に全員が到達するまでの最小時間を求める
    long long ans = (N + MinTime - 1) / MinTime + 4;
    
    //出力
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
  d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,Z[d]=1,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
int N;
main(){for(cin>>n>>k,N=n;--n;*Z-=T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=0);n<N;a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;
       //*Z-=*O=W(*O=0);
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

int main()
{
   long long n,a,b,c,r,ans;
   cin>>n>>a>>b;
   
   c = n/(a+b);
   r = n%(a+b);
   
   ans = a*c + min(r,a);
   
   cout<<ans<<endl;
   
   return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var ab = ReadLine().Split().Select(int.Parse).ToArray();
        int a = ab[0];
        int b = ab[1];
        int d = b - a;
        int p = 0;
        for (int i = 0; i < d; i++)
        {
            p += i;
        }
        WriteLine(p-a);
    }
}


Measured memory_bytes: 27868
from sys import exit

N = int(input())
A = list(map(int, input().split()))

dp = [[0] * 2 for i in range(N + 1)]
dp[0][0] = 0
dp[0][1] = -10 ** 6

for i in range(N):
    dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
    dp[i + 1][1] = max(dp[i][1] + A[i], dp[i][0] - A[i])

print(dp[N][0])


Measured memory_bytes: 25580
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  int dp[n];
  dp[0]=0;
  if(n>1) dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	char S[100005];
	int N,i=0,num=0;
	int Y[105];
	scanf("%d",&N);
	scanf("%s",S);
	while(i<N){
		if(S[i]=='X'&&S[i+1]=='O')
			++num,i+=2;
		else if(S[i]=='O'&&S[i+1]=='X')
			++num,i+=2;
		else i++;}
	printf("%d\n",num);

	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    string s,t;cin>>s>>t;
    cout<<t<<s<<endl;
}

Measured memory_bytes: 256
use std::io;
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
    loop {
        let n: Vec<usize> = read_vec();
        if n[0] == 0 && n[1] == 0 {
            break;
        }
        for i in 0..n[0] {
            println!(
                "{}",
                if i == 0 || i == n[0] - 1 {
                    "#".repeat(n[1])
                } else {
                    format!("#{}#", ".".repeat(n[1] - 2))
                }
            );
        }
        println!();
    }
}



Measured memory_bytes: 5036
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    
    if (s == "SUN") cout << "7";
    if (s == "MON") cout << "6";
    if (s == "TUE") cout << "5";
    if (s == "WED") cout << "4";
    if (s == "THU") cout << "3";
    if (s == "FRI") cout << "2";
    if (s == "SAT") cout << "1";
    
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
//By : BebekJK
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 1000000007
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

typedef long long ll;
typedef long double ld;
typedef pair<int , int> pii;
typedef pair<long long , long long> pll;

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
int main(){
//	BOOST();
	int N;
	cin>>N;
	cout<<(1000-N%1000)%1000<<endl;
}







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

int main() {
  constexpr int d = 60;
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, ans = 0;
    cin >> n;
    vector<uint64_t> a(n), w(d);
    for (int j = 0; j < n; j++) {
      cin >> a.at(j);
    }
    string s;
    cin >> s;
    for (int j = n - 1; j >= 0; j--) {
      if (s.at(j) == '1') {
        uint64_t m = a.at(j);
        for (int k = 0; k < d; k++) {
          if ((m >> k) & 1ul) m ^= w.at(k);
        }
        if (m) {
          ans = 1;
        }
      } else {
        uint64_t m = a.at(j);
        for (int k = 0; k < d; k++) {
          if ((m >> k) & 1ul) {
            if (w.at(k) == 0) {
              w.at(k) = m;
            }
            m ^= w.at(k);
          }
        }
      }
    }
    cout << ans << "\n";
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <long long mod>
struct modular {
    long long value;
    modular(long long x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }
    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        long long a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            long long t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular operator-() { return modular(-value); }
    modular operator+(modular rhs) { return modular(*this) += rhs; }
    modular operator-(modular rhs) { return modular(*this) -= rhs; }
    modular operator*(modular rhs) { return modular(*this) *= rhs; }
    modular operator/(modular rhs) { return modular(*this) /= rhs; }
    bool operator==(modular rhs) { return value == rhs.value; }
    bool operator!=(modular rhs) { return value != rhs.value; }
    bool operator<(modular rhs) { return value < rhs.value; }
};
template <long long mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <long long mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <long long mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
};
const long long mod = (long long)1e9 + 7;
using mint = modular<mod>;

inline mint pw(mint a, long long n) {
    mint res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= a;
        }
        a *= a;
        n >>= 1;
    }
    return res;
}
vector<mint> fact, finv;
inline void cinit(int n) {
    fact.resize(n, 1);
    finv.resize(n, 1);
    for (int i = 2; i < n; i++) {
        fact[i] = fact[i - 1] * i;
    }
    finv[n - 1] /= fact[n - 1];
    for (int i = n - 2; i >= 2; i--) {
        finv[i] = finv[i + 1] * (i + 1);
    }
}
inline mint C(int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cinit(500500);
    int n, m;
    cin >> n >> m;
    mint ans = fact[m] * finv[m - n];
    ans *= ans;
    for (int i = 1; i <= n; i++) {
        mint t = fact[m - i] * finv[m - n];
        t *= t;
        t *= C(n, i) * C(m, i) * fact[i];
        if (i % 2 == 1) {
            ans -= t;
        } else {
            ans += t;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 11068
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b;
    std::cin>>a>>b;

    int res;
    if(a + b < 24){
        res = a + b;
    }else{
        res = a + b - 24;
    }
    std::cout<<res<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int ok(int x,ll k, vector<int> &a){
	int res = 0;
	rep(i, a.size()) {
		res += (a[i] - 1) / x;
	}
	return res <= k;
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll max = a[0];
	ll res = 0;
	rep(i, n)
	{
		if (max < a[i]){
			max = a[i];
		} else{
			res += max - a[i];
		}
	}
	cout << res << endl;

	return 0;
}

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll k,a,b,i,flag=0;
	cin >> k >> a >> b;
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			flag=1;
			break;
		}
	}
	if(flag)
	{
		cout << "OK" << endl;
	}
	else
	{
		cout << "NG" << endl;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    srand(time(0));
    int n, h, w;
    cin >> w >> h >> n;
    vector<set<int> > kek(w);
    for (int i=0; i < n; i++){
        int x, y;
        cin >> y >> x;
        kek[y-1].insert(x-1);
    }
    int R = 0;
    for (int i=0; i < w-1; i++){
        int M = 1e9;
        if (kek[i+1].size()) M = *kek[i+1].begin();
        if (M <= R){
            cout << i+1;
            return 0;
        }
        if (M!= R+1) R++;
    }
    cout << w << endl;

}


Measured memory_bytes: 19200
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int min = Integer.MAX_VALUE;
			for(int i = 1; i < n;i++){
				int a = i;
				int b = n - i;
				int sum = 0;
				while(a > 10){
					sum += a % 10;
					a /= 10;
				}
				sum += a;
				while(b > 10){
					sum += b % 10;
					b /= 10;
				}
				sum += b;
				
				min = Math.min(min, sum);
			}
			System.out.println(min);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
using namespace std;
/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main()
{
	kira;
    lli T=1;
    //cin>>T;
    while(T--)
    {
    	lli n,a=0,t=50;
        cin>>n;
        while(n/t)
        {
            a+=n/t;
            t*=5;
        }
        t=10;
        a+=n/t;
        if(n%2==0)
            cout<<a<<endl;
        else
            cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var rdx = Input.ar;
        for(var i=0;i<10;i++)
        {
            rdx[2] = rdx[0] * rdx[2] - rdx[1];
            WriteLine(rdx[2]);
        }
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647

vector<ll> binary(ll bina)
{
    vector<ll> data;
    for (ll i = 0; bina > 0; i++)
    {
        data.push_back((bina % 2));
        bina = bina / 2;
    }
    return data;
}
vector<ll> bin(vector<ll> C)
{
    vector<ll> data;
    ll i = 0;
    ll y = 0;
    for (ll m : C)
    {
        y += m * (ll)pow(2, i);
        data.push_back(y);
        i++;
    }
    return data;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    vector<ll> A = binary(a); //2だったら0,1とかで入っている。
    vector<ll> B = binary(b);
    for (ll i = A.size(); i < B.size(); i++)
    {
        A.push_back(0);
    }
    vector<ll> A_ = bin(A);
    vector<ll> B_ = bin(B); //その桁までの値を格納している。
    //数的にはA+1-B
    vector<ll> C;
    ll i = 0;
    ll store = 0;

    for (ll x : A)
    {
        ll u = A_[i] % (ll)pow(2, i + 1);   //周期のu番目(index)
        ll v = (b - a) % (ll)pow(2, i + 1); //始まりからどんぐらいの場所まで行くか。
        ll d = (b - a) / (ll)pow(2, i + 1); //何回回りましたか。
        //uから始まり、＋vのところまで行くという情報が大事。
        //pow(2, i)の個数0が続き、残りpow(2, i)１が続く
        ll count = 0;
        //現在u番目にいる。そしてその後、u+vまで進む。
        //uからu+vまでに何個あるかを考える
        if (u < (ll)pow(2, i))
        {
            if (u + v >= (ll)pow(2, i))
            {
                count = min(u + v, (ll)pow(2, i + 1) - 1) - (ll)pow(2, i) + 1;
            }
        }
        else
        {
            if (u + v < 2 * (ll)pow(2, i))
            {
                count = v + 1; //これは確実にあっている。
            }
            else if (u + v < 3 * (ll)pow(2, i))
            {
                count = (ll)pow(2, i + 1) - 1 - u + 1;
            }
            else if (u + v >= 3 * (ll)pow(2, i))
            {
                count = (ll)pow(2, i + 1) - 1 - u + 1 + u + v - 3 * (ll)pow(2, i) + 1;
            }
        }
        //やり方わかっているので適当にやれ
        /*if (u + v < (ll)pow(2, i + 1))
        {
            count += max(u + v + 1, (ll)pow(2, i)) - max(u - 1, (ll)pow(2, i) - 1);
        }
        else if (u + v < 3 * (ll)pow(2, i) && u + v >= (ll)pow(2, i + 1))
        {
            count += (ll)pow(2, i + 1) - max(u, (ll)pow(2, i));
        }
        else
        {
            count += (ll)pow(2, i + 1) - max(u, (ll)pow(2, i)) + u + v - (ll)pow(2, i) * 3 + 1;
        }*/

        /*for (ll k = u; k <= u + v; k++)
        {
            if (k % (ll)pow(2, i + 1) >= (ll)pow(2, i))
            {
                count += 1;
            }
        }*/
        //count = 1 + min(u + v % (ll)pow(2, i + 1), (ll)pow(2, i)) - max(u % (ll)pow(2, i + 1), (ll)pow(2, i));
        count += d * pow(2, i);
        count %= 2;
        store += count * pow(2, i);
        i++;
    }

    cout << store;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

string rev(string s) {
	reverse(s.begin(), s.end());
	return s;
}

int main() {
	int m; cin >> m;
	while (m--) {
		string s;
		cin >> s;

		set<string> S;
		for (int i = 1; i < s.size(); i++) {
			S.insert(s.substr(0, i) + s.substr(i));
			S.insert(rev(s.substr(0, i)) + s.substr(i));
			S.insert(s.substr(0, i) + rev(s.substr(i)));
			S.insert(rev(s.substr(0, i)) + rev(s.substr(i)));
			S.insert(s.substr(i) + s.substr(0, i));
			S.insert(s.substr(i) + rev(s.substr(0, i)));
			S.insert(rev(s.substr(i)) + s.substr(0, i));
			S.insert(rev(s.substr(i)) + rev(s.substr(0, i)));
		}
		cout << S.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1296
N, L = map(int, input().split())
S = []

for i in range(N):
   S.append(input())

for i in range(N):
    if (min(S) == "~XXX"):
        break

    print(min(S).replace('\n',''),end="")
    # print(S.index(min(S)))
    S[S.index(min(S))] = "~XXX"


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<String> dic = new HashSet<>();
        int n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            String com = sc.next();
            String word = sc.next();
            if(com.equals("insert")) dic.add(word);
            if(com.equals("find")) {
                if(dic.contains(word)) System.out.println("yes");
                else System.out.println("no");
            }
        }
    }
}


Measured memory_bytes: 210088
#include <bits/stdc++.h>
	#include <set>
	#define ll long long 
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=1;i<n;i++)
	using namespace std;
	ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}

	int power(ll int x,  ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
	void fastio()
	{					
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	 ll int dp[101][100001];
	void solve()
	{
		ll int n,w,i,j;cin>>n>>w;
		ll int weights[n],values[n];
		rep(i,n)
		{
			cin>>weights[i]>>values[i];

		}
		
		rep(i,101)
		rep(j,100001)
		dp[i][j]=1e10;
		

		// rep(i,100001)
		// dp[0][i]=0;

		rep(i,101)
		dp[i][0]=0;

		for(i=1;i<=n;i++)
		{
			for(j=0;j<=100000;j++)
			{
				if (values[i-1]<=j)
					dp[i][j]=min(dp[i-1][j],weights[i-1]+dp[i-1][j-values[i-1]]);
				else
					dp[i][j]=dp[i-1][j];

			}
			

		}
		 
		
		ll int ans=-1;
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=100000;j++)
			{
				if (dp[i][j]<=w)
					ans=max(ans,j);
			}
		}
		cout<<ans<<endl;
    }
	int main()
	{
		fastio();
		ll int t;
		t=1;
		// cin>>t;
		
		while(t--)
		{
			solve();
		}
			
	}
			

Measured memory_bytes: 82528
#include<iostream>
#include<algorithm>
using namespace std;
bool binarySearch(int A[], int n, int key)
{
	int left = 0;
	int right = n - 1;
	while (left <= right)
	{
		int mid = (left + right) / 2;
		if (A[mid] == key)
			return true;
		else if (key < A[mid])
			right = mid - 1;
		else if (key > A[mid])
			left = mid + 1;
	}
	return false;
}
int main()
{
	int n;
	cin >> n;
	int *S = new int[n];
	for (int i = 0; i < n; i++)
		cin >> S[i];
	sort(S, S + n);
	int q;
	cin >> q;
	int *T = new int[q];
	for (int i = 0; i < q; i++)
		cin >> T[i];
	int count = 0;
	for (int i = 0; i < q; i++)
		if (binarySearch(S, n, T[i]))
			count++;
	cout << count << endl;
	delete[] S;
	delete[] T;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int N=3005;

vector<ll>wt(N);
vector<ll>val(N);

ll dp[N][N];
ll fp[N][N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,t;
    cin>>n>>t;
    for(int i=1;i<=n;i++){
        cin>>wt[i]>>val[i];
    }
    for(int i=0;i<=n;i++){
        for(int w=0;w<=t;w++){
            if(i==0 || w==0)dp[i][w]=0;
            else if(wt[i]<=w){
                dp[i][w]=max(dp[i-1][w],val[i]+dp[i-1][w-wt[i]]);
            }
            else{
                dp[i][w]=dp[i-1][w];
            }
        }
    }
    for(int i=n;i>=1;i--){
        for(int w=0;w<=t;w++){
            if(w==0)fp[i][w]=0;
            else if(wt[i]<=w){
                fp[i][w]=max(fp[i+1][w],fp[i+1][w-wt[i]]+val[i]);
            }
            else{
                fp[i][w]=fp[i+1][w];
            }
        }
    }

    ll res=0;
    for(int i=1;i<=n;i++){
        for(int w=0;w<t;w++){
            res=max(res,dp[i-1][w]+val[i]+fp[i+1][t-1-w]);
        }
    }
    cout<<res<<endl;
    return 0;
    }


Measured memory_bytes: 141312
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;

int main(){
    int A,B,X;
    cin >> A >> B >> X;
    
    if(A+B>=X && A<=X){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-


N = int(input())
e = [int(i) for i in input().split()]

ans = 0

for i in range(len(e)):
    if i==0:
        ans += 1
        continue

    flg = True
    for i2 in range(i+1):
        if e[i2]>e[i]:
            flg = False

    if flg:
        ans += 1

print(ans)

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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;

int solve(int h, int w, vector<pair<int, int>> a) {
    int n = a.size();
    sort(a.begin(), a.end());

    int y = 0;

    int j = 0;

    for (int x = 1; x < h; x++) {
        while (j < n && a[j].first < x) j++;

        if (j < n && a[j].first == x && a[j].second <= y) {
            return x;
        }
        if (j < n && a[j] != make_pair(x, y + 1) && y < w-1) {
            y++;
        }
    }
    return h;
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int h, w, n;
    while (scanf("%d%d%d", &h, &w, &n) == 3) {
        vector<pair<int, int>> a(n);
        for (int i = 0; i < n; i++) {
            scanf("%d%d", &a[i].first, &a[i].second);
            a[i].first--;
            a[i].second--;
        }

        printf("%d\n", solve(h, w, a));
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> edge(n, vector<bool>(n, false));
    
    rep(m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        edge[a][b] = edge[b][a] = true;
    }
    
    vector<int> f(n-1);
    repeat(i, n-1) f[i] = i+1;
    
    auto check = [](const vector<int> &tf, const vector<vector<bool>> &edge) -> bool {
        vector<int> f {0};
        f.insert(f.end(), tf.begin(), tf.end());
        int n = f.size();
        
        repeat(i, n-1) {
            int src = f[i];
            int dst = f[i+1];
            if (!edge[src][dst]) return false;
        }
        return true;
    };
      
    int ans = 0;
    do {
        if (check(f, edge)) ++ans;
    } while (next_permutation(f.begin(), f.end()));
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
local x, y = io.read("*n", "*n")
if x == 0 then
  if 0 <= y then
    print(y)
  else
    print(1 - y)
  end
elseif y == 0 then
  if 0 < x then
    print(x + 1)
  else
    print(-x)
  end
elseif 0 < x and 0 < y then
  if x <= y then
    print(y - x)
  else
    print(2 + x - y)
  end
elseif x < 0 and 0 < y then
  print(1 + math.abs(x + y))
elseif x < 0 and y < 0 then
  if x <= y then
    print(y - x)
  else
    print(2 + x - y)
  end
else
  print(1 + math.abs(x + y))
end


Measured memory_bytes: 508
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};
use std::collections::HashSet;

fn main() {
   let mut set = HashSet::new();
   input! {
      n:usize,k:usize
   }
   for _ in 0..k {
      input! {
         d:usize,
         a:[usize;d]
      }
      for i in a {
         set.insert(i);
      }
   }
   println!("{}", n - set.len());
}


Measured memory_bytes: 2184
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include <numeric>
using namespace std;
#include <stdio.h>
int n;
int a[200010];
int counter = 0;
int main(void)  {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    for (int i=0;i<n;i++) {
        if (a[i] == counter+1) {
            counter++;
        }
    }
    if(counter == 0) {
        cout << -1 << endl;
    } else {
        cout << n - counter << endl;
    }
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x, a, b;
  cin >> x >> a >> b;
  int sum = (x + b) - (x + a);
  if (sum > 0 && sum > x) {
  	cout << "dangerous\n";
  }else if (sum > 0 && sum <= x) {
  	cout << "safe\n";
  }else {
    cout << "delicious\n";
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	h, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	w, _ := strconv.Atoi(sc.Text())

	skipRows := makeTrues(h)
	skipCols := makeTrues(w)
	white := byte('.')

	matrix := make([][]byte, h)
	for i := 0; i < h; i++ {
		sc.Scan()
		row := sc.Text()
		matrix[i] = make([]byte, w)

		skipRow := true
		for j := 0; j < w; j++ {
			matrix[i][j] = row[j]
			skipRow = skipRow && matrix[i][j] == white
			skipCols[j] = skipCols[j] && matrix[i][j] == white
		}
		skipRows[i] = skipRow
	}

	colLen := 0
	for _, skip := range skipCols {
		if !skip {
			colLen += 1
		}
	}

	out := bufio.NewWriter(os.Stdout)
	for i, row := range matrix {
		if skipRows[i] {
			continue
		}
		for j, p := range row {
			if skipCols[j] {
				continue
			}
			fmt.Fprintf(out, string(p))
		}
		fmt.Fprintln(out)
	}
	out.Flush()
}

func makeTrues(n int) []bool {
	bs := make([]bool, n)
	for i := 0; i < n; i++ {
		bs[i] = true
	}
	return bs
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <tuple>

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<std::pair<int, int>> PY(M);
  for (auto& pi: PY) scanf("%d %d", &pi.first, &pi.second);

  std::map<int, std::vector<int>> aux;
  for (auto& pi: PY) {
    int p, y;
    std::tie(p, y) = pi;
    aux[p].push_back(y);
  }

  std::map<int, std::map<int, int>> ord;
  for (auto& p: aux) {
    std::sort(p.second.begin(), p.second.end());
    for (size_t i = 0; i < p.second.size(); ++i)
      ord[p.first][p.second[i]] = i+1;
  }

  for (auto& pi: PY) {
    int p, y;
    std::tie(p, y) = pi;
    printf("%06d%06d\n", p, ord[p][y]);
  }
}

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

int main() {
	int n;
	cin >> n;
	vector<int> w(n);
	for (int i = 0; i < n; i++) {
		cin >> w.at(i);
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += w.at(i);
	}
	int tmpa = 0;
	int tmpb = 0;
	int ans = 100;
	for (int i = 0; i < n; i++) {
		tmpa += w.at(i);
		tmpb = sum - tmpa;
		ans = min(ans,abs(tmpa - tmpb));
		
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int num, i, a, w = false;;
	cin >> num;
	for (i = 0; i < num; i++) {
		scanf("%d", &a);
		if (a & 1) {
			w = true;
			break;
		}
	}
	if (w)
		printf("first\n");
	else
		printf("second\n");
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());
        String s = stdin.readLine();

        Map<Character, Long> d = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            d.put(c, d.getOrDefault(c, 0L) + 1);
        }

        long ans = 1;
        for (long v : d.values()) {
            ans *= v + 1;
            ans %= 1000000000 + 7;
        }
        stdout.println(ans - 1);
    }


    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


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

int main(){
  int x,kekka;
  cin >> x;
  int now = 0;
  for(int i = 1;i > 0;i++){
    now += i;
    if(now >= x){
      kekka = i;
      break;
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int r;
    cin >> r;
    cout << (3 * r * r) << endl;
}

Measured memory_bytes: 256