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

std::vector<bool> make_prime_checklist(int n) {
  std::vector<bool> list(n + 1, true);
  list[0] = list[1] = false;
  for (int i = 4; i <= n; i += 2) list[i] = false;
  int bdr = std::sqrt(n);
  for (int i = 3; i <= bdr; i += 2)
    if (list[i])
      for (int j = 2 * i; j <= n; j += i) list[j] = false;
  return list;
}

int main() {
  int n;
  std::cin >> n;

  auto check = make_prime_checklist(55555);
  int k = 2;
  for (int i = 0; i < n; i++) {
    while (!check[k] || k % 5 != 1) {
      k++;
    }
    std::cout << k << " ";
    k++;
  }
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 256
from collections import Counter


def main():
    n = int(input())
    As = list(map(int, input().split()))
    ans = 0
    for num, count in Counter(As).items():
        if count >= num:
            ans += (count - num)
        else:
            ans += count
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n,a,b=1e9+1,f=0;
  ll sum=0;
  cin >> n;
  rep(i,n){
    cin>>a;
    f+=a<0;
    b=min(b,abs(a));
    sum+=abs(a);
  }
  if(f&1)
    cout<<sum-b*2;
  else
    cout<<sum;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] log2 = new int[K+1];
        log2[0] = 0;
        log2[1] = 1;
        int pow2 = 2;
        for (int i = 2; i <=K; i++) {
            if(i <= pow2) log2[i] = log2[i-1];
            else if(pow2 < i){
                log2[i] = log2[i-1] + 1;
                pow2 *= 2;
            }
        }
        // for (int i = 0; i < K+1; i++) {
        //     System.out.println(log2[i]);
        // }
        double ans = 0;
        for (int i = 1; i <= N; i++) {
            double prob = 1.0/N;
            int score = i;
            while(score<K){
                score = score * 2;
                prob = prob * 0.5;
            }
            ans += prob;
        }
        System.out.println(ans);
    }
}

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

int n;
int as[114514];

bool check(int t) {
  if (t < 10) return true;
  
  int prev = t%10;
  t /= 10;
  while (t > 0) {
    int x = t%10;
    if (x != prev-1) return false;
    t /= 10;
    prev = x;
  }

  return true;
}

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

  int ans = -1;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      int t = as[i]*as[j];
      if (check(t)) ans = max(ans, t);
    }
  }

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

Measured memory_bytes: 3228
n=int(input())
a=list(map(int, input().split()))
x=a[0]
y=sum(a)-a[0]
ans=abs(y-x)
for i in range(1,n-1):
    x+=a[i]
    y-=a[i]
    if ans>abs(x-y):
        ans=abs(x-y)
print(ans)


Measured memory_bytes: 78672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
 
using std::cin;
using std::cout;
using std::endl;
 
int main(void) {
    int n;
 
    while (1) {
        cin>>n;
        if(n==0)break;
        char c;
        int count_p = 0;
        bool d = false;
        std::vector< std::pair<int,char> > data(26);
        std::vector<int> hash(26);
 
        for (int i = 0; i < 26; i++) {
            data[i].first = 0;
            data[i].second = 'A' + i;
        }
 
        for (int i = 0; i < n; i++) {
            cin >> c;
            for (int j = 0; j < 26; j++) {
                if (c == data[j].second) {
                    data[j].first++;
                }
            }
 
            std::sort(data.begin(), data.end());
 
            if ( data[25].first > data[25-1].first + (n-i-1) ) {
                if (!d) {
                    cout << data[25].second << " " << i+1 << endl;
                    d = true;
                }
            }
        }
 
        if (data[25].first == data[25-1].first) {
            cout << "TIE" << endl;
        }
        else {
            if (!d) {
                cout << data[25].second << " " << n << endl;
            }
        }
 
    }
 
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  if(N == 1 || N == 2 || N == 3 || N == 5 || N == 6 || N == 9 || N == 10 || N == 13 || N == 17) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

void q_sort(int numbers[], int left, int right){
    int pivot, l_hold, r_hold;

    l_hold = left;
    r_hold = right;
    pivot = numbers[left];
    while (left < right)
    {
        while ((numbers[right] >= pivot) && (left < right))
            right--;
        if (left != right)
        {
            numbers[left] = numbers[right];
            left++;
        }
        while ((numbers[left] <= pivot) && (left < right))
            left++;
        if (left != right)
        {
            numbers[right] = numbers[left];
            right--;
        }
    }
    numbers[left] = pivot;
    pivot = left;
    left = l_hold;
    right = r_hold;
    if (left < pivot)
        q_sort(numbers, left, pivot-1);
    if (right > pivot)
        q_sort(numbers, pivot+1, right);
}

int main(){
    int n,num[100]={0},i,sum;

    while(scanf("%d",&n),n){
        sum=0;
        for(i=0;i<n;i++){
            scanf("%d",&num[i]);
        }
        q_sort(num,0,n-1);
        for(i=1;i<n-1;i++)sum+=num[i];
        printf("%d\n",sum/(n-2));
    }
    return 0;
}

Measured memory_bytes: 600
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto n = readInt();
		if(n == 0) return;
		int[][] p;
		for(int i; i < n; ++i) {
			p ~= readInts()[1..$].sort;
		}
		auto l = readInts()[1..$].sort;
		auto suspect = zip(iota(1, n+1), p).filter!(a => equal(l, setIntersection(a[1],l))).array;
		if(suspect.length != 1) {
			writeln(-1);
		} else {
			writeln(suspect[0][0]);
		}
	}
}

Measured memory_bytes: 3564
def main():
    N = int(input())
    A = list(map(int, input().split()))

    reslt = {}
    re = []

    for i, num in enumerate(A):
        reslt[num] = i + 1

    for k, v in sorted(reslt.items()):
        re.append(v)

    print(*re)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c);
    CoutYn((a < c && c < b) || (b < c && c < a));
}





Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Dijkstra O(NlogM)*/

template <typename Type = int>
struct Dijkstra{
  int V;
  vector<vector<pair<int,Type>>> G;
  vector<Type> cost;

  Dijkstra(int n):
    V(n), G(n, vector<pair<int,Type>>()) {}

  void add_edge(int u, int v, Type c){
    G[u].push_back({v, c});
  }

  Type solve(int s, int g = -1){
    cost.assign(V, -1);
    priority_queue<pair<Type,int>> pq;
    Type max_cost = 0;

    pq.push({0, s});

    while(pq.size()){
      Type now_cost = pq.top().first;
      int now = pq.top().second;
      pq.pop();

      if(cost[now] >= 0) continue;

      cost[now] = -now_cost;
      max_cost = max(max_cost, -now_cost);

      if(now == g) return -now_cost;

      for(int i=0; i<(int)G[now].size(); i++)
        pq.push({now_cost - G[now][i].second, G[now][i].first});
    }

    return max_cost;
  }
};

int N, M, K;
ll J[SIZE], P[SIZE], c[SIZE];
vector<pair<int,int>> G[SIZE];

int main(){

  scanf("%d%d%d", &N, &M, &K);

  for (int i=0; i<N; i++) scanf("%lld", P+i);
  for (int i=0; i<N; i++) scanf("%lld", c+i);
  for (int i=0; i<N; i++) scanf("%lld", J+i);

  Dijkstra<ll> dijk(N);

  for (int i=0; i<M; i++) {
    int u, v, t;
    scanf("%d%d%d", &u, &v, &t);
    u--; v--;
    G[u].push_back({v, t});
    G[v].push_back({u, t});
    dijk.add_edge(u, v, t);
    dijk.add_edge(v, u, t);
  }

  dijk.solve(0);

  priority_queue<pair<ll,int>> pq;

  for (int i=0; i<N; i++) {
    J[i] -= dijk.cost[i];
    P[i] -= dijk.cost[i];
    pq.push({P[i], i});
  }

  bool visited[SIZE] = {};
  ll T[SIZE];
  while(pq.size()) {
    auto p = pq.top();
    pq.pop();

    int now = p.second;
    ll cost = p.first;

    if (visited[now]) continue;
    visited[now] = true;

    T[now] = cost;

    for (auto q : G[now]) {
      if (!visited[q.first]) {
        pq.push({cost - q.second, q.first});
      }
    }
  }

  ll ans[SIZE];

  for (int i=0; i<K; i++)
    ans[i] = -LLINF;

  for (int i=0; i<N; i++) {
    ans[c[i]-1] = max(ans[c[i]-1], J[i] + T[i]);
  }

  for (int i=0; i<K; i++) {
    printf("%lld\n", ans[i]);
  }

  return 0;
}



Measured memory_bytes: 36820
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


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


#define all(c) c.begin(), c.end()


typedef int64_t i64;


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


namespace hash_util_detail {
    template<class T>
    inline void hash_combine(size_t &seed, T const &v) {
        static std::hash<T> h;
        seed ^= h(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    }

    
}

namespace std {
    

    template<class U, class V>
    struct hash<pair<U, V>> {
        std::size_t operator()(pair<U, V> const& p) const {
            size_t seed = 0;
            hash_util_detail::hash_combine(seed, p.first);
            hash_util_detail::hash_combine(seed, p.second);
            return seed;
        }
    };

    
}

void solve(istream& in, ostream& out) {
  auto h = next<i64>(in);
  auto w = next<i64>(in);
  auto n = next<int>(in);
  i64 totalSquares = (w - 2) * (h - 2);

  unordered_map<pair<int, int>, int> cnts;

  FOR(i, n) {
    auto x = next<int>(in) - 1;
    auto y = next<int>(in) - 1;
    for (int tx = x - 2; tx <= x; ++tx) {
      for (int ty = y - 2; ty <= y; ++ty) {
        if (tx >= 0 && ty >= 0 && tx + 2 < h && ty + 2 < w) {
          cnts[{tx, ty}]++;
        }
      }
    }
  }

  vec<i64> counts(10, 0);
  for (auto cs : cnts) {
    counts[cs.second]++;
  }
  totalSquares -= accumulate(all(counts), 0);
  counts[0] = totalSquares;
  FOR(i, 10) {
    out << counts[i] << "\n";
  }
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



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

using namespace std;
using ll = long long;

const int N = 1e6 + 5, M = 1e9 + 7;

void solve() {            
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n / x + (n % x != 0)) * t;    
}

main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>
#define INPUT_FROM_FILE (0)

#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv) {
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;
	int max_v = INT_MIN;
	int min_v = INT_MAX;


#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

#if INPUT_FROM_FILE
	ifs >> min_v;
#else
	std::cin >> min_v;
#endif

	for(int i = 1; i < n; i++){
		int num = 0;
#if INPUT_FROM_FILE
		ifs >> num;
#else
		std::cin >> num;
#endif
		max_v = std::max(max_v, num - min_v);
		min_v = std::min(min_v, num);
	}

	std::cout << max_v << std::endl;
	return 0;
}

Measured memory_bytes: 3096
A, B, C, D, E, F = map(int, input().split())
Con = 0
a, b = 0, 0
for i in range(F//100 + 1):
    for j in range(F//100 + 1):
        Water = 100 * A * i + 100 * B * j
        if Water > F:
            break
        for x in range(E * Water // 100 + 1):
            for y in range(E * Water // 100 + 1):
                Sugar = C * x + D * y
                if Water + Sugar > F:
                    break
                if Water * E < Sugar * 100:
                    break
                if Sugar + Water == 0:
                    break
                c = (100 * Sugar) / (Sugar + Water)
                if Con <= c:
                    Con = c
                    a = Water
                    b = Sugar
print(a + b, b)

Measured memory_bytes: 73764
import java.io.*;
import java.math.*;
import java.util.*;


public class Main{
    static long MOD = 998244353L;
    static long [] fac;
    static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    static long lMax = 0x3f3f3f3f3f3f3f3fL;
    static int iMax = 0x3f3f3f3f;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int k = sc.nextInt();
            String s = sc.nextLine();
            int len = s.length();
            if(len <= k)
                out.println(s);
            else out.println(s.substring(0, k) + "...");
        }
        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long gcd(long a, long b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


int main(void){
	string n;
	while(cin >> n){
		if(n[0]=='-') break;
		int i=0,cnt=0,flag=false;
		rep(j,n.size()){
			if(n[j]=='.'){
				cnt=0,flag=true;
			}else{
				i=10*i+n[j]-'0';
				cnt++;
			}
		}
		if(flag==false) cnt=0;
		bool ok=true;
		rep(j,cnt){
			if(i%5) ok=false;
			i/=5;
		}
		rep(j,4-cnt) i*=2;
		if(i>=4096) ok=false;
		if(ok){
			for(int j=11;j>=4;--j){
				cout << ((i&(1<<j))>0);
			}
			putchar('.');
			for(int j=3;j>=0;--j){
				cout << ((i&(1<<j))>0);
			}
			puts("");
		}else{
			puts("NA");
		}
	}
	return 0;
}

Measured memory_bytes: 3076
# coding: utf-8
moji = list(input())
n = len(moji)
kaunto = 0
risuto = []
for i in range(n):
    if (moji[i] == "A") or (moji[i] == "G") or (moji[i] == "C") or (moji[i] == "T"):
        risuto.append("X")
    else:
        risuto.append(" ")

s = 0
kotae = []
for i in risuto:
    if i == "X":
        s += 1
        kotae.append(s)
    else:
        s = 0
if kotae != []:
    print(int(max(kotae)))
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,m,x,y,dp[N],ans;
vector<int> v[N];
bool notroot[N];
int dfs(int x)
{
	if(dp[x]!=-1)
		return dp[x];
	if(v[x].empty())
	{
		dp[x]=0;
		return 0;
	}
	int res=-666666;
	for(int i=0;i<v[x].size();i++)
		res=max(res,dfs(v[x][i])+1);
	dp[x]=res;
	return res;
}
int main(){
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
		notroot[y]=true;
	}
	for(int i=1;i<=n;i++)
		if(!notroot[i])
			ans=max(ans,dfs(i));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10880
function Main(input) {
 
    in_array = input.split("");
    let j = 0;
    
    if (in_array[0] === 'R' && in_array[1] === 'S' && in_array[2] === 'R') {
        j = 1;
    } else {
        for(let i=0 ; i<3 ; i++) {
            if(in_array[i] === 'R')  j++;
        }
    }
 
    console.log('%d', j);
    
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29512
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{
	string s;
	cin >> s;

	if (s[2] == s[3] && s[4] == s[5])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  string S, T;
  cin >> S >> T;
  string ans;
  if (S.size() + 1 != T.size()) {
    cout << "No" << endl;
    return 0;
  }
  
  for (int i = 0; i < (int)S.size(); ++i) {
    if (S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    }	
  }
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 3008
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

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

int main()
{
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    ll ad = v * t;
    ll bd = w * t;

    ll al = a - ad;
    ll ar = a + ad;
    ll bl = b - bd;
    ll br = b + bd;

    string ans;
    if (al <= bl && ar >= br) 
    {
        ans = "YES";
    }
    else
    {
        ans = "NO";
    }

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

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

using namespace std;

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


int main(){
 long n,m;
   cin >> n >> m;
  
  vector<pair<long,long>> p(n);
  
 rep(i,n){
  long a,b;
   cin >> a >> b;
   p[i]=make_pair(a,b);
 }
  
  sort(p.begin(),p.end(),greater<pair<long,long>>());
  
  long res=0;
  priority_queue<long> pque;
  int num=n-1;
  for(int i=1;i<=m;i++){
   while(p[num].first<=i&&num>=0) {
     pque.push(p[num].second);  
     num--;
   }
   if(!pque.empty()) {
     res+=pque.top();
    pque.pop();
   }
   }
 
  cout << res << endl;
 
  }

Measured memory_bytes: 2936
n,m = map(int, input().split())
s = input()
now = 0
MIN = 0
ans = []
while now < n:
  for i in range(min(n-now,m),0,-1):
    nex = now + i
    if s[nex] == "0":
      now = nex
      MIN += 1
      break
  else:
    print(-1)
    exit()
now = 0
while now < n:
  for i in range(min(n-now,m),0,-1):
    nex = now + i
    if s[n-nex] == "0":
      now = nex
      ans.append(i)
      break
print(*reversed(ans))

Measured memory_bytes: 6384
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int[N];
		int[] t = new int[N];
		int p = 1100;
		for(int i = 0; i < N; i++){
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++){
			if(t[i] <= T){
				if(c[i] < p){
					p = c[i];
				}
			}
		}
		if(p == 1100){
			System.out.println("TLE");
		}else{
			System.out.println(p);
		}
	}
}

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

int main() {
  char c;
  cin >> c;
  
  if ((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u'))
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()
#define ld long double
void solve();
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}
void solve()
{
	ll n; cin >> n;
	ll arr[n]; for (auto &x : arr) cin >> x;
	ll res = 0;
	ll high = arr[0];
	for (int i = 1; i < n; ++i)
	{
		if (arr[i] < high ) res += (high - arr[i]);
		else
		{
			high = max(high , arr[i]);
		}
	}
	cout << res;
	cout << "\n";
	return ;
}


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

int main(){
    int N,K; cin >> N >> K;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    bool dp[K+1]={};
    //dp[0]=false;
    for(int i=1;i<=K;i++){
        //dp[i]=false;
        for(int j=0;j<N;j++){
            if(i-a[j]<0) continue;
            dp[i] |= !dp[i-a[j]]; //1が立ったらかき消されることはない(論理和)
        }
    }
    //for(int i=0;i<=K;i++){
        //cout << dp[i] << endl;
    //}
    if(dp[K]==1){
        cout << "First" << endl;;
    }else{
        cout << "Second" << endl;
    }

}

Measured memory_bytes: 384
#include <cstdio>
using namespace std;
#define ll long long
ll a,b,k;
int main(){
	scanf("%lld%lld%lld",&a,&b,&k);
	if (a+b<=k){
		puts("0 0");
	}
	else{
		if (a<=k){
			printf("0 %lld\n",b-(k-a));
		}
		else{
			printf("%lld %lld\n",a-k,b);
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    int maxx = *max_element(ALL(a));
    int minn = *min_element(ALL(b));
    int ans = 0;
    vector<pair<int, int>> p(n);
    REP(i, n)
    p[i] = {minn - a[i] + 1, b[i] - maxx + 1};
    sort(ALL(p));
    int t = INT_MAX;
    REP(i, n - 1) {
        t = min(t, p[i].second);
        ans = max(ans, p[i + 1].first + t);
    }
    t = max(0, minn - maxx + 1);
    REP(i, n) {
        int cur = b[i] - a[i] + t + 1;
        ans = max(ans, cur);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




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

    int N;
    cin>>N;
    vector<ll> V(N);
    ll sum=0;
    for(int i=0;i<N;i++) cin>>V[i],sum+=V[i];

    ll S=(ll)N*(N+1)/2;
    if(sum%S!=0){
        cout<<"NO"<<endl;
        return 0;
    }
    ll num=sum/S;

    ll count=0;
    for(int i=1;i<=N;i++){
        ll x=V[i%N]-V[i-1];
        if(x==num) continue;
        if((num-x)%N!=0 || num<x){
            cout<<"NO"<<endl;
            return 0;
        }
        count+=(num-x)/N;
    }
    if(count==num) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;


}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
vi in;
double m;
double h;
bool check(){
	double L=m;
	double out[2];
	rep(q,2){
		loop(i,0,86400){
			L+=h-in[i];
			if(L<=0)return false;
			if(L>m)L=m;
		}
		out[q]=L;
	}
	if(abs(out[0]-out[1])<EPS)return true;
	return false;
}
int main(){
	int n;
	while(cin>>n>>m,n+m){
		in=vi(86401);
		while(n--){
			int a,b,c;
			cin>>a>>b>>c;
			b--;
			loop(i,a,b+1)in[i]=c;
		}
		double r=0,l=1e9;
		while(l-r>EPS){
			h=(r+l)/2;
			if(check())l=h;
			else r=h;
//			cout<<shosu(9)<<l<<" "<<r<<endl;
		}
		cout<<shosu(9)<<l<<endl;
//		cout<<endl;
	}
}

Measured memory_bytes: 1796
#include <iostream>
#include <vector>

int main() {
  int n, k;
  std::cin >> n >> k;
  int max = (n - 2) * (n - 1) / 2;  // 蜘蛛っぽい形の時
  std::vector<std::pair<int, int>> result;
  if (max >= k) {
    // まずはmaxを作る
    for (size_t i = 1; i < n; ++i) {
      result.push_back(std::make_pair(1, i + 1));
    }

    int i = 2;
    int e = max - k;
    while (e > 0) {
      for (size_t j = 1; i + j <= n; ++j) {
        result.push_back(std::make_pair(i, i + j));
        if (--e <= 0) {
          break;
        }
      }
      ++i;
    }
  }

  if (result.size() == 0) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << result.size() << std::endl;
    for (auto &p : result) {
      std::cout << p.first << " " << p.second << std::endl;
    }
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int A,B;
    cin >> A >>B;
    int H = 100;
    int W = 100;
    bool isW[H][W];
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            if(yi < 50){
                isW[yi][xi] = false;
            }else{
                isW[yi][xi] = true;
            }
        }
    }
    int countA = 1;
    int countB = 1;
    for(int yi = 0; yi < H / 2; yi++){
        for(int xi = 0; xi < W; xi++){
            if(yi % 2 == 0 && xi % 2 == 0){
                if(countA == A){
                    continue;
                }
                isW[yi][xi] = true;
                countA++;

            }
        }
    }
    for(int yi = H - 1; yi >= H / 2; yi--){
        for(int xi = 0; xi < W; xi++){
            if((yi - (H - 1)) % 2 == 0 && (xi - (W - 1)) % 2 == 0){
                if(countB == B){
                    continue;
                }
                isW[yi][xi] = false;
                countB++;

            }
        }
    }
    cout << H << " " << W << endl;
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            if(isW[yi][xi]){
                cout << ".";
            }else{
                cout << "#";
            }
        }
        cout << endl;
    }

}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<LL> a(n);
    inc(i, 0, n) cin >> a[i];
    LL ans = LLONG_MAX;
    inc(k, 0, 2){
        LL sum = 0;
        LL cnt = 0;
        inc(i, 0, n){
            sum += a[i];
            if(sum <= 0 && k == i%2){
                cnt += 1-sum;
                sum = 1;
            }else if(sum >= 0 && k != i%2){
                cnt += sum+1;
                sum = -1;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
//20200815B
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] L=new int[n];
		for(int i=0;i<n;i++){
			L[i]=sc.nextInt();
		}
		int ans=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				for(int k=j+1;k<n;k++){
					if((L[i]<L[j]+L[k])&& (L[k]<L[i]+L[j])&& (L[j]<L[k]+L[i])){
                      	ans++;
                      	if((L[i]==L[j])||(L[j]==L[k])||(L[k]==L[i])){
                        	ans--;
                          	
                        }else{
                         
                   
                      		//System.out.println(L[i]);
                      		//System.out.println(L[j]);
                      		//System.out.println(L[k]);
                        }
					}
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36588
using System;
using System.Linq;
using System.Collections.Generic;

class AtCode {
  static void Main() {
    var S = Console.ReadLine().Trim();
    string answer;
    if(S == "Sunny") {
      answer = "Cloudy";
    } else if(S == "Cloudy") {
      answer = "Rainy";
    } else {
      answer = "Sunny";
    }
    Console.WriteLine(answer);
  }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  char c;
  for (int i = 0; i < a; ++i) {
    cin >> c;
    if ('0' <= c && c <= '9') continue;
    puts("No");
    return 0;
  }
  cin >> c;
  if (c != '-') {
    puts("No");
    return 0;
  }
  for (int i = 0; i < b; ++i) {
    cin >> c;
    if ('0' <= c && c <= '9') continue;
    puts("No");
    return 0;
  }
  puts("Yes");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

const Int inf = numeric_limits<Int>::max() / 2;


template<class T = Int>
struct Edge {
	Int to;
	T cost;
	Edge() {}
	Edge(Int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge& r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(vector<vector<Edge<T>>>& edges, Int st) {

	Int V = (Int)edges.size();
	//const T inf = numeric_limits<T>::max() / 2;
	vector<T> cost(V, inf);
	cost[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;//要素の型はEdge<T>、内部コンテナはvector<Edge>>、昇順
	p_que.emplace(st, cost[st]);

	while (!p_que.empty()) {

		Edge<T> now(p_que.top().to, p_que.top().cost);//now.to: 配る側になった頂点 now.cost: その頂点の最小コスト
		p_que.pop();

		//↓この一行、有向グラフ（行きと帰りで辺の重みが違う場合）で威力を発揮、オーダーレベルで計算量が異なることも
		//後からキューに入れたものが追い越した場合、追い越されたものはオワコンになる
		if (cost[now.to] < now.cost) continue;


		for (const Edge<T>& e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				p_que.emplace(e.to, cost[e.to]);
			}
		}
	}

	return cost; // min cost to vertex idx from st
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M;
	cin >> N >> M;

	vector<vector<Edge<Int>>> Graph(N);

	Int L, R, C;
	for (Int i = 0; i < M; i++) {
		cin >> L >> R >> C;
		L--;
		R--;

		Graph[L].emplace_back(R, C);
		//Graph[R].emplace_back(L, C);
	}

	for (Int i = 0; i < N-1; i++) {
		Graph[i + 1].emplace_back(i, 0LL);
	}

	vector<Int> temp = Dijkstra(Graph, 0);
	
	if (temp[N - 1] == inf) {
		cout << -1 << "\n";
	}
	else {
		cout << temp[N - 1] << "\n";
	}
}


Measured memory_bytes: 9336
import java.util.Scanner;

fun main (args: Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    var varCount = 5
    
    while (varCount-- > 0) {
      if (input.nextInt() == 0) {
        println(5 - varCount)
      }
    }
  }
}

Measured memory_bytes: 36164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	char a;
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <math.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define str string
#define deb_arr(arr,n) for(ll i=0;i<(n);i++){ cout << (arr)[i] << " ";}
#define in_arr0(arr,n) for(ll i=0;i<(n);i++){ cin >> (arr)[i]; }
#define in_arr1(arr,n) for(ll i=1;i<=(n);i++){ cin >> (arr)[i];}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define vll vector<ll> 
#define fr(n) for(i=0;i<(n);i++)
#define fr1(n) for(i=1;i<=(n);i++)
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI M_PI
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=1e9+7;
inline ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
inline ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}

const int mxn=1e5+10;


void init(){

    return ;
}


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    init();
    ll i,j;
    ll n,k;
    cin >> n >> k;
    map<ll,ll> mp;
    ll d,a;
    for(i=0;i<k;i++){
        cin >> d;
        while(d--){
            cin >> a;
            mp[a]++;
        }
    }
    ll ans=0;
    for(i=1;i<=n;i++){
        if(mp[i]==0){
            ans++;
        }
    }
    cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

ll mod_conv(ll n,ll r,ll mod)
{
    ll nume = 1;
    ll deno = 1;

    FOR(i,0,r){
        nume = (nume  * (n - i)) % mod;
        deno = (deno * (1 + i)) % mod;
    }

    return (nume * modinv(deno,mod))%mod;
}

int main(void)
{
    ll n;
    ll mod = 1e9 + 7;
    cin >> n;
    ll all = RepeatSquaring(2, n, mod) - 1;
    ll a, b;
    cin >> a >> b;

    ll ans = all - mod_conv(n, a,mod);
    ans = (ans < 0) ? ans + mod : ans;

    ans = ans - mod_conv(n, b, mod);
    ans = (ans < 0) ? ans + mod : ans;
    

    if(n <= 2){
        cout << '0' << endl;
    }
    else{
        cout << ans  % mod<< endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??????acm?????????
		int a = sc.nextInt();
		//??????bcm?????????
		int b = sc.nextInt();

		//??¢????????????????¨????
		int Area = a *  b;
		//??¨?????????????¨????
		int Circuit = a * 2 + b * 2;

		//???????????¨???
		System.out.println(Area +" "+ Circuit);
	}
}

Measured memory_bytes: 26148
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

#define MOD ((lli)1000000007)


lli ta[505][505]={};

lli mop(lli p,lli q){
	lli res=1,bp=p,b=1;
	while(q){
		if(q&b){
			res=(res*bp)%MOD;
			q-=b;
		}
		bp=(bp*bp)%MOD;
		b*=2;
	}
	return res;
}

lli inv(lli p){
	return mop(p,MOD-2);
}

void init(){

	rep(p,500){
		reg(q,1,500){
			ta[p][q] = (ta[p][q-1] + mop(q,p))%MOD;
		}
	}
	/*
	rep(p,10){
		reg(q,1,9){
			printf("ta[%d][%d]  %lld\n",p,q,ta[p][q]);
		}
	}
	*/
}


lli dp[505][505]={};
int n,c;
int da[405]={},db[405]={};

int main(void){
	init();
	scanf("%d%d",&n,&c);
	reg(i,1,n)scanf("%d",&da[i]);
	reg(i,1,n)scanf("%d",&db[i]);
	
	dp[0][0]=1;
	reg(i,1,n){
		reg(j,0,c){
			lli s=0;
			reg(k,0,j){
				lli ad = (dp[i-1][j-k] * ((ta[k][db[i]] - ta[k][da[i]-1] + MOD)%MOD))%MOD;
				//printf("%d %d %d ,%lld\n",i,j,k,ad);
				s = (s + ad)%MOD;
			}
			dp[i][j]=s;
		}
	}
	
	printf("%lld\n",dp[n][c]);
	
	return 0;
}






Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		int []p = new int [n];
		
		for(int i = 0 ; i < k; i++) {
			int d = Integer.parseInt(sc.next());
			for(int j = 0 ; j < d ;j++) {
				int a = Integer.parseInt(sc.next())-1;
				p[a]++;
			}
		}
		
		int cnt = 0;
		for(int i = 0 ; i < n ;i++) {
			if(p[i] == 0) {
				cnt++;
			}
		}
		System.out.println(cnt);
				
	}

}


Measured memory_bytes: 41736
n = gets.chomp.to_i
s = []
t = []
for i in 0..(n-1)
    s[i],t[i] = gets.split(" ")
end
t = t.map!(&:to_i)
x = gets.chomp
cnt = s.index(x)
lesult = t.slice((cnt+1)..(-1)).inject(:+)
if lesult == nil
    puts 0
else 
    puts lesult
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int n=s.size();
   int t=0;
   for(int i=0;i<n;i++)
   {
       if(s[i]!=s[n-i-1])
       {
           t=1;
       }
   }
   if(t==1)
   {
       cout<<"No"<<endl;
       return 0;
   }
   int t1=0;
   for(int i=0;i<(n-1)/2;i++)
    {
        if(s[i]!=s[(n-1)/2-i-1])
        {
            t1=1;
        }
    }
    int t2=0;
    //cout<<(n+3)/2<<endl;
    for(int i=((n+3)/2-1);i<n;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            t2=1;
        }
    }
    if(t==0 && t1==0 && t2==0)
    {
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
int n, a[N], cnt[2], pcnt[N], mrk[2][N];
void init(void){
    for (int i = 1; i < N; ++i){
        for (int j = i; j >= 1; j -= j&(-j)) pcnt[i]++;
    }
}
int main(void){
    IOS;
    init();
    cin >> n;
    string s; cin >> s;
    for (int i = 0; i < s.size(); ++i){
        a[n-i-1] = s[i]-'0';
        cnt[a[n-i-1]]++;
    }
    int mod1 = cnt[1]+1, mod2 = cnt[1]-1, ans1 = 0, ans2 = 0;
    for (int i = n-1; i >= 0; --i){
        ans1 = (ans1*2+a[i])%mod1;
    }
    for (int i = mrk[0][0] = 1; i < n; ++i) mrk[0][i] = mrk[0][i-1]*2%mod1;
    if (cnt[1] > 1){
        for (int i = n-1; i >= 0; --i){
            ans2 = (ans2*2+a[i])%mod2;
        }
        for (int i = mrk[1][0] = 1; i < n; ++i) mrk[1][i] = mrk[1][i-1]*2%mod2;
    }
    for (int i = n-1; i >= 0; --i){
        int ans;
        if (a[i] == 0){
            ans = (ans1+mrk[0][i])%mod1;
        }else{
            if (mod2 == 0){
                cout << 0 << endl; continue;
            }
            if (mod2) ans = ((ans2-mrk[1][i])%mod2+mod2)%mod2;
            else ans = 0;
        }
        if (!ans){
            cout << 1 << endl;
        }else{
            int tot = 1;
            while (ans){
                ans = ans%pcnt[ans];
                tot++;
            }
            cout << tot << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6892