akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

int main() {

	int N;
	cin >> N;

	int F[100][10] = {};
	rep(i, N) {
		rep(ii, 10) {
			cin >> F[i][ii];
		}
	}

	int P[100][11] = {};
	rep(i, N) {
		rep(ii, 11) {
			cin >> P[i][ii];
		}
	}

	int saidai = -1000000000;
	rep1(i, 1023) {

		int rieki = 0;
		rep(ii, N) {

			int kari = i;
			int kazu = 0;
			rep(iii, 10) {
				if (kari % 2 && F[ii][iii]) kazu++;
				kari /= 2;
			}
			rieki += P[ii][kazu];
		}

		saidai = max(saidai, rieki);
	}

	co(saidai);
	Would you please return 0;
}

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


struct Node{
    int water;
    int sugar;

    double sugarP() const{
        if(water == 0 && sugar == 0)    return 0;
        return (100.0*sugar)/(100.0*water + sugar);
    }

    bool operator< (const Node &r) const{
        return sugarP() > r.sugarP();
    }
};

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


    map<int, double> m;
    priority_queue<Node> que;

    set<int> st;
    rep(i, 3005){
        rep(j, 3005){
            if(100*i*a + 100*j*b <= f)  st.insert((int)i*a + (int)j*b);
            else                        break;
        }
    }

    double border = (100.0*e)/(100.0 + e);

    Node maxx = {a, 0};

    for(auto water : st){
        rep(i, 3005){
            if(100*water + c*i <= f)    que.push({water, c*(int)i});
            else                        break;
        }
    }

    while(!que.empty()){
        Node node = que.top(); que.pop();

        if(node.sugarP() < m[node.water])   continue;
        if(border < node.sugarP())          continue;
        m[node.water] = node.sugarP();

        if(maxx.sugarP() < node.sugarP())   maxx = node;

        Node dn = {node.water, node.sugar+d};
        if(100*dn.water+dn.sugar <= f)  que.push(dn);        
    }

    cout << 100*maxx.water+maxx.sugar << " " << maxx.sugar << endl;

    return 0;
}


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

bool visited[100001];
int official[100001] = {0};

struct input{
    int node1;
    int node2;
};

int main(){
    //gathering input
    int n, m, counter=1;
    cin >> n >> m;
    input nodes[m];
    queue<int> ans;
    vector<int> connect[n+1];
    //getting input
    for(int i=0; i<m; i++){
        cin >> nodes[i].node1 >> nodes[i].node2;
        connect[nodes[i].node1].push_back(nodes[i].node2);
        connect[nodes[i].node2].push_back(nodes[i].node1);
    }
    //DEBUG
//    for(int i=0; i<n+1; i++){
//        for(int k=0; k<connect[i].size(); k++){
//            cout << connect[i][k] << " ";
//        }
//        cout << endl;
//    }
    //initializing
    visited[1]=true;
    ans.push(1);
    //function
    while(counter<=n and !ans.empty()){
        int wanted =ans.front();
        ans.pop();
        for(int i=0; i<connect[wanted].size(); i++){
            if(!visited[connect[wanted][i]]){
                visited[connect[wanted][i]]=true;
                ans.push(connect[wanted][i]);
                official[connect[wanted][i]]=wanted;
                counter++;
            }
        }
        if(ans.empty() and counter!=n){
            cout << "No" << endl;
            return 0;
        }
    }
    //end printing
    cout << "Yes" << endl;
    for(int i=2; i<=n; i++){
        cout << official[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 12088
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

void main() {
	string[] inputs = split(readln());
	int x = to!int(inputs[0]);
	int a = to!int(inputs[1]);
	int b = to!int(inputs[2]);
	
	if(abs(x - a) < abs(x - b)) 'A'.writeln;
	else 'B'.writeln;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF 100000000 
#define N 100

int n;
int size[N];
int to[N][N];
int cost[N][N];
int dist[N];
 
void DFS(int,int);
 
main(int argc,char *argv[]){
  int i, j;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    int u;
    scanf("%d", &u);
    scanf("%d", &size[u]);
    for(j=0;j<size[u];j++){
      scanf("%d", &to[u][j]);
      scanf("%d", &cost[u][j]);
    }
  }
  for(i=0;i<n;i++) dist[i] = INF;
  DFS(0, 0);
  for(i=0;i<n;i++){
    printf("%d %d\n", i, dist[i]);
  }
  return 0;
}
void DFS(int p, int c){
  int i;
  dist[p] = c;
  for(i=0;i<size[p];i++){
    if(dist[to[p][i]] > c + cost[p][i])
      DFS(to[p][i], c + cost[p][i]);
  }
}
 

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

#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b, c; cin >> a >> b >> c;
  cout << min(b/a, c);
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    for (a in 1..9)
        for (b in 1..9)
            if (a * b == N) {
                println("Yes")
                return
            }
    println("No")
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta

Measured memory_bytes: 33484
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, ans;
    string S;
    cin >> N;
    cin >> S;
    vector<int> West(N);
    vector<int> East(N);
    if ( S.at(0) == 'W' ) West.at(0) = 1;
    else West.at(0) = 0;
    if ( S.at(N-1) == 'E' ) East.at(N-1) = 1;
    else East.at(N-1) = 0;
    REP(int,i,1,N){
        if ( S.at(i) == 'W' ) West.at(i) = 1 + West.at(i-1);
        else West.at(i) = West.at(i-1);
        if ( S.at(N-1-i) == 'E' ) East.at(N-1-i) = 1 + East.at(N-1-i+1);
        else East.at(N-1-i) = East.at(N-1-i+1);
    }
    ans = N;
    /*REP(int,i,0,N) cout << West.at(i) << " ";
    cout << endl;
    REP(int,i,0,N) cout << East.at(i) << " ";
    cout << endl;*/
    REP(int,i,0,N){
        ans = min(ans,West.at(i) + East.at(i) - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3076
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

X, Y, A, B, C = i_l()
p = i_l()
q = i_l()
r = i_l()

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

p = p[:X]
q = q[:Y]
arr = sorted((p + q + r), reverse=True)

print(sum(arr[:(X+Y)]))

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

using namespace std;

int main() {
    string s;

    cin >> s;
    
    int ans = 0;

    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0 && s[i] == 'p') {
            ans--;
        } else if (i % 2 == 1 && s[i] == 'g') {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	ll n,d;
	cin >> n >> d;
	vector<ll> x(n),y(n);
	ll ans = 0;
	REP(i,n) cin >> x[i] >> y[i];
	
	REP(i,n){
		if(d*d >= x[i]*x[i] + y[i]*y[i] ){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6284
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	bool res = true;
	string s_l, s_r;
	int n = s.length();
	s_l = s.substr(0, (n - 1) / 2);
	s_r = s.substr((n + 1) / 2);
	reverse(s_r.begin(), s_r.end());
	if (s_l != s_r)res = false;
	int m = s_l.length();
	string s_l_l, s_l_r;
	if (m % 2 == 0) {
		s_l_l = s_l.substr(0, m / 2);
		s_l_r = s_l.substr(m / 2);
		reverse(s_l_r.begin(), s_l_r.end());
		if (s_l_l != s_l_r)res = false;
	}
	else {
		s_l_l = s_l.substr(0, (m-1)/ 2);
		s_l_r = s_l.substr((m+1)/ 2);
		reverse(s_l_r.begin(), s_l_r.end());
		if (s_l_l != s_l_r)res = false;
	}
	if (res)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: i64, b: i64,
        p: [i64; n],
    }
    let mut p1 = 0;
    let mut p2 = 0;
    for p in p {
        if p <= a {
            p1 += 1;
        } else if p <= b {
            p2 += 1;
        }
    }
    use std::cmp::min;
    println!("{}", min(p1, min(p2, n - p1 - p2)));
}


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

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

  int cnt = 0;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s.at(i) != s.at(s.size() - i - 1)) {
      cnt++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
def kaibun(s):
  n=len(s)
  a=True
  if n%2==0:
    for i in range(n//2):
      if s[i]!=s[n-1-i]:
        a=False
  else:
    for i in range((n-1)//2):
      if s[i]!=s[n-1-i]:
        a=False
  return a
S=input()
N=len(S)
if kaibun(S)==True and kaibun(S[0:(N-1)//2])==True and kaibun(S[(N+3)//2-1:N])==True:
  print("Yes")
else:
  print("No")

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

using namespace std;

map < pair < string, string >, int > mp;

main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int mask = 0; mask < (1 << n); mask++) {
    string a, b;
    for (int i = 0; i < n; i++) {
      if ((mask >> i) & 1) {
        a += s[i];
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if ((mask >> i) & 1 ^ 1) {
        b += s[i];
      }
    }
    mp[{a, b}]++;
  }
  long long ans = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    string a, b;
    for (int i = 0; i < n; i++) {
      if ((mask >> i) & 1) {
        a += s[n + i];
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if ((mask >> i) & 1 ^ 1) {
        b += s[n + i];
      }
    }
    ans += mp[{b, a}];
  }
  cout << ans;
}


Measured memory_bytes: 91904
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end());
	for (int i = 0; i < n; i++) {
		if (a[i] <= b[n / 2 - 1]) cout << b[n / 2] << endl;
		else cout << b[n / 2 - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3840
using System;

namespace abc93A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string[] temp = { "", "", "" };
            for(int i = 0; i < 3; i++)
            {
                temp[i] = A.Substring(i, 1);
            }
            if (temp[0] != temp[1] && temp[0] != temp[2] && temp[1] != temp[2])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main(void){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
           
            break;
        }
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                printf("#");
            }
            printf("\n");
        }
            printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  if(s == "ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<int,int> P;
#include <boost/multiprecision/cpp_int.hpp>

using bint = boost::multiprecision::cpp_int;
 


int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> x(n),y(n),z(n);
    rep(i,n) cin >> x[i] >> y[i] >> z[i];
    ll ans = 0ll;
    rep(i,8){
        vector<ll> tempx = x;
        vector<ll> tempy = y;
        vector<ll> tempz = z;
        int sx = (1<<0) & i;
        int sy = (1<<1) & i;
        int sz= (1<<2) & i;
        if (sx){
            rep(i,n){
                tempx[i] *= -1;
            }
        }
        if (sy){
            rep(i,n){
                tempy[i] *= -1;
            }
        }
        if (sz){
            rep(i,n){
                tempz[i] *= -1;
            }
        }
        vector<ll> temp(n);
        rep(i,n) temp[i] = tempx[i] + tempy[i] + tempz[i];
        SORTR(temp);
        ll cand = 0ll;
        rep(i,m){
            cand += (ll)temp[i];
        }
        ans = max(ans,cand);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

vector<int> prime;
int num[105];

void setPrime(int n) {
    for(int i=2; i<=n; i++) {
        bool ok = true;
        for (int j=2; j*j<=i; j++) {
            if (i%j==0) ok = false;
        }
        if (ok) prime.push_back(i);
    }
}



int main(){
    int n;
    cin >> n;
    ll ans = 0;
    setPrime(n);
    
    
    for (int i=2; i<=n; i++) {
        int v = i;
        for (int j:prime) {
            if (v==1) break;
            while (v%j==0) {
                v /= j;
                num[j]++;
            }
        }
    }
    rep(i, n+1) {
        //cout << num[i] << endl;
    }
    
    int num74 = 0;
    int num24 = 0;
    int num14 = 0;
    int num4 = 0;
    int num2 = 0;
    rep(i, n+1) {
        if (num[i]>=74) num74++;
        if (num[i]>=24) num24++;
        if (num[i]>=14) num14++;
        if (num[i]>=4) num4++;
        if (num[i]>=2) num2++;
    }
    ans += num74;
    ans += num24*(num2-1);
    ans += num14*(num4-1);
    ans += (num4*(num4-1)/2)*(num2-2);
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
vector<int> family;
int cnt = 1;
vector< vector<int> > adj;

void dfs(int v){
    family[v] = cnt;
    for(auto &x: adj[v]){
        if(family[x] == 0) dfs(x);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    family.assign(n+1, 0);
    adj.resize(n+1);
    while(m--){
        int x, y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for(int i=1; i<=n; i++){
        if(family[i] == 0){
            dfs(i);
            cnt++;
        }
    }
    sort(begin(family), end(family));
    int mx = 1, cnt2 = 0;
    for(int i=1, curr = family[0]; i<=n; i++){
        if(curr == family[i]) cnt2++;
        else{
            mx = max(mx, cnt2);
            cnt2 = 1;
            curr = family[i];
        }
    }
    cout << max(mx, cnt2);
}


Measured memory_bytes: 21072
n,m = map(int,input().split())
r = [[] for i in range(n)]
for i in range(m):
  x,y = map(int,input().split())
  r[x-1].append(y-1)
  r[y-1].append(x-1)
max = 0  
mark = []
for i in range(n):
  mark.append('t')

for i in range(n):
  if mark[i] == 't':
    s = 0
    mark[i] = 'f'
    stack = [i]
    while stack:
      x = stack.pop() #要素を取り出す
      s += 1
      for j in range(len(r[x])):
        nx = r[x][j]
        if mark[nx] == 't':
            mark[nx] = 'f'
            stack.append(nx) 
    
  if max < s:
    max = s
                     
print(max)    

Measured memory_bytes: 44668
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();      
        int[] a = r.ii();
        println(a[0]*a[1] < a[2] ? a[0]*a[1] : a[2]);        
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23252
'use strict'
function otoshidama(stdin) {
  const inputs = stdin.split(' ')
  const n = inputs[0]
  const y = inputs[1]
  for (let i = 0;i <= n;i++) {
    const remain = y - 10000 * i
    if (remain < 0) break
    for (let j = 0;j <= n - i;j++) {
      const sen = n - i - j
      const result = remain - 5000 * j - 1000 * sen
      if (result === 0) return console.log(i, j, sen)
    }
  }
  return console.log(-1, -1, -1)
}
otoshidama(require('fs').readFileSync(0, 'utf8'))

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (S == U) cout << A - 1 << " " << B << endl;
    else cout << A << " " << B - 1 << endl;

    return 0;
}


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

long long int N, a[100000], b[100000], i;

long long int mdbipw(long long int n){
    long long int ret = 1, bi = 2;
    while(n){
        if(n & 1){
            ret *= bi;
            ret %= 1000000007;
        }
        bi *= bi;
        bi %= 1000000007;
        n /= 2;
    }
    return ret;
}

int main(){
    scanf("%lld", &N);
    for(i = 0; i < N; ++i){
        scanf("%lld", a + i);
        b[i] = ((i + 1 + ((N + 1) & 1)) / 2) * 2 - ((N + 1) & 1);
    }
    sort(a, a + N);
    cout << (equal(a, a + N, b)?mdbipw(N / 2):0) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  string s;
  int i,flag=0,a[30]={0};
  cin>>s;
  for(i=0;i<s.length();i++){
      a[s[i]-'a']++;
  }
  for(i=0;i<30;i++)
    if(a[i]>1)
    flag=1;
  if(flag==1)
    cout<<"no";
  else
    cout<<"yes";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

int x, y, z;
struct Medals
{
	int g, s, b;
}Med[MaxN + 5];
LL pre[MaxN + 5]; //prefix
LL suf[MaxN + 5]; //suffix
priority_queue <LL, vector<LL>, greater<LL> > preq;
priority_queue <LL, vector<LL>, greater<LL> > sufq;

int cmp(Medals a, Medals b) {
	return (a.g - a.s) < (b.g - b.s);
}

int main()
{
	while(scanf("%d %d %d", &x, &y, &z) != EOF)
	{
		int all = x + y + z;
		for(int i = 1; i <= all; i++) {
			scanf("%lld %lld %lld", &Med[i].g, &Med[i].s, &Med[i].b);
		}
		sort(Med + 1, Med + all + 1, cmp);

		for(int i = 1; i <= y; i++) {
			pre[y] += Med[i].s;
			preq.push(Med[i].s - Med[i].b);
		}
		for(int i = y + 1; i <= all; i++) {
			LL tmp = preq.top();
			pre[i] = pre[i - 1] + Med[i].b;
			if(tmp < (Med[i].s - Med[i].b)) {
				pre[i] -= tmp;
				pre[i] += Med[i].s - Med[i].b;
				preq.pop();
				preq.push(Med[i].s - Med[i].b);
			}
		}

		for(int i = all; i >= y + z + 1; i--) {
			suf[y + z + 1] += Med[i].g; 
			sufq.push(Med[i].g - Med[i].b);
		}
		for(int i = y + z; i >= 1; i--) {
			LL tmp = sufq.top();
			suf[i] = suf[i + 1] + Med[i].b;
			if(tmp < (Med[i].g - Med[i].b)) {
				suf[i] -= tmp;
				suf[i] += Med[i].g - Med[i].b;
				sufq.pop();
				sufq.push(Med[i].g - Med[i].b);
			}
		}

		LL ans = 0;
		for(int i = y ; i <= y + z ; i++) {
			ans = max(ans, pre[i] + suf[i + 1]);
		}
		printf("%lld\n", ans);

		memset(Med, 0, sizeof(Med));
		memset(pre, 0, sizeof(pre));
		memset(suf, 0, sizeof(suf));
		while(!preq.empty()) preq.pop();
		while(!sufq.empty()) sufq.pop();
	}
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int b[n], col[n];
    for (int i = 0; i < n; i++) {
        b[i] = 1;
        col[i] = 'w';
    }
    col[0] = 'r';
    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        x--, y--;
        if (b[x] > 0) {
            if (b[y] == 0) {
                col[y] = col[x];
            }
            else if (col[x] == 'r') col[y] = 'r';
            b[x]--;
            b[y]++;
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += !!(b[i] > 0 && col[i] == 'r');
    }
    cout << cnt << "\n";
}


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

int counter(int num){
    int count = 0;
    while(num % 2 == 0){
        num /= 2;
        count++;
    }
    return count;
}

int main(){

    long  a, b;
    int count = 0;
    int res = 0xFFFF;

    cin >> a;
    
    for(int i = 0; i < a; i++){
        cin >> b;
        if(b % 2 != 0){
            res = 0;
            cout << res << endl;
            return 0;
        } else {
            int temp = counter(b);
            if(res > temp){
                res = temp;
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
	static void Main(string[] args)
	{
		// 入力フェーズ
				//string input[] = Console.ReadLine().Split(' ');
        string S = Console.ReadLine();

				// i文字目から数えた時最長
				int len = 0;
				for(int i=0; i<S.Length; i++)
				{
					for(int j=i; j<S.Length; j++)
					{
						if(S[j] == 'A' || S[j] == 'T' || S[j] == 'C' || S[j] == 'G')
						{
							;
						}
						else
						{
							int l = j - i;
							if(len < l)
							{
								len = l;
							}
							break;
						}

						if(j == S.Length - 1)
						{
							// 最後の文字がATCGの場合
							int l = j - i + 1;
							if(len < l)
							{
								len = l;
							}
						}
					}
				}

				Console.WriteLine(len);

    }

}


Measured memory_bytes: 13140
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
  num = 1+i
  A[i] = [A[i], num]
A.sort(key=lambda x: x[0])
for i in range(N):
  A[i] = A[i][1]
L=[str(a) for a in A]
L=" ".join(L)
print(L)

Measured memory_bytes: 21504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1005;

ll fsum(ll x){
    ll a = 0;
    while(x){
        a += (x % 10);
        x /= 10;
    }
    return a;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<ll>v;
    for(int i = 1;i < 10;i++){
        v.push_back(i);
    }
    v.push_back(19);
    ll K;
    cin>>K;
    ll last = 19;
    while(v.size() < K){
        //去向量的最后一个fsum 
        ll p = fsum(last);
        ll add = 1;
        //99 :109 119 
        while((last+add)*fsum(last+add*2) > (last+2*add)*fsum(last+add)){
            add *= 10;
        }
        last += add;
        v.push_back(last);
    }
    for(int i = 0;i < K;i++){
        cout<<v[i]<<endl;
    }
    return 0;
}


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

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

    vector<int> a(5);
    REP(i, 5) cin >> a[i];
    sort(a.begin(), a.end());

    int k; cin >> k;

    if (a[4] - a[0] <= k) cout << "Yay!" << '\n';
    else cout << ":(" << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
s = ns()

cnt = Counter(s)

ans = 1
mod = 10**9+7

for k,v in cnt.items():
    ans *= (v+1)
    ans %= mod
    
ans -= 1
if ans < 0:
    ans += mod
    
print(ans)

Measured memory_bytes: 3572
def main():
    h1,m1,h2,m2,k = map(int,input().split())
    wake_up_minutes = (h2-h1) * 60 - m1 + m2
    study_start_minutes = max(0,wake_up_minutes - k)
    print(study_start_minutes)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
// C - Lining Up
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

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

	int ans = 1;
	int odd = (N-1) & 1;
	for(int i=odd; i<N; i+=2){
		int a = A[i];
		if(!odd && i==0 && a==1) continue;
		if(a!=2){
			cout<< '0' <<endl;
			return 0;
		}
		ans = ans * a % MOD;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 640
N = int(input())

H = list(map(int, input().split()))

max = 0
count = 0
for i in range(N):
    if i == 0: continue
    if H[i - 1] >= H[i]:
        count += 1
    else:
        if count > max:
            max = count
        count = 0
if count > max:
    max = count
print(max)


Measured memory_bytes: 14252
import sys
from math import pi, cos, sqrt
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    x, k, d = geta(int)

    ans = 0
    if abs(x) > k * d:
        ans = abs(x) - k * d
    else:
        q, r = divmod(abs(x), d)

        if (k - q) & 1 == 0:
            ans = r
        else:
            ans = d - r

    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

struct Node
{
    bool visited = false;
    long taka = INF;
    long aoki = INF;
    vector<long> adj;
};

void bfs(long x, vector<Node> &nodes, bool taka)
{
    queue<long> q;
    q.push(x);
    while (not q.empty()) {
        long y = q.front();
        q.pop();
        Node &r = nodes[y];
        r.visited = true;
        long dist = (taka) ? r.taka : r.aoki;
        for (auto &z : r.adj) {
            Node &u = nodes[z];
            if (u.visited) continue;
            if (taka) {
                if (dist + 1 < u.aoki) {
                    u.taka = dist + 1;
                    q.push(z);
                }
            } else {
                u.aoki = dist + 1;
                q.push(z);
            }
        }
    }
}

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n, u, v;
        cin >> n >> u >> v;

        vector<Node> nodes(n+1);
        nodes[u].taka = 0;
        nodes[v].aoki = 0;
        for (long i = 0; i < n-1; i++) {
            long a, b;
            cin >> a >> b;
            nodes[a].adj.push_back(b);
            nodes[b].adj.push_back(a);
        }
        bfs(v, nodes, false);
        for (long i = 1; i <= n; i++) {
            nodes[i].visited = false;
        }
        bfs(u, nodes, true);

        long ans = -INF;
        long diff = nodes[u].aoki;
        for (long i = 1; i <= n; i++) {
            if (nodes[i].taka != INF) {
                ans = max(ans, nodes[i].aoki);
            }
        }
        ans -= 1;
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 11660
#include<iostream>
#include<algorithm>
#include<sstream>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    for(int ix=0;ix<n;ix++){
        cin>>s;
        string big,sma;
        big=sma=s;
        sort(sma.begin(),sma.end(),less<char>());
        sort(big.begin(),big.end(),greater<char>());
        int bi=0,sm=0;
        stringstream b,s;
        b<<big;
        s<<sma;
        b>>bi;
        s>>sm;
        cout<<bi-sm<<endl;
    }
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string s;
    int K;
    cin >> s >> K;

    set<string> st;
    rep(i,0,s.size()){
        string t;
        rep(j,i,s.size()){
            t+=s[j];
            if(st.size()<K){
                st.insert(t);
                continue;
            }
            if(*st.rbegin()>t){
                st.insert(t);
                if(st.size()>K){
                    auto it=st.end();
                    --it;
                    st.erase(it);
                }
            }else break;
        }
    }

    cout << *st.rbegin() << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
ll a,b,c;
cin>>a>>b>>c;

if(a%2==0 || b%2==0 || c%2==0){
	cout<<0<<endl;
	return 0;
}
cout<<min({a*b,b*c,c*a})<<endl;
return 0;


}



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

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

A0 = A[1:] + [A[0] + K]
dis = [a0 - a for (a, a0) in zip(A, A0)]
ans = K - max(dis)

print(ans)


Measured memory_bytes: 26420
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if(A + B > C + D) {
			System.out.println("Left");
		} else if(A + B == C + D) {
			System.out.println("Balanced");
		} else {
			System.out.println("Right");
		}
	}
}


Measured memory_bytes: 21716
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s,ok[4]={"dream","dreamer","erase","eraser"};
    cin>>s;
    vector<int>dp(s.size()+1);
    dp[0]=1;
    for(int i=0;i<(int)s.size();i++)
        for(int j=0;j<4;j++)
            if(s.substr(i,ok[j].size())==ok[j])
                dp[i+ok[j].size()]|=dp[i];
    return 0*printf("%s\n",(dp[s.size()] ? "YES" : "NO"));
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;

int main(){
    Fast;
    int n;
    cin>>n;
    unsigned long long int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    sort(a,a+n);
    reverse(a,a+n);
    bool ok=true;
    unsigned long long int ans=1LL,x=1e18;
    for(int i=0;i<n;i++){
        ans*=a[i];
        if(ans>x){
            cout<<-1<<endl;
            return 0;
        }
    }
    if(ans>0 && ans<=x){
        cout<<ans<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 4436
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let q: usize = scan(tokens);
    for _ in 0..q {
        let a: usize = scan(tokens);
        let b: usize = scan(tokens);
        let c: usize = scan(tokens);
        let d: usize = scan(tokens);
        let (a, b, c, d) = (a - 1, b - 1, c - 1, d - 1);
        let mut loss = 0;
        let mut u = 1;
        for _ in 0..30 {
            loss = std::cmp::max(loss, f(a, b, c, d, u));
            loss = std::cmp::max(loss, f(c, d, a, b, u));
            loss = std::cmp::max(loss, f(b, a, d, c, u));
            loss = std::cmp::max(loss, f(d, c, b, a, u));
            u *= 3;
        }
        println!("{}", diff(a, c) + diff(b, d) + 2 * loss);
    }
}

fn f(a: usize, b: usize, c: usize, d: usize, u: usize) -> usize {
    if (a / u + 2) / 3 < (c / u + 1) / 3 && b / u == d / u && b / u % 3 == 1 {
        let mut loss = u;
        loss = std::cmp::min(loss, b % u + 1);
        loss = std::cmp::min(loss, d % u + 1);
        loss = std::cmp::min(loss, u - b % u);
        loss = std::cmp::min(loss, u - d % u);
        loss
    } else {
        0
    }
}

fn diff(x: usize, y: usize) -> usize {
    if x < y {
        y - x
    } else {
        x - y
    }
}


Measured memory_bytes: 4476
n = int(input())
elements = [int(input()) for _ in range(n)]

#初期値
max_v = -100000000000000 #負の値をとる場合があるので0ではNG
min_v = elements.pop(0)

'''
for j が 1 から n-1 まで
  maxv = (maxv と R[j]-minv のうち大きい方)
  minv = (minv と R[j] のうち小さい方)
'''
for element in elements :
    max_v = max(element-min_v,max_v)
    min_v = min(element,min_v)
print(max_v)


Measured memory_bytes: 13600
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

vector<bool> vis;
vector<int> G[200020], a, b;

void dfs(int k, int dep) {
    vis[k] = 1;
    if (dep % 2) a.push_back(k);
    else b.push_back(k);
    for (auto &i : G[k]) {
        if (!vis[i]) {
            dfs(i, dep + 1);
        }
    }
}

int main() {
    int n;
    cin >> n;
    vis.assign(n, 0);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, 0);

    int m[3] = {n / 3, (n + 2) / 3, (n + 1) / 3};
    int ans[n];
    if (min(a.size(), b.size()) <= m[0]) {
        if (a.size() < b.size()) {
            for (auto i : a) {
                ans[i] = 0;
                m[0]--;
            }
            for (int i = 0; i < b.size(); i++) {
                if (i < m[0]) ans[b[i]] = 0;
                else if (i < m[0] + m[1]) ans[b[i]] = 1;
                else ans[b[i]] = 2;
            }
        }
        else {
            for (auto i : b) {
                ans[i] = 0;
                m[0]--;
            }
            for (int i = 0; i < a.size(); i++) {
                if (i < m[0]) ans[a[i]] = 0;
                else if (i < m[0] + m[1]) ans[a[i]] = 1;
                else ans[a[i]] = 2;
            }
        }
    }
    else {
        for (int i = 0; i < a.size(); i++) {
            if (i < m[1]) ans[a[i]] = 1;
            else ans[a[i]] = 0;
        }
        for (int i = 0; i < b.size(); i++) {
            if (i < m[2]) ans[b[i]] = 2;
            else ans[b[i]] = 0;
        }
    }
    int p[3] = {3, 1, 2};
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << p[ans[i]];
        p[ans[i]] += 3;
    }
    cout << endl;
    

}

Measured memory_bytes: 18676
// Smart Calculator
import java.util.*;

public class Main {
	static int pos;
	static String formura;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		for (int i = 0; i < n; i++) {
			formura = scanner.next();
			pos = 0;
			int result = expression();
			System.out.println(result);
		}
		scanner.close();
	}

	static int expression() {
		int result = 0;
		int a = term();
		result += a;
		while (pos < formura.length()
				&& (formura.charAt(pos) == '+' || formura.charAt(pos) == '-')) {
			char op = formura.charAt(pos);
			pos++;
			int b = term();
			if (op == '+')
				result += b;
			else
				result -= b;
		}
		return result;
	}

	static int term() {
		int result = 0;
		int a = factor();
		result += a;
		while (pos < formura.length()
				&& (formura.charAt(pos) == '*' || formura.charAt(pos) == '/')) {
			char op = formura.charAt(pos);
			pos++;
			int b = factor();
			if (op == '*')
				result *= b;
			else
				result /= b;
		}
		return result;
	}

	static int factor() {
		int result = 0;
		if (formura.charAt(pos) == '(') {
			pos++;
			result = expression();
			pos++;
		} else {
			while (pos < formura.length()
					&& Character.isDigit(formura.charAt(pos))) {
				result *= 10;
				result += Character.getNumericValue(formura.charAt(pos));
				pos++;
			}
		}
		return result;
	}
}

Measured memory_bytes: 17176
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, K;
    cin >> N >> K;
    set<ll> snuke;
    Rep (i, K) {
        ll d;
        cin >> d;
        Rep (j, d) {
            ll a;
            cin >> a;
            snuke.insert(a);
        }
    }

    cout << N - snuke.size() << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	string S;
	cin >> S;
	int n = S.size();
	ll ans = 0;
	for (int bit = 0; bit < (1 << (n - 1)); bit++) {
		ll sum = 0;
		ll now = S[0] - '0';
		for (int i = 0; i < n - 1; i++) {
			if (bit&(1 << i)) {
				sum += now;
				now = S[i + 1] - '0';
			}
			else {
				now *= 10;
				now += S[i + 1] - '0';
			}
		}
		sum += now;
		ans += sum;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
static const int INFTY = (1<<20);
static const int MAX = 100;
static const int WHITE = 0;
static const int BLACK = 1;

int main() {
  int n;
  int M[110][110];
  int d[110];
  int visited[110];
  std::cin >> n;
  for(int i=0; i<n; ++i) {
    for(int j=0; j<n; ++j) {
      M[i][j] = INFTY;
    }
  }

  for(int i=0; i<n; ++i) {
    d[i] = INFTY;
    visited[i] = WHITE;
  }

  for(int i=0; i<n; ++i) {
    int u, k;
    std::cin >> u >> k;
    for(int j=0; j<k; ++j) {
      int c, v;
      std::cin >> v >> c;
      M[u][v] = c;
    }
  }

  d[0] = 0;

  while(true) {
    int minicost = INFTY;
    int u;

    for(int i=0; i<n; ++i) {
      if(visited[i] == WHITE && d[i] < minicost) {
        minicost = d[i];
        u = i;
      }
    }

    if(minicost == INFTY) break;
    visited[u] = BLACK;

    for(int v=0; v<n; ++v) {
      if(d[u] + M[u][v] < d[v]) {
        d[v] = d[u] + M[u][v];
      }
    }
  }

  for(int i=0; i<n; ++i) {
    std::cout << i << " " << d[i] << std::endl;
  }


}


Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<map>
using namespace std;

int main(){
    string s1,s2,s3;
    int a,b;
    cin>>s1>>s2>>a>>b>>s3;
    if (s1==s3){
    a--;
    }else{
    b--;
    }
    cout<<a<<' '<<b<<endl;
    
    return 0;


}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

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

  if(a==b)out("Draw")
  else {
    if(a==1){out("Alice");return 0;}
    else if(b==1){out("Bob");return 0;}

    if(a>b)out("Alice")
    else out("Bob")
  }

  return 0;
}


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

#define MOD 100000
int N, M, S;
int dp[2][2001][2001];
int T[2001][2001];

int main() {
  while (cin >> N >> M >> S) {
    if (N == 0 && M == 0 && S == 0) break;
    for (int j=1; j<=M; j++) {
      for (int k=1; k<=S; k++) {
        dp[0][j][k] = 0;
      }
    }

    N *= N;
    S -= N*(N+1) / 2;
    M = min(M - N, S);
    for (int i=0; i<=M; i++) dp[0][i][i] = 1;

    for (int i=0; i<N-1; i++) {
      int _ = i%2;
      for (int j=0; j<=M; j++) {
        for (int k=0; k<=S; k++) {
          dp[_^1][j][k] = 0;
          T[j][k] = 0;
        }
      }
      for (int j=0; j<=M; j++) {
        for (int k=0; k<=S; k++) {
          if (j + k <= S) {
            T[j][j+k] = (T[j][j+k] + dp[_][j][k]) % MOD;
          }
        }
      }
      for (int j=0; j<=M; j++) {
        for (int k=0; k<=S; k++) {
          if (j > 0 && k > 0) T[j][k] = (T[j][k] + T[j-1][k-1]) % MOD;
          dp[_^1][j][k] = (dp[_^1][j][k] + T[j][k]) % MOD;
        }
      }
    }
    int m = 0;
    for (int i=0; i<=M; i++) m = (m + dp[(N-1)%2][i][S]) % MOD;
    cout << m << "\n";
  }
  return 0;
}

Measured memory_bytes: 46360
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

  sort(a.begin(), a.end());

  vector<bool> memo(a[n-1], true);

  int count = 0;

  for(int i = 0; i < n; i++){
    if(memo[a[i]] == false)
      continue;
    
    if(i != n - 1 && a[i] == a[i + 1]){
      for(int j = 1; j * a[i] <= a[n - 1]; j++)
	memo[j * a[i]] = false;
      continue;
    }
    else{
      count++;
      for(int j = 1; j * a[i] <= a[n - 1]; j++)
	memo[j * a[i]] = false;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  REP(i, b+1){
    if((a*i) % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int t[30];
	for(int i=0;i<30;i++)t[i]=i+1;
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int c,d;
		scanf("%d,%d",&c,&d);
		int s=t[c-1];
		t[c-1]=t[d-1];
		t[d-1]=s;
	}
	for(int i=0;i<a;i++)printf("%d\n",t[i]);
}

Measured memory_bytes: 0