akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 20 21:40:30 2018
ABC065D
@author: maezawa
i=0...n (0-origin)
"""
import heapq
import sys
input = sys.stdin.readline

n = int(input())
a = [[] for _ in range(n)]
b = [[] for _ in range(n)]
for i in range(n): # i is a name of the city (0-origin)
    xy = list(map(int, input().split()))
    a[i]=[xy[0],i]
    b[i]=[xy[1],i]

a.sort()
b.sort()
#print(a) 
#print(b)

# making adj list
adj = [[] for _ in range(n)]
for [x0, j0], [x1, j1]  in zip(a, a[1:]):
    adj[j0].append([x1-x0, j1])
    adj[j1].append([x1-x0, j0])
for [y0, j0], [y1, j1] in zip(b, b[1:]):
    adj[j0].append([y1-y0, j1])
    adj[j1].append([y1-y0, j0])

#print(adj)
    
# Prim's algorithm
#d = [10**10]*n
visited = [False]*n
h = []
s = 0
heapq.heappush(h, [0, s])
cnt = 0
totalcost = 0 
while h:
    cost, node = heapq.heappop(h)
    #if visited[node] != True and cost < d[node]:
    if visited[node] != True:        
        #d[node] = cost
        visited[node] = True
        totalcost += cost
        cnt += 1
        if cnt == n:
            break
        for edge in adj[node]:
            if visited[edge[1]]:
                continue
            heapq.heappush(h, edge)
            
#print(d)
print(totalcost)
        


Measured memory_bytes: 98920
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();  // input Integer
    int b = sc.nextInt();  // input Integer
    int c = sc.nextInt();  // input Integer
    int max = Math.max(a,b);
    max = Math.max(max,c);
    System.out.println(a+b+c-max);
//    String a = sc.next();  // input String
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n + 1),b(n);
    for(ll i = 0;i < n + 1; i++){
        cin >> a[i];
    }
    for(ll i = 0;i < n; i++){
        cin >> b[i];
    }
    ll ans = 0;
    for(ll i = 0;i < n; i++){
        ll sum = a[i] + a[i + 1];
        if(sum < b[i]){
            a[i] = 0;
            a[i + 1] = 0;
            ans += sum;
        }else{
            ans += b[i];
            if(a[i] - b[i] < 0) {
                b[i] = b[i] - a[i];
                a[i] = 0;
            }else{
                a[i] = a[i] - b[i];
                b[i] = 0;
            }
            a[i + 1] = a[i + 1] - b[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    double a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    double dens_tmp, dens = 0, dens_max = e/100;

    int w, s, w_ans, s_ans;

    for (int i = 0; 100*a*i <= f; i++) {
        for (int j = 0; 100*(a*i+b*j) <= f; j++) {
            w = 100*a*i + 100*b*j;
            if (w == 0) continue;
            for (int k = 0; k*c <= f - w; k++) {
                for (int l = 0; k*c+l*d <= f - w; l++) {
                    s = c*k + d*l;

                    dens_tmp = (double) s/w;

                    if (dens_max >= dens_tmp && f >= s+w && dens_tmp >= dens ) {

                        dens = dens_tmp;

                        w_ans = w;
                        s_ans = s;
                        
                    } 

                }
            }
            
        }
    }
    cout << s_ans+w_ans << " " << s_ans << endl;

}

Measured memory_bytes: 256
# 1_1_A_InsertionSort.py

n = int(input())
a = [int(x) for x in input().split()]

print(' '.join([str(x) for x in a]))
for i in range(1, len(a)):
    for j in range(i, 0, -1):
        if a[j] < a[j-1]:
            a[j], a[j-1] = a[j-1], a[j]
    print(' '.join([str(x) for x in a]))



Measured memory_bytes: 5608
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;



   public class Main
    {
  public static void main(String[] args) {
       
       Scanner sc = new Scanner(System.in);
       
       String str = sc.next();
       int rain = 0;
       char ch;
       
       if(str.equals("RRR")) 
        System.out.println(3);
        
        else if(str.equals("RSS") || str.equals("RSR") || str.equals("SRS") || str.equals("SSR"))
        System.out.println(1);
        
        else if(str.equals("RRS") || str.equals("SRR"))
        System.out.println(2);
       
       else
       System.out.println(0);
       
    }
    }

Measured memory_bytes: 27032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll modinv(ll a, ll m=mod) {
  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;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> X(n); rep(i, n) cin >> X[i];
  ll fact = 1;
  rep(i, n-1) (fact *= i+1) %= mod;
  vector<ll> inv(n);
  inv[0] = fact;
  rep(i, n) if(i) inv[i] = (inv[i-1] + fact*modinv(i+1)%mod) % mod;
  ll ans = 0;
  rep(i, n-1) (ans += (X[i+1]-X[i]) * inv[i]) %= mod;
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;
}int n,m,f[1000000],x,y;
struct lsg{int x,y;}a[1000000];
int pd(lsg x,lsg y){return x.y<y.y;}
int main(){
	n=read();m=read();memset(f,10,sizeof(f));f[1]=0;
	for (int i=1;i<=m;i++){
		x=read();y=read();
		a[i].x=x;a[i].y=y;
	}sort(a+1,a+1+m,pd);
	for (int i=1;i<=m;i++)f[a[i].y]=min(f[a[i].x]+1,f[a[i].y]);
	if (f[n]<=2)puts("POSSIBLE");else puts("IMPOSSIBLE");
}


Measured memory_bytes: 7424
MODE = "stdio"
require 'matrix'
include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '1 2 4 8 16 32
  EESWN'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
class Dice
  attr_accessor :top, :front, :right, :left, :back, :bottom
  def initialize(arr)
    @top = arr[0]
    @front = arr[1]
    @right = arr[2]
    @left = arr[3]
    @back = arr[4]
    @bottom = arr[5]
  end

  def roll(s)
    case s
    when "E"
      @top, @right, @bottom, @left = @left,@top, @right, @bottom
    when "W"
      @top, @right, @bottom, @left = @right, @bottom, @left, @top
    when "N"
      @top, @back , @bottom, @front = @front,@top, @back , @bottom
    when "S"
      @top, @back , @bottom, @front = @back , @bottom, @front,@top
    end
    [@top, @front, @right, @left, @back, @bottom]
  end

  def rolls(s)
    s.chars.each do|s|
      roll(s)
    end
    [@top, @front, @right, @left, @back, @bottom]
  end

end




arr = line[0].split(" ").map(&:to_i)
cmd = line[1]


dice = Dice.new(arr)
dice.rolls(cmd)

puts dice.top

Measured memory_bytes: 9268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
#define PI acos(-1)
using namespace std;

int main(){
    int i, j;
    string str;
    int q;
    string ins, rle;
    int a, b;
    cin >> str;
    cin >> q;
    rep(i,q){
        cin >> ins >> a >> b;
        if(!ins.compare("print")) cout << str.substr(a,b-a+1) << endl;
        else if(!ins.compare("reverse")){
            string sub = str.substr(a, b-a+1);
            reverse(sub.begin(), sub.end());
            str.replace(a,b-a+1,sub);
        }else if(!ins.compare("replace")){
            cin >> rle;
            str.replace(a,b-a+1,rle);
        }
    }
    return 0;
}


Measured memory_bytes: 3236
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000007

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

map < pll, pll > vec;
ll p2[200005];
int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

	p2[0] = 1;

	for(i = 1; i <= 200000; i++) p2[i] = (2 * p2[i - 1]) % mod;

    while(cin >> n)
    {
		vec.clear();

		for(i = 1; i <= n; i++)
		{
			ll a, b;
			slld(a);
			slld(b);

			if(a == 0 && b == 0) vec[{0,0}].first++;
			else if(a == 0) vec[{0,1}].first++;
			else if(b == 0) vec[{0,1}].second++;
			else
			{
				ll g = __gcd(a,b);

				a /= g;
				b /= g;

				if(a * b > 0) vec[{abs(a),abs(b)}].first++;
				else vec[{abs(b),abs(a)}].second++;
			}
		}

		ans = 1;

		for(auto p: vec)
		{
			if(p.first.first == 0 && p.first.second == 0) continue;

			ans = (ans * (p2[p.second.first] + p2[p.second.second] - 1)) % mod;
		}

		ans = (ans + vec[{0,0}].first - 1 + mod) % mod;

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


}





Measured memory_bytes: 20980
#S = gets.to_i
cash = gets
S = cash.split("")
cash0 = ""
cash1 = ""
for i in 1...S.length do
  if i % 2 == 0 then
    cash0 = cash0 + "0"
    cash1 = cash1 + "1"
  else
    cash0 = cash0 + "1"
    cash1 = cash1 + "0"
  end
end

cash0 = cash0.split("")
cash1 = cash1.split("")

num0=0
num1=0
for i in 0...S.length do
  if S[i]==cash0[i] then
    num0=num0+1
  end
  if S[i]==cash1[i] then
    num1=num1+1
  end
end

if num0 > num1 then
  puts num1
else
  puts num0
end


Measured memory_bytes: 114268
#include <bits/stdc++.h>
#define fori(i,a,b) for(int i=a,b_=b;i<=b_;++i)
#define ford(i,a,b) for(int i=a,b_=b;i>=b_;--i)
#define forv(i,a) for(auto &i:a)
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define fi first
#define se second
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define getbit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define ___ << "\n"
#define __ << " " <<
#define _ << " "
using namespace std;

const int N=100005, mod=1e9+7;
int n;
vector<int> ke[N];
ll f[N][2];

void DFS(int pp, int u)
{
    f[u][0]=f[u][1]=1;
    if(ke[u].size()==0) return;
    if(u!=pp && ke[u].size()==1) return;
    forv(v,ke[u]) if(pp!=v)
    {
        DFS(u,v);
        f[u][0]=f[u][0]*f[v][1]%mod;
        f[u][1]=f[u][1]*((f[v][0]+f[v][1])%mod)%mod;
    }
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    int u,v;
    fori(i,1,n-1)
    {
        cin >> u >> v;
        ke[u].pb(v); ke[v].pb(u);
    }
    DFS(1,1);
    cout << (f[1][0] + f[1][1]) %mod;
}


Measured memory_bytes: 12800
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 2e5 + 9;
int fre[N];
int main() {
//	file();
	fast();
	int n; cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int x; cin >> x;
		fre[x]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << fre[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int k;
    cin >> k;

    vector<int> m(k+1);
    int value = 7;
    int i = 1;
    if(value%k==0){
        cout << i << endl;
        return 0;
    } 
    while(true){
        i++;
        value = (10*value + 7) % k;
        if(value==0){
            cout << i << endl;
            return 0;
        }

        m[value]++;
        if(m[value] == 2){
            cout << -1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 7148
#pragma GCC optimize("O3") 

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

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define deb(x)		        cout << #x << ": " << x << endl;
#define deb2(x,y)	        cout << #x << ": " << x << " ~ " <<  #y << ": " << y << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    ll n;
    cin >> n;
    ll a[n], b[n];
    f(i, 0 ,n)
    {
        cin >> a[i] >> b[i];
    }
    f(i, 0, n - 2)
    {
        if(a[i] == b[i])
            if(a[i + 1] == b[i + 1])
                if(a[i + 2] == b[i + 2])
                {
                    cout << "Yes" << endl;
                    return;
                }
    }
    cout << "No" << endl;
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}

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

vector<int> path;
vector<int> path2;
vector<int> V[100010];
int vis[100010];

void dfs(int a)
{
	vis[a]=true;
	path.push_back(a);
	for(int i=0;i<V[a].size();i++)
	{
		if(!vis[V[a][i]])
		{
			dfs(V[a][i]);
			return;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	
	int M,N; cin>>M>>N;
	for(int i=1;i<=N;i++)
	{
		int t1,t2; cin>>t1>>t2;
		V[t1].push_back(t2);
		V[t2].push_back(t1);
	}
	
	dfs(1);
	swap(path,path2);
	dfs(1);
	
	cout<<path.size()+path2.size()-1<<endl;
	for(int i=path2.size()-1;i>=1;i--)
	{
		cout<<path2[i]<<" ";
	}
	for(int i=0;i<path.size();i++)
	{
		cout<<path[i]<<" ";
	}
	
	return 0;
}


Measured memory_bytes: 9976
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	int a,b,x;
	while(cin>>a>>b>>x){
        if(a*a*b==x) printf("%.10lf\n",0);
        else if(x>=0.5*a*a*b){
            double theta=2.00*(a*a*b-x)/(a*a*a);
            printf("%.10lf\n",atan(theta)*180.0/PI);
        }
        else{
            double theta=(0.5*a*b*b)/x;
            printf("%.10lf\n",atan(theta)/PI*180.0);
        }
	}
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <limits>
#include <iomanip>
#include <bitset>

#define INF 1000000000
#define Inf 1000000000000000000
#define mp make_pair
#define pb push_back
#define EPS 1e-9

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

int h, w, n, sr, sc, acc[200010], cur;
string s, t;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10);

  cin >> h >> w >> n >> sr >> sc >> s >> t;

  cur = sc;
  for(int i = 0; i < n; ++i) {
    if (s[i] == 'R') ++cur;
    if (cur > w) {
      cout << "NO" << endl;
      return 0;
    }
    if (t[i] == 'L') --cur;
    if (cur < 1) cur = 1;
  }
  cur = sc;
  for(int i = 0; i < n; ++i) {
    if (s[i] == 'L') --cur;
    if (cur < 1) {
      cout << "NO" << endl;
      return 0;
    }
    if (t[i] == 'R') ++cur;
    if (cur > w) cur = w;
  }
  cur = sr;
  for(int i = 0; i < n; ++i) {
    if (s[i] == 'U') --cur;
    if (cur < 1) {
      cout << "NO" << endl;
      return 0;
    }
    if (t[i] == 'D') ++cur;
    if (cur > h) cur = h;
  }
  cur = sr;
  for(int i = 0; i < n; ++i) {
    if (s[i] == 'D') ++cur;
    if (cur > h) {
      cout << "NO" << endl;
      return 0;
    }
    if (t[i] == 'U') --cur;
    if (cur < 1) cur = 1;
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int x = scan.nextInt();
		int a[] = new int[m];
		int row[] = new int[n+1];
		int rightsum = 0;
		int leftsum = 0;

		for (int num=0; num < m; num++) {
			a[num] = scan.nextInt();
		}

		for (int i=0; i < m; i++) {
			row[a[i]] = 1;
		}

		int rightnum = n - x;

		for (int j = 0; j <= rightnum; j++) {
			rightsum += row[x + j];
		}

		for (int leftnum = x; leftnum >= 0;leftnum--) {
			leftsum += row[leftnum];
		}

		int sum = (rightsum > leftsum)?leftsum : rightsum;

		System.out.println(sum);

		scan.close();

	}

}


Measured memory_bytes: 21972
#include<stdio.h>
#include<string.h>
int comp(const void *p,const void *q){
	return *(int *)p-*(int *)q;
}
int main(){
	int i,j,n,m,c,ans;
	int lb,ub,mid,k;
	int p[1005];
	static q[1003005];
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0)break;
		p[0]=0;
		for(i=1;i<=n;i++)scanf("%d",&p[i]);
		c=0;
		for(i=0;i<=n;i++)
			for(j=i;j<=n;j++)
				q[c++]=p[i]+p[j];
		qsort(q,c,sizeof(int),comp);
		ans=0;
		//for(i=0;i<c;i++)printf("%d%s",q[i],(i==c-1)?"\n":" ");
		for(i=0;i<c;i++){
			if(m>=q[i]){
				lb=0;ub=c;
				k=m-q[i];
				while(ub-lb>1){
					mid=(ub+lb)/2;
					if(q[mid]<=k)lb=mid;
					else ub=mid;
				}
				//printf("%d(%2d) %d + %d\n",ub,q[lb],k,q[i]);
				ans=(ans<q[i]+q[lb])?q[i]+q[lb]:ans;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4544
#include <stdio.h>
#include <ctype.h>

#define MAX_N 2000001
#define MAX_K 10001

char buf[MAX_N*5];

int getInteger();
void countingSort(int,int*);

int main(){
  int n,i;
  static int A[MAX_N];
  fread(buf,1,MAX_N*5,stdin);
  n = getInteger();
  for(i = 0 ; i < n ; i++){
    A[i] = getInteger();
  }
  countingSort(n,A);
  return 0;
}

int getInteger(){
  int res = 0;
  static int c = 0;
  while(isdigit(buf[c])){
    res *= 10;
    res += (buf[c++]-'0');
  }
  c++;
  return res;
}

void countingSort(int n,int *A){
  int i,C[MAX_K] = {0};
  static int B[MAX_N];
  for(i = 0 ; i < n ; i++){ C[A[i]]++; }
  for(i = 1 ; i < MAX_K ; i++){ C[i] += C[i-1]; }
  for(i = n-1 ; i >= 0 ; i--){
    B[C[A[i]]] = A[i]; C[A[i]]--;
  }
  for(i = 0 ; i < n ; i++){
    printf("%d%c",B[i+1],i != n-1 ? ' ' : '\n');
  }
}

Measured memory_bytes: 25676
#include <bits/stdc++.h>
using namespace std;
using um = unordered_map<int, long long>;
#define each(i, a) for (auto &&i : (a))

int main() {
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  each(i, x) cin >> i;
  each(i, x) i -= A;
  function<um(int, int)> div_con = [&](int l, int r) {
    um ret;
    if (r - l == 1)
      ret[x[l]]++;
    else {
      int m = (l + r) / 2;
      um lm = div_con(l, m), rm = div_con(m, r);
      each(p, lm) ret[p.first] += p.second;
      each(p, rm) ret[p.first] += p.second;
      each(p, lm) each(q, rm) ret[p.first + q.first] += p.second * q.second;
    }
    return ret;
  };
  cout << div_con(0, N)[0] << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,k,l,i=0;
	cin>>n>>m>>k;
	l=k;
	do
	{
		l+=m+k;
		i++;
	}
	while(l<n);
	if(l>n) i--;
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
# 2150 start

import numpy

N,M=map(int, input().split())
price = numpy.empty((N,3))
sumcan = 0
sumprice = 0
lastshop = 0

for i in range(N):
    shop_data = input().split()
    A = int(shop_data[0])
    B = int(shop_data[1])
    price[i,0]= A * B
    price[i,1] = A
    price[i,2] = B

price = price[price[:,1].argsort(),:]

for j in range(M):
    sumcan = sumcan + price[j,2]
    if sumcan < M:
        sumprice = sumprice + price[j,0]
    elif sumcan >= M:
        sumcan = sumcan - price[j,2]
        lastshop = j
        break

sumprice = sumprice + (M - sumcan)*price[lastshop,1]

print(int(sumprice))









Measured memory_bytes: 17928
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  void run() {
    String[] l = new String[]{ "Closed by ", "Opened by " };
    int N = ni();
    HashSet<String> set = new HashSet<String>();

    for ( int i = 0; i < N; ++i ) {
      set.add(sc.next());
    }

    int M = ni();
    int flag = 0;
    for ( int i = 0; i < M; ++i ) {
      String str = sc.next();
      if ( set.contains(str) ) {
        flag = 1 - flag;
        System.out.println(l[ flag ] + str);
      } else {
        System.out.println("Unknown " + str);
      }
    }
  }

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

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 20680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	static class Vacations {

		int ar[][];
		int dp[][];

		Vacations(int n) {

			ar = new int[n][3];
			dp = new int[n][3];
		}

		public int func(int i, int j) {

			if (i == ar.length - 1)
				return dp[i][j] = ar[i][j];

			if (dp[i][j] != -1)
				return dp[i][j];

			int max = Integer.MIN_VALUE;

			for (int x = 0; x < 3; x++) {

				if (x != j)
					max = Math.max(max, (ar[i][j] + func(i + 1, x)));
			}
			return dp[i][j] = max;
		}
	}

	public static void main(String[] args) throws Exception {
		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);
		int n = sc.nextInt();
		Vacations a = new Vacations(n);

		for (int i = 0; i < n; i++) {

			a.ar[i][0] = sc.nextInt();
			a.ar[i][1] = sc.nextInt();
			a.ar[i][2] = sc.nextInt();

			for (int j = 0; j < 3; j++)
				a.dp[i][j] = -1;
		}

		int x = a.func(0, 0);
		int b = a.func(0, 1);
		int c = a.func(0, 2);
		pr.println(Math.max(x, Math.max(b, c)));
		pr.close();
	}

	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: 62964
from functools import lru_cache

@lru_cache()
def f(n):
    if n==0:
        return 1
    return 2*f(n-1)+1

@lru_cache()
def g(n):
    if n==0:
        return 1
    return 2*g(n-1)+3

N, X = map(int, input().split())
total = [g(i) for i in range(N+1)]
p = [f(i) for i in range(N+1)]
ans = 0

def search(x, n):
    global ans
    if n==0:
        if x:
            ans += 1
        return
    if x==0:
        return
    if x > total[n-1] + 2:
        ans += p[n-1] + 1
        search(x-(2 + total[n-1]), n-1)
    elif x == total[n-1] + 2:
        ans += p[n-1] + 1
    else:
        search(x-1, n-1)

search(X, N)
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<ll>> X(26);
  int _S = s.size(), _T = t.size();
  REP(i, _S) { X[s[i] - 'a'].push_back(i); }
  ll roop = 0, now = -1;
  REP(i, _T) {
    auto itr = upper_bound(X[t[i] - 'a'].begin(), X[t[i] - 'a'].end(), now);
    if (itr != X[t[i] - 'a'].end()) {
      now = *itr;
      continue;
    }
    roop++, now = -1;
    itr = upper_bound(X[t[i] - 'a'].begin(), X[t[i] - 'a'].end(), now);
    if (itr != X[t[i] - 'a'].end()) {
      now = *itr;
      continue;
    }
    cout << -1 << endl;
    return 0;
  }
  cout << roop * _S + now + 1 << endl;
}

Measured memory_bytes: 4568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll MOD = (ll)1e9 + 7, INF = (ll)1e18;;
ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mul(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(x, bin_pow(x, p - 1));
    return bin_pow(mul(x, x), p / 2);
}

const int N = 100100;
int n, m, q;
ll a[2*N];
ll L, R;
vector<pii> g[2*N];
bool used[2*N];

bool dfs(int v) {
    used[v] = true;
    if (v < n)
        L = max(L, -a[v]);
    else
        R = min(R, a[v]);
    for (auto [u, w] : g[v]) {
        if (used[u]) {
            if (a[v] + a[u] != w) return false;
        }
        else {
            a[u] = w - a[v];
            if (!dfs(u)) return false;
        }
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    
    cin >> n >> m >> q;
    for (int i = 0; i < q; ++i) {
        int x, y, w;
        cin >> x >> y >> w;
        --x; --y;
        g[x].pb({n + y, w});
        g[n + y].pb({x, w});
    }
    
    for (int v = 0; v < n; ++v) {
        if (used[v]) continue;
        L = -INF, R = INF;
        if (!dfs(v) || L > R) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 17896
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;
 
/** Template Begins **/
 
typedef long long        ll;
typedef pair<int,int>    PII;
 
#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)
 
/* Debug */
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
 
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
/* Debug Ends */
 
const int N = 5e6+7;
 
/** Template Ends **/

 
signed main() {
 
    IOS;
    int x;	cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No";



 
    return 0;
}























Measured memory_bytes: 3608
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        String c = sc.next();
        int b = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result;
        if ("+".equals(c)) {
            result = a + b;
        } else {
            result = a - b;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] str1 = sc.next().toCharArray();
		char[] str2 = sc.next().toCharArray();
		if(str1.length != str2.length) {
			System.out.println("No");
			return;
		}

		for(int i = 0; i < str1.length; i++) {
			boolean bo = true;
			for(int j = 0; j < str1.length; j++) {
				if(str1[(i+j)%str1.length] != str2[j]) {
					bo = false;
					break;
				}
			}
			if(bo) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){
  int n,i,j,k,l,a[101],b[101][101];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&a[i-1],&a[i]);
  }

  for(i=1;i<=n;i++){
    b[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      b[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
	if(b[i][j]>b[i][k]+b[k+1][j]+a[i-1]*a[k]*a[j]){
	  b[i][j]=b[i][k]+b[k+1][j]+a[i-1]*a[k]*a[j];
	}
      }
    }
  }
  printf("%d\n",b[1][n]);

  return 0;
}



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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	cout << 800*n - n/15*200 << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from itertools import repeat
def main():
    n, m = map(int, stdin.readline().split())
    s = raw_input().strip()
    dat = map(int, stdin.read().split(), repeat(10, 2 * m))
    e = [[set(), set()] for i in xrange(n)]
    for i in xrange(2 * m):
        dat[i] -= 1
    for i in xrange(m):
        x, y = dat[i*2], dat[i*2+1]
        e[x][s[y]=='B'].add(i)
        e[y][s[x]=='B'].add(i)
    st = []
    pu = st.append
    po = st.pop
    d = [0] * n
    for i in xrange(n):
        if not e[i][0] or not e[i][1]:
            pu(i)
            d[i] = 1
    while st:
        z = po()
        for j in xrange(2):
            for i in e[z][j]:
                x, y = dat[i*2], dat[i*2+1]
                if x == y:
                    continue
                if x == z:
                    x, y = y, x
                e[x][s[y]=='B'].discard(i)
                if not e[x][s[y]=='B'] and not d[x]:
                    d[x] = 1
                    pu(x)
            e[z][j].clear()
    for i in xrange(n):
        if e[i][0] and e[i][1]:
            print 'Yes'
            return
    print 'No'
main()


Measured memory_bytes: 135468
#include <stdio.h>

int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 2688
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
		
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int c = 0, d = 0;
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			c += a.at(i);
		}
		else
		{
			d += a.at(i);
		}
	}
	cout << c - d << endl;

}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

mul xs as = map (sum . zipWith (*) as) xs

main = do
  [n, m] <- map (\x -> read x :: Int) . words <$> getLine
  a <- replicateM n $ map (\x -> read x :: Int) . words <$> getLine
  b <- replicateM m readLn
  mapM_ print $ mul a b

Measured memory_bytes: 7572
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=s-1; i>=s; i--)

int main(){

    int n; cin >> n;
    queue<int> qremain[n];
    rep(i, n){
        rep(j, n-1){
            int temp; cin >> temp;
            temp--;

            qremain[i].push(temp);
        }
    }

    queue<int> qupdate;
    rep(i, n){
        qupdate.push(i);
    }

    int cnt = 0;
    int donecnt = 0;
    int donecntprev = -1;
    bool deadlock = false;
    while(true){
        if(donecntprev == donecnt){
            deadlock = true;
            break;
        }

        donecntprev = donecnt;

        // cout << "done " << donecnt << endl;
        if(donecnt == n*(n-1)) break;

        cnt++;
        // cout << cnt << endl;
        int nq = qupdate.size();
        queue<int> qnext;
        vector<int> vpop;
        set<int> st;

        rep(i, nq){
            int t = qupdate.front();
            qupdate.pop();
            // cout << " " << t << endl;

            if(qremain[t].empty()) continue;

            int u = qremain[t].front();
            if(t == qremain[u].front()){
                if(st.find(t) != st.end()) continue;

                // cout << t << " " << u << endl;
                st.insert(t);
                st.insert(u);
                qnext.push(t);
                qnext.push(u);
                vpop.push_back(t);
                vpop.push_back(u);
                donecnt += 2;
            }
        }
        for(int x : vpop){
            qremain[x].pop();
        }
        nq = qnext.size();
        rep(i, nq){
            int t = qnext.front();
            qnext.pop();
            qupdate.push(t);
        }

        // rep(i, n){
        //     cout << ":" << qremain[i].front() << endl;
        // }


        // cout << cnt << endl;
    }

    cout << (deadlock ? -1 : cnt) << endl;

    return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		int array[] = new int[N];
		for(int i = 0; i < N; i++)array[i] = scanner.nextInt();

		out_put(array);

		int base_value,loc;
		for(int i = 1; i < N; i++){
			base_value = array[i];
			loc = i-1;
			while(loc >= 0 && array[loc] > base_value){
				array[loc+1] = array[loc];
				loc--;
			}
			array[loc+1] = base_value;

			out_put(array);
		}
	}

	private static void out_put(int array[]){

		System.out.printf("%d", array[0]);

		for(int i = 1; i < array.length; i++){
			System.out.printf(" %d", array[i]);
		}
		System.out.printf("\n");
	}
}


Measured memory_bytes: 51700
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
		double D = sc.nextDouble();
		double T = sc.nextDouble();
		double S = sc.nextDouble();
		
		double a = 0;
		a = D / S;
		
		if(a <= T) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}

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

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

    vector<int> d(n);
    for (int i = 0; i < n; i++)
        cin >> d[i];

    sort(d.begin(), d.end());
    int abc, arc;

    abc = *(d.begin()+ (n/2) -1);
    arc = *(d.begin()+ (n/2));

    cout << arc-abc << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define N 100010
using namespace std;
int main(){
	int n,m=0;
	scanf("%d",&n);
	if(n<=9)printf("%d",n);
	else if(n<=99)printf("9");
	else if(n<=999)printf("%d",9+(n-99));
	else if(n<=9999)printf("909");
	else if(n<=99999)printf("%d",909+n-9999);
	else printf("90909");
	return 0;
}

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

int main()
{
	int n;
	long long int ans = 0;
	cin >> n;
	if (n)ans++;
	for (int i = 1; i <= n; i++)
	{
		ans *= i;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, n) for(ll i = 0; i < n; i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
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 stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
template<class T>bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n, k;
  cin >> n >> k;
  vector<ll> ans(n, 0);
  for(ll i = 0; i < k; i++){
    ll d;
    cin >> d;
    for(ll j = 0; j < d; j++){
      ll a;
      cin >> a;
      a--;
      ans[a]++;
    }
  }
  
  ll res = 0;
  rep(i, n){
    if(ans[i] == 0) res++;
  }
  cout << res << endl;
  return 0;
}

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

int main() {
  int p1, p2, p3, j1, j2;
  cin >> p1 >> p2 >> p3 >> j1 >> j2;
  int t = 0;
  t += (p1<p2?(p1<p3?p1:p3):(p2<p3?p2:p3));
  t += (j1<j2?j1:j2);
  t -= 50;
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys


def solve(N: int, S: str, T: str):
    ans = ''
    for i in range(N):
        ans += S[i]
        ans += T[i]
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(N, S, T)

if __name__ == '__main__':
    main()


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

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i = (a); i != (b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int) (v).size())

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

// sum to 2^30
const int maxn = 2e5 + 10;
int A[maxn];

map<int, int> cnt[31];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	scanf("%d", &n);
	REP(i, n) scanf("%d", &A[i]);

	sort(A, A + n);

	ll ret = 0;
	REP(i, n) {
		int x = A[n-1-i];


		// 2^j >= x

		int y = -1;

		int j = 0;
		while ((1<<j) < x) j++;
		while (j < 31) {
			int ty = (1 << j) - x;
			if (cnt[j].find(ty) != cnt[j].end() && cnt[j][ty] > 0) {
				y = ty;
				break;
			}
			j++;
		}

		if (y >= 0) ret++;

		for (int k = 0; k < 31; k++) {
			if (y >= 0) {
				if (y < (1<<k)) cnt[k][y]--;
			} else {
				// cerr << "add " << x << endl;
				if (x < (1<<k)) cnt[k][x]++;
			}
		}
	}

	/* for (int k = 0; k < 31; k++) {
		cerr << k << ": ";
		for (auto x : cnt[k]) cerr << x.x << "->"<<x.y << " ";
		cerr << endl;
	} */

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 20608
#include <iostream>

using namespace std;
int n ,m,f,war[1001],you[1001];
bool s,w;
char arr[1001][10001];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>arr[i][j];
            if(arr[i][j]=='.')f++;
        }
        if(f==m)war[i]=i;
        f=0;
    }
  for(int k=1;k<=m;k++)
  {
    for(int h=1;h<=n;h++)
    {
        if(arr[h][k]=='.')f++;

    }
   if(f==n)you[k]=k;

   f=0;
  }

  for(int l=1;l<=n;l++)
  {
      for(int d=1,w=1;d<=m;d++)
      {
          if(war[l]!=l&&you[d]!=d)
          {  if(w==1&&l!=1&&s==1)
              {cout<<endl;
              }
              cout<<arr[l][d];
              w++;
              s=1;
          }

      }

  }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <random>

#define ll long long

using namespace std;

struct item {
    int w;
    ll c;
};

int main() {
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    int n, W;
    scanf("%d %d", &n, &W);
    vector<item> a(n);
    for (int i = 0; i < n; i++)
        scanf("%d %lld", &a[i].w, &a[i].c);
    vector<ll> b(W + 1, -1);
    b[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = W - a[i].w; j >= 0; j--) {
            if (b[j] != -1) {
                b[j + a[i].w] = max(b[j + a[i].w], b[j] + a[i].c);
            }
        }
    }
    ll maxVal = -1;
    for (int i = 0; i <= W; i++)
        maxVal = max(maxVal, b[i]);
    printf("%lld", maxVal);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
char str[1000010];
int dp[1000010],L[1000010];
int main()
{
    int n;
    cin>>n;
    scanf("%s",str+1); 
    for(int i=1;i<=n;i++)
    {
        if(str[i]=='1')L[i]=L[i-1];
        else L[i]=i;
    }
    for(int i=1;i<=n;i++)
    {
        dp[i]=dp[i-1];
        if(str[i]=='1')
        {
            if(str[i-1]=='0' and str[i-2]=='1')
            {
                dp[i]=max(dp[i],dp[L[i-2]]+(i-2)-L[i-2]);
                dp[i]=max(dp[i],dp[L[i-2]+1]+(i-2)-L[i-2]-1);
            }
            else if(L[i]>1 and  str[L[i]-1]=='1')
            {
                dp[i]=max(dp[i],dp[L[i]-2]+i-L[i]);
            }
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        String ans = "Good";
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i) == s.charAt(i - 1)) {
                ans = "Bad";
            }
        }
        System.out.println(ans);
    }

}


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

int main() {
    int n, k, d[110], a, sunuke[110] = {0};
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        cin >> d[i];
        for (int j = 0; j < d[i]; ++j) {
            cin >> a;
            sunuke[a - 1] = 1;
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i)
        if (!sunuke[i]) ++cnt;

    cout << cnt << endl;
}


Measured memory_bytes: 3636