akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    ll ans = 1;
    ll mod = 1000000007;
    ll r = 0, b = 0, g = 0;
    rep(i,n) {
        ll num; cin >> num;

        if(r==num && b!=num && g!=num) r++;
        else if(r!=num && b==num && g!=num) b++;
        else if(r!=num && b!=num && g==num) g++;
        else if(r!=num && b==num && g==num) {
            ans*=2;
            ans%=mod;
            b++;
        }
        else if(r==num && b!=num && g==num) {
            ans*=2;
            ans%=mod;
            g++;
        }
        else if(r==num && b==num && g!=num) {
            ans*=2;
            ans%=mod;
            r++;
        }
        else if(r!=num && b!=num && g!=num) ans*=0;
        else {
            ans*=3;
            ans%=mod;
            r++;
        }
    }
    cout << ans%mod << endl;


    return 0;
}

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

int	main() {
	int N, K;
	cin >>N >>K;
	vector<int> A(N);
	int AA=0;
	for (int i=0; i<N; i++) {
		cin >>A.at(i);
		AA = max(AA, A.at(i));
	}
	if (1==N) {
		if (K==AA) {
			cout <<"POSSIBLE" <<endl;
			return 0;
		} else {
			cout <<"IMPOSSIBLE" <<endl;
			return 0;
		}
	}
	if (AA<K) {
		cout <<"IMPOSSIBLE" <<endl;
		return 0;
	}
	AA -=K;
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	if (1<A.size()) {
		for (int i=1; i<A.size();i++)
			A.at(i-1)=A.at(i)-A.at(i-1);
		A.erase(A.end()-1, A.end());
		sort(A.begin(), A.end());
		A.erase(unique(A.begin(), A.end()), A.end());
	}
	while (A.size()>1) {
		for (int i=A.size()-1; i>0;i--)
			A.at(i)=A.at(i)-A.at(i-1);
		sort(A.begin(), A.end());
		A.erase(unique(A.begin(), A.end()), A.end());
		if (1==A.at(0))
			break;
	}
	if (0==AA%A.at(0))
		cout <<"POSSIBLE" <<endl;
	else
		cout <<"IMPOSSIBLE" <<endl;
	return 0;
}


Measured memory_bytes: 640
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        List<Job> jobs = new ArrayList<Job>();
        for(int i =0;i<n;i++){
            int t= in.nextInt();
            int p = in.nextInt();
            jobs.add(new Job(t,p));
        }
        Collections.sort(jobs);
        String ans ="Yes";
        int s =0;
        for(Job v : jobs){
            s+=v.time;
            if(s>v.period) {
                ans="No";
                break;
            }
        }
        out.print(ans);
        out.close();
    }
    static public class Job implements Comparable<Job>{
        int time;
        int period;
        public Job(int time, int period){
            this.time = time;
            this.period=period;
        }
        public String toString(){
            return "["+time+","+period+"]";
        }
        public int compareTo(Job o){
            int compare = Integer.compare(period,o.period);
            if (compare==0){
                compare=Integer.compare(time,o.time);
            }
            return compare;

        }
    }


}


Measured memory_bytes: 102232
#include<stdio.h>
int main()
{
    int H,W;
    int h,w;
    // スペース区切りの整数の入力
    scanf("%d %d",&H,&W);
    // 文字列の入力
    scanf("%d %d",&h,&w);
    // 出力
    printf("%d",H*W - h*W - H*w + h*w);
    return 0;
}

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

int d[2], f[100], n;

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cin >> n;
    for (int i = 0; i < n; f[i++] = d[0] == d[1])
        for (int j = 0; j < 2; ++j)
            cin >> d[j];
    for (int i = 0, j = 1, k = 2; k < n; i = j, j = k++)
        if (f[i] and f[j] and f[k])
            cout << "Yes", exit(0);
    cout << "No";
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1005;
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<3;i++) if(a[i]==b[i]) ans++;
	cout<<ans<<endl;
    return 0;
}

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

#define V vector<int>
#define VV(v, n, m) vector<V> v(n, V(m));
#define _4(i, n) for(int i = 0; i < n; i++)
#define g_arr(arr, n) _4(i, n) cin >> arr[i];
#define p_vec(vec) _4(i, (int)vec.size()) cout << vec[i] << ' '; cout << endl;

typedef long long ll;

using namespace std;

int getMax();

V a, b, c;
int n;

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n;

    a.resize(n);
    b.resize(n);
    c.resize(n);

    _4(i, n)
        cin >> a[i] >> b[i] >> c[i];

    cout << getMax();

    return 0;
}

int getMax() {
    VV(dp, n + 1, 3);

    dp[0] = {0, 0, 0};

    for(int i = 1; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i - 1];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i - 1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i - 1];
    }

    return max(
            max(dp[n][0], dp[n][1]),
            dp[n][2]
        );
}


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

int main() {

  int N; 
  cin >> N;
  int ANS;
  if(N % 2 == 0){
    ANS = N / 2;
  }
  if(N % 2 == 1){ 
    ANS = N / 2 + 1;
  }
  cout << ANS << endl;

}


Measured memory_bytes: 256
//const config = { stdin: 'tmp', newline: '\r\n' }; // win
const config = { stdin: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.stdin, 'ascii').trim()
	.split(config.newline).map(function (line) {
		return line.split(' ');
});
str = line.shift()[0];
line.shift();
res = line.reduce(function (prev, cur) {
	var op = cur[0], a = parseInt(cur[1]), bp1 = parseInt(cur[2]) + 1, ary;
	if (op === 'print') {
		console.log(prev.slice(a, bp1));
		return prev;
	} else if (op === 'reverse') {
		ary = prev.slice(a, bp1).split('');
		ary.reverse();
		return prev.slice(0, a) + ary.join('') + prev.slice(bp1);
	} else {
		return prev.slice(0, a) + cur[3] + prev.slice(bp1);
	}
}, str);

Measured memory_bytes: 16516
#include <cstdio>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a <= 0 && 0 <= b) {
        puts("Zero");
    } else {
        if (b < 0 && (b - a) % 2 == 0) {
            puts("Negative");
        } else {
            puts("Positive");
        }
    }
}

Measured memory_bytes: 128
#![allow(dead_code)]
use std::io;

fn main() {
    solve_d();
}

fn solve_d() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();

    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<i64> = x.trim()
        .split(' ')
        .map(|s| s.parse::<i64>().unwrap())
        .collect();

    let mut max = -1 * 1_000_000_i64;
    let mut min = 1_000_000_i64;
    let mut sum = 0;

    for i in v {
        if max < i {
            max = i;
        }
        if i < min {
            min = i;
        }
        sum += i;
    }
    println!("{} {} {}", min, max, sum);
}




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

int main() {
  int a,b,c,x,y,ans;
  cin >> a >> b >> c >> x >> y;
  ans = max(x,y)*2*c;
  int d;
  if(x >= y) d = y*2*c+(x-y)*a;
  else d = x*2*c+(y-x)*b;
  ans = min(ans,d);
  ans = min(ans,x*a+y*b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstring>

typedef std::pair<int, int> P;
int dx[] = { 0, 1, 0, -1 }, dy[] = { 1, 0, -1, 0 };

int w, h, ans = 0;
char map[101][101];
bool used[101][101];

void bfs(int sx, int sy){
	std::queue<P> que;
	que.push(P(sx, sy));

	while (!que.empty()){
		P p = que.front();
		que.pop();

		for (int i = 0; i < 4; i++){
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx >= 0 && nx < w && ny >= 0 && ny < h && map[ny][nx] == map[sy][sx] && !used[ny][nx]){
				used[ny][nx] = true;
				que.push(P(nx, ny));
			}
		}
	}
}

int main(){
	while (std::cin >> h >> w, h || w){
		memset(used, 0, sizeof(used));
		ans = 0;

		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				std::cin >> map[i][j];
			}
		}

		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (!used[i][j]){
					ans++;
					bfs(j, i);
					used[i][j] = true;
				}
			}
		}

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

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

int main() {
    int ans = 0;
    int N,Y;
    cin >> N >> Y;

    int a10000=-1,b5000=-1,c1000=-1;

    for(int i=0;i < N+1;i++){
        for(int j=0; i+j<N+1;j++){
            int k = N-i-j;
            int mny=10000*i+5000*j+1000*k;
            if(mny == Y){
                a10000=i;
                b5000=j;
                c1000=k;
            }
        }
    }


    std::cout << a10000 <<" " <<b5000<<" "<<c1000 << std::endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

/*
   AtCoder contest code
   coder : yoichidon
 */
import java.util.*;
import java.io.*;

public class Main {
    public static long sum(long[] array){
        long ans = 0;
        for(long e:array) ans+=e;
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];
        for(int n=0;n<N;n++) A[n]=sc.nextLong();
        for(int n=0;n<N;n++) B[n]=sc.nextLong();

        if(sum(A)<sum(B)){
            System.out.println("-1");
            return;
        }
        int notEnoughStudy = 0;
        long extraStudy = 0;
        PriorityQueue<Long> margin = new PriorityQueue<>(Comparator.reverseOrder());
        for(int n=0; n<N; n++){
            if(A[n]<B[n]){
                notEnoughStudy++;
                extraStudy += (B[n]-A[n]);
            }else{
                margin.add(A[n]-B[n]);
            }
        }
        int decrease = 0;
        while(extraStudy>0){
            extraStudy -= margin.poll();
            decrease++;
        }
        System.out.println(notEnoughStudy+decrease);


    }
}


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

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

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

  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);

  vector<ll> ans(n);
  ll sum=0;

  for(int i=0; i<n; i++){
    sum += (pow(-1, i))*a.at(i);
  }

  rep(i, n){
    ans.at(i) = sum;
    sum = sum * -1;
    sum += a.at(i)*2;
  }

  rep(i, n) cout << ans.at(i) << " ";

}

Measured memory_bytes: 2944
//
// ALDS1_1 - C Prime Numbers
// A prime number is a natural number which has exactly two distinct natural number divisors: 
// 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
//
// Write a program which reads a list of N integers and prints the number of prime numbers in the list.
//
#include <iostream>
#include <cmath>
using namespace std;

void read(int& size, int **ppArray);
void checkPrimeNumbers(size_t size, const int* pArray, int& count);
void write(const int count);

int main()
{
    int size = 0, ret = 0;
    int* pArray = NULL;

    read(size, &pArray);
    checkPrimeNumbers(size, pArray, ret);
    write(ret);

    delete pArray;
}

void read(int& size, int **ppArray)
{
    if (NULL == ppArray || NULL != *ppArray)
        return;

    cin >> size;
    if (10000 < size)
        return;

    *ppArray = new int[size];
    for (int i = 0; i < size; i++) {
        cin >> *(*ppArray + i);
    }
}

void checkPrimeNumbers(size_t size, const int* pArray, int& count)
{
    if (NULL == pArray)
        return;

    for (int i = 0; i < size; i++) {
        bool flag = true;
        int value = *(pArray + i);
        if (2 > value)
            continue;
        if (2 == value) {
            count++;
            continue;
        }
        if (0 == value % 2)
            continue;
        for (int j = 3; j <= (int)sqrt(value); j += 2) {
            if (0 == value % j) {
                flag = false;
                break;
            }
        }
        if (true == flag)
            count++;
    }
}

void write(const int count)
{
    cout << count << endl;
}

Measured memory_bytes: 3124
N, M, X, Y = map(int, (input().split()))
x = list(map(int, (input().split())))
y = list(map(int, (input().split())))

max_x = max(max(x), X)
min_y = min(min(y), Y)

print("No War" if min_y - max_x > 0 else "War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n;
  cin >> n;
  int a = n%10;
  if (a == 2 || a == 4 || a == 5 || a==7 ||  a == 9) {
    puts("hon");
  } else if (a == 0 || a == 1 || a == 6 || a == 8) {
    puts("pon");
  } else if (a == 3) {
    puts("bon");
  }

  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    if(s.length()&1){cout<<"No";return 0;}
    for(int i=0 ; i<s.length() ; i+=2)
    {
        string str;
        str+=s[i];
        str+=s[i+1];
        if(str!="hi") {cout << "No";return 0;}
    }
    cout << "Yes";
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		StringBuilder sb = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] map = new char[h][w];
		for (int i = 0; i < h; i++) {
			map[i] = sc.next().toCharArray();
		}
		int row[][] = new int[h][w];
		int col[][] = new int[h][w];
		int cnt = 0;
		int s = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cnt = 0;
				if (map[i][j] == '.') {
					cnt++;
					s = j;
					j++;
					while (true) {
						if (j >= w || map[i][j] == '#') {
							break;
						} else if (map[i][j] == '.') {

							cnt++;
						}
						j++;
					}
					for (int k = s; k < j; k++) {
						row[i][k] = cnt;
					}
				}
			}
		}

		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				cnt = 0;
				if (map[j][i] == '.') {
					cnt++;
					s = j;
					j++;
					while (true) {
						if (j >= h || map[j][i] == '#') {
							break;
						} else if (map[j][i] == '.') {
							cnt++;
						}
						j++;
					}
					for (int k = s; k < j; k++) {
						col[k][i] = cnt;
					}
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				ans = Math.max(ans, col[i][j] + row[i][j] - 1);
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 108692
#include <cstdio>
using namespace std;
 
struct Node {
    Node *parent;
    Node *left;
    Node *right;
    int key;
};
 
Node *NIL = NULL;
 
void preorder(Node *v) {
    if (v == NIL) return;
    printf(" %d", v->key);
    preorder(v->left);
    preorder(v->right);
}
 
void inorder(Node* v) {
    if (v == NIL) return;
    inorder(v->left);
    printf(" %d", v->key);
    inorder(v->right);
}
 
void postorder(Node* v) {
    if (v == NIL) return;
    postorder(v->left);
    postorder(v->right);
    printf(" %d", v->key);
}
 
void insert(Node* &T, Node *z) {
    Node *y = NIL;
    Node *x = T;
    while (x != NIL) {
        y = x;
        if (z->key < x->key)
            x = x->left;
        else
            x = x->right;
    }
    z->parent = y;
 
    if (y == NIL)
        T = z;
    else if (z->key < y->key)
        y->left = z;
    else
        y->right = z;
}
 
 
int main()
{
    int n;
    scanf("%d", &n);
 
    Node *T = NIL;
    for (int i = 0; i < n; ++i) {
        char cmd[20];
        int v;
        scanf("%s %d", cmd, &v);
        if (cmd[0] == 'i') {
            Node *p = new Node;
            p->key = v;
            insert(T, p);
        } else if (cmd[0] == 'p') {
            inorder(T);
            printf("\n");
            preorder(T);
            printf("\n");
        }
    }
 
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  vector<int> E(N);
  for (int i = 0; i < N; i++) {
    cin >> D[i] >> E[i];
  }

  int count = 0;
  for (int i = 0; i < N; i++) {
    if (D[i] == E[i]) {
      count++;
    } else {
      count = 0;
    }
    if (count >= 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define all(v) (v).begin(), (v).end()

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

    vector<int> dp(n+1);
    vector<int> cs(m+1);
    rep(i, m){
        cin >> cs[i];
    }
    cs[m] = 0;
    int csi = 0;

    dp[0] = 1;
    for(int i=1; i<=n; i++){
        if(cs[csi] == i){
            csi++;
            dp[i] = 0;
            continue;
        }
        dp[i] = ((i!=1?dp[i-2]:0) + dp[i-1])%1000000007;
    }

    cout << dp[n];

}

Measured memory_bytes: 1024
import sys
def input():
    return sys.stdin.readline()[:-1]
S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
L = S.split(', ')
N = int(input())
print(L[N-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int D; cin >> D;
    vector<int> c(27);
    for (int i = 1; i < 27; i++) {
        cin >> c[i];
    }

    vector<vector<int>> s(D+1, vector<int> (27));
    for (int i = 1; i < D+1; i++) {
        for (int j = 1; j < 27; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D+1);

    ll score = 0;
    vector<int> last(27, 0);
    int M;
    int MJ;
    for (int i = 1; i < D+1; i++) {
        M = 0;
        for (int j = 1; j < 27; j++) {
            if(s[i][j] + c[j] * (i-last[j]) > M){
                M = s[i][j] + c[j] * (i-last[j]);    
                MJ = j;
            }
        }
        t[i] = MJ;
        score += s[i][MJ];
        last[MJ] = i;
        for (int j = 1; j < 27; j++) {
            score -= c[j] * (i - last[j]);
        }
    }
    
    //ここまでが貪欲解の導出
    //ここから微調整

    // そのコンテストが開催された日の集合
    vector<set<int>> day(27, set<int> ());
    for (int i = 1; i < D+1; i++) {
        day[t[i]].insert(i);
    }
    for (int i = 1; i < 27; i++) {
        day[i].insert(0);
        day[i].insert(D+1);
    }

    //更新作業
    //i回目の更新では、i%D日目の開催をt[i%D]+7i%26に変更し、差分が正だったら更新
    int CNT = 5000000;
    int dd, qq;
    int d1, d2;
    auto itr1 = day[1].lower_bound(0);
    dd = 1;
    ll diff;
    for (int i = 0; i < CNT; i++) {
        diff = 0;
        
        qq = rand() % 26 + 1;

        diff += s[dd][qq];
        diff -= s[dd][t[dd]];
        
        itr1 = day[qq].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        diff += c[qq] * (dd - d1) * (d2 - dd);

        itr1 = day[t[dd]].lower_bound(dd);
        itr1++;
        d2 = *itr1;
        itr1--;
        itr1--;
        d1 = *itr1;
        diff -= c[t[dd]] * (dd - d1) * (d2 - dd);

        //差分が正なら更新
        if(diff > 0){
            // tとsetを更新
            t[dd] = qq;
            day[t[dd]].erase(dd);
            day[qq].insert(dd);
        }

        //ddを更新
        dd++;
        if(dd == D+1) dd = 1;

    }
    for (int i = 1; i < D+1; i++) {
        printf("%d\n", t[i]);
    }

}

Measured memory_bytes: 3776
l = list(map(int,input().split()))
N = l[0]
D = l[1]
count = 0
for i in range(N):
    l1 = list(map(int,input().split()))
    x = l1[0]
    y = l1[1]
    d = ((x**2 + y**2)**(.5))
    if D >= d:
        count+=1
print(count)



Measured memory_bytes: 9636
import std;

auto input()
{
    return readln().chomp();
}

alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long n;
    scan(n);
    auto T = new long[](n);
    foreach (i; 0 .. n)
    {
        long t;
        scan(t);
        T[i] = t;
    }
    // writeln(T);
    long ans_gcd;
    ans_gcd = T[0];
    foreach (i; 0 .. n)
    {
        ans_gcd = gcd(ans_gcd, T[i]);
    }
    // writeln(ans_gcd);
    long ans_lcm;
    ans_lcm = T[0];
    foreach (i; 0 .. n)
    {
        ans_lcm = ans_lcm * (T[i] / gcd(ans_lcm, T[i]));
    }
    writeln(ans_lcm);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

auto binary_search(long key, long[] l)
{
    long left = 0; //lの左端
    long right = l.length - 1; //lの右端
    while (right >= left)
    {
        long mid = left + (right - left) / 2; //区間の真ん中
        if (l[mid] == key)
        {
            return mid;
        }
        else if (l[mid] > key)
        {
            right = mid - 1;
        }
        else if (l[mid] < key)
        {
            left = mid + 1;
        }

    }
    return -1;
}

// auto a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910];
// auto a = aryread();
// writeln(a);
// long len_a = a.length;
// writeln(len_a);
// long ans;
// ans = binary_search(51, a);
// writeln(ans);


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    string X = "ABC";
    int ans = 0;
    REP(i,N-2){
        if(S.substr(i,3) == X) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"
#define ALL(x) (x).begin(),(x).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,t,ci,ti;
    int mincost = 1001;
    cin >> n >> t;
    REP(i,n){
        cin >> ci >> ti;
        if(ti <= t) mincost = min(mincost, ci);
    }
    
    if(mincost <= 1000) cout << mincost << "\n";
    else cout << "TLE\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

const int M=85;
const int MM=81*81+5;

int dp[M][M][MM];
int a[M][M],b[M][M];

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&b[i][j]);
	//memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			int diff=abs(a[i][j]-b[i][j]);
			if(i==1&&j==1)
			{
				dp[i][j][diff]=1;
				continue;
			}
			if(i!=1)
			{
				for(int k=0;k<MM;k++)
				{
					if(!dp[i-1][j][k]) continue;
					if(k+diff<MM)
						dp[i][j][k+diff]=1;
					dp[i][j][abs(k-diff)]=1;
				}
			}
			if(j!=1)
			{
				for(int k=0;k<MM;k++)
				{
					if(!dp[i][j-1][k]) continue;
					if(k+diff<MM)
						dp[i][j][k+diff]=1;
					dp[i][j][abs(k-diff)]=1;
				}
			}
		}
	int ans=-1;
	for(int i=0;i<MM;i++)
	{
		if(dp[n][m][i]) 
		{
			ans=i;
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

template <class T> inline bool chmax(T& a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  vector<int> as1(N + 1, 0);
  vector<int> as2(N + 1, 0);
  int a;
  for(int i = 1; i <= N; ++i) {
    cin >> a;
    as1[i] = as1[i - 1] + a;
  }
  for(int i = 1; i <= N; ++i) {
    cin >> a;
    as2[i] = as2[i - 1] + a;
  }
  int ans = 0;
  for(int i = 1; i <= N; ++i) {
    chmax(ans, as1[i] + as2[N] - as2[i - 1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
string s;
int cc;

int main(void)
{
	int i; cin>>s;
	for(i=0 ; i<s.length()-1 ; i++) if(s[i]!=s[i+1]) cc++;
	cout<<cc; return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
int N;
cin>>N;
cout<<N/3<<endl;
 return 0;
}
/*


*/

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb emplace_back
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef pair<int,int> pi;
vector<pi> solve(vector<int> s){
	R int n=s.size();
	if(n==4){
		vector<pi>ans(4);
		ans[0]=pi(1,0),ans[1]=pi(1,1),ans[2]=pi(0,1),ans[3]=pi(0,0);
		return ans;
	}
	R int pos=-1;
	fp(i,0,n-1)if(s[i]==90&&s[(i+1)%n]==270){pos=i;break;}
	vector<int>st;
	fp(i,pos-1,pos-1+n-1)if(i!=pos&&i!=pos+1)st.pb(s[(i+n)%n]);
	vector<pi>pans=solve(st),ans(n);
	fp(i,0,n-3){
		R pi p=pans[i];
		if(!i||p.fi>pans[0].fi)++p.fi;
		if(p.se>pans[0].se)++p.se;
		R int to=(!i?0:i+2);
		ans[to]=p;
	}
	ans[1]=pi(ans[0].fi,ans[0].se+1),
	ans[2]=pi(ans[1].fi-1,ans[1].se);
	rotate(ans.begin(),ans.begin()+(n-pos+1)%n,ans.end());
	if(ans[0].fi!=ans[1].fi){
		fp(i,0,n-1)swap(ans[i].fi,ans[i].se),ans[i].fi*=-1;
	}
	if(ans[0].se>ans[1].se){
		fp(i,0,n-1)ans[i].fi*=-1,ans[i].se*=-1;
	}
	return ans;
}
int main(){
//	freopen("testdata.in","r",stdin);
	int n,sum=0;
	scanf("%d",&n);
	vector<int>p(n);
	fp(i,0,n-1)scanf("%d",&p[i]),sum+=(p[i]==90?1:-1);
	if(sum!=4)return puts("-1"),0;
	vector<pi>ans=solve(p);
	fp(i,0,n-1)ans[i].fi+=5e8,ans[i].se+=5e8;
	fp(i,0,n-1)printf("%d %d\n",ans[i].fi,ans[i].se);
	return 0;
}

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

const ll INF = 1LL << 60;

long double N;
ll A, B, C, D, E;
int main() {
    cin >> N >> A >> B >> C >> D >> E;

    long double min_val = min({A, B, C, D, E});

    printf("%lld\n", (ll)ceil((long double) N / min_val) + 4);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e5+10;
vector<int>g[maxn],vis(maxn);
int n,m;
void run(int u,list<int>&path){
	vis[u] = 1;
	path.push_back(u);
	for(auto v:g[u]){
		if( !vis[v]){
			run(v,path);
			return;
		}
	}
}
	
int32_t main(){
	IOS
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	list<int> l1 , l2 ;
	run(1,l1);
	run(1,l2);
	int prv = 0;
	cout << ( (int)l1.size() + (int)l2.size() - 1 ) << endl;
	for(auto it=l1.rbegin();it!=l1.rend();it++){
		if( *it != prv ){
			cout << *it <<" ";
			prv = *it ;
		}
	}
	for(auto it=l2.begin();it!=l2.end();it++){
		if( *it != prv ){
			cout << *it <<" ";
			prv = *it;
		}
	}
	
}
/*
 * long long or int?
 * index out of bound?
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 12584
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n = Integer.parseInt(sc.next());int p = 0;String s = "";
		String[] a = new String[n];
		for(int i = 0; i < n; i++) {
			s = sc.next();p = 1100 - Integer.parseInt(sc.next());
			a[i] = s + "_" + String.valueOf(p) + "_" + String.valueOf(i+1);
		}
		Arrays.parallelSort(a);
		for(String a_i : a) {
			System.out.println(a_i.split("_")[2]);
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std; 
int a,b,k,i;
string s; 
int main()
{
  cin >> a >> b >> s;
  for(i=0;i<s.size();i++){
    if(i!=a&&(48>s[i]||s[i]>57))k=1;
  }
  if(s.size()==a+b+1&&s[a]==45&&k!=1)printf("Yes");
  else printf("No");
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int H =scane.nextInt();
		int W =scane.nextInt();;

		do {

			for(int i =0; i<H; i++){
				for (int j = 0; j < W; j++) {

					if(i%2 ==0){
						if(j%2 ==0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}

					}else{
						if(j%2 !=0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
				}
				System.out.println();
			}
			System.out.println();

			H = scane.nextInt();

			W= scane.nextInt();


		} while (H !=0 && W !=0);
	}
}

Measured memory_bytes: 34768
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    a = list(map(int,ipti().split()))
    under = 0

    for ele in a:
        under += 1 / ele

    print(1/under)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N = int(input())
r = 0
b = 0
for _ in range(N):
    a = int(input())
    a += b
#    print(a-b,b,a//2)
    r += a//2
    if a == 1 and b == 1:
        b = 0
    elif a%2:
        b = 1
    else:
        b = 0
print(r)


Measured memory_bytes: 43496
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
//orz kczno1    POD only
template<typename T>
struct vec{T *a;int n;void clear(){n=0;}
void pb(const T &x){if((n&-n)==n)a=(T*)realloc(a,(n*2)*sizeof(T));a[n++]=x;}
inline T* begin(){return a;}inline T* end() {return a+n;}};
inline ll sq(ll x)
{
	if(x<0) return -1;
	ll w=sqrt(x)-1;
	for(ll i=w;i<=w+2;++i)
		if(i>=0&&x==i*i) return i;
	return -1;
}
int ps[SZ],pn=0; bool np[SZ];
ll op(ll x)
{
	ll s=1;
	for(int i=1;ps[i]*(ll)ps[i]*ps[i]<=x;++i)
	{
		int c=0; while(x%ps[i]==0) x/=ps[i],++c;
		c=(3-c)%3; while(c--) s=s*ps[i];
	}
	if(x==1) return s; //1
	ll p=sq(x); if(p>0) return s*p; //p^2
	return s*x*x; //pq or p
}
ll fj(ll x)
{
	for(int i=1;ps[i]*(ll)ps[i]*ps[i]<=x;++i)
	{
		ll s=ps[i]*(ll)ps[i]*ps[i];
		while(x%s==0) x/=s;
	}
	return x;
}
map<ll,int> cnt;
set<ll> co;
int n; ll x;
map<ll,ll> ops;
int main()
{
	for(int i=2;i<SZ;++i) if(!np[i])
	{
		ps[++pn]=i;
		for(int j=i+i;j<SZ;j+=i) np[j]=1;
	}
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&x);
		x=fj(x); if(x==1) {ans=1; continue;}
		ll ox=op(x); ops[x]=ox; ops[ox]=x;
		++cnt[x]; co.insert(min(x,ox));
	}
	for(auto j:co)
		ans+=max(cnt[j],cnt[ops[j]]);
	printf("%d\n",ans);
}


Measured memory_bytes: 30848
import java.util.Locale;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in).useLocale(Locale.ENGLISH);
        int count = scanner.nextInt();

        int onesAll = 0;
        int twosAll = 0;
        int threesAll = 0;
        for (int i = 0; i < count; ++i) {
            int value = scanner.nextInt();
            switch (value) {
                case 1:
                    onesAll++;
                    break;
                case 2:
                    twosAll++;
                    break;
                case 3:
                    threesAll++;
                    break;
            }
        }

        double[][][] s = new double[count + 1][count + 1][count + 1];

        for (int threes = 0; threes <= count; ++threes) {
            for (int twos = 0; twos <= count - threes; ++twos) {
                for (int ones = 0; ones <= count - twos - threes; ++ones) {
                    int countNonZero = ones + twos + threes;
                    double steps = countNonZero == 0 ? 0.0 : 1.0 * count / countNonZero;
                    if (ones > 0) {
                        steps += s[ones - 1][twos][threes] * ones / countNonZero;
                    }

                    if (twos > 0) {
                        steps += s[ones + 1][twos - 1][threes] * twos / countNonZero;
                    }

                    if (threes > 0) {
                        steps += s[ones][twos + 1][threes - 1] * threes / countNonZero;
                    }

                    s[ones][twos][threes] = steps;
                }
            }
        }

        System.out.println(s[onesAll][twosAll][threesAll]);
    }
}


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

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;

int main(){

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

	int n, t;
	cin >> n >> t;

	int aux;
	set<int> seti;
	for(int i = 0; i < t; i++){
		int siz;
		cin >> siz;
		for(int j = 0; j < siz; j++){
			cin >> aux;
			seti.insert(aux);
		}
	}

	cout << n - seti.size() << endl;

	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <set>
#include <memory.h>
using namespace std;

int main(){
    int n, t, i, j, sum;
    cin >> n;
    
    vector<int> v, u;
    
    for(i = 0; i < n; i++){
        cin >> t;
        v.push_back(t);
        u.push_back(t);
    }
    
    int m, p, x;
    cin >> m;
    
    for(i = 0; i < m; i++){
        sum = 0;
        for(j = 0; j < n; j++){
            u[j] = v[j];
        }
        cin >> p;
        cin >> x;
        
        u[p-1] = x;
        
        for(j = 0; j < n; j++){
            sum += u[j];
        }
        
        printf("%d\n", sum);
    }
}

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

using namespace std;
using ll = long long;

int main() {
    int n;
    ll d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> monsters(n);
    for (int i = 0; i < n; i++) {
        cin >> monsters[i].first >> monsters[i].second;
        monsters[i].second = (monsters[i].second + a - 1) / a;
    }
    sort(monsters.begin(), monsters.end());
    ll ans = 0;
    queue<pair<ll, ll>> q;
    ll tot = 0;
    for (auto monster: monsters) {
        ll x = monster.first;
        ll h = monster.second;
        while (!q.empty() && q.front().first < x) {
            tot -= q.front().second;
            q.pop();
        }
        h -= tot;
        if (h > 0) {
            ans += h;
            tot += h;
            q.emplace(make_pair(x + 2 * d, h));
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back

const int N=2e5+5,D=1e9+7;
ll mi(ll x,int y=D-2)
{
	ll ans=1;
	while(y)
	{
		if(y&1)ans=ans*x%D;
		x=x*x%D;y>>=1;
	}
	return ans;
}
vector<int>lk[N];
bool vis[N];

int du[N],fa[N],sz[N];
int q[N],tail,nq[N];
inline bool link_fa(int x)
{
	return x<fa[fa[x]];
}
ll solve(int rt)
{
	tail=1;
	q[1]=rt;
	vis[rt]=1;
	rep(head,1,tail)
	{
		int x=q[head];
		du[x]=0;sz[x]=1;fa[x]=0;
		for(auto y:lk[x])
		if(!vis[y])
		{
			q[++tail]=y;
			vis[y]=1;
		}
	}
	int ecnt=0;
	rep(head,1,tail)
	{
		int x=q[head];
		for(auto y:lk[x])
		{
			++du[y];
			++ecnt;
		}
	}
	if(ecnt/2!=tail)return 0;
	int nq_tail=0;
	rep(head,1,tail)
	{
		int x=q[head];
		if(du[x]==1)nq[++nq_tail]=x;
	}
	rep(head,1,nq_tail)
	{
		int x=nq[head];
		for(auto y:lk[x])
		if(--du[y]>0)
		{
			fa[x]=y;
			if(du[y]==1)nq[++nq_tail]=y;
			else rt=y;
		}
	}
	for(int x=rt;;)
	{
		for(auto y:lk[x])
		if(du[y]>1&&fa[y]!=x)
		{
			fa[x]=y;
			x=y;
			break;
		}
		if(x==rt)break;
	}
	ll ans=1;
	rep(head,1,nq_tail)
	{
		int x=nq[head];
		(ans*=sz[x])%=D; 
		if(link_fa(x))sz[fa[x]]+=sz[x];
	}
	for(int x=rt;;)
	{
		if(!link_fa(x))
		{
			rt=fa[x];
			break;
		}
		x=fa[x];
		if(x==rt)return 0;
	}
	for(int x=rt;;)
	{
		(ans*=sz[x])%=D; 
		if(link_fa(x))sz[fa[x]]+=sz[x];
		x=fa[x];
		if(x==rt)break;
	}
	return mi(ans);
}

int main()
{
	int n;
	cin>>n;
	rep(i,1,n*2)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		y+=n;
		lk[x].pb(y);lk[y].pb(x);
	}
	
	ll ans=1;
	rep(i,1,n*2)ans=ans*i%D;
	rep(x,1,n*2)
	if(!vis[x])
	{
		ll s=solve(x);
		rep(head,1,tail)
		{
			int x=q[head];
			vis[x]=0;
			reverse(lk[x].begin(),lk[x].end());
		}
		(ans*=s+solve(x))%=D;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 15360
w,h = list(map(int, input().split()))
ws = []
hs = []
for i in range(w): ws.append(int(input()))
for i in range(h): hs.append(int(input()))

ws.sort(reverse = True)
hs.sort(reverse = True)

remainW = w
remainH = h
aliveW = [1 for i in range(w)]
aliveH = [1 for i in range(h)]

ans = 0
while(remainW>0 or remainH>0):
    #print(ans, remainW, remainH)
    costW = ws[remainW-1] * (remainH + 1)
    costH = hs[remainH-1] * (remainW + 1)
    if(remainH!=0 and (ws[remainW-1] > hs[remainH-1] or remainW==0)):
        ans += costH
        remainH = max(0,remainH-1)
    else:
        ans += costW
        remainW = max(0,remainW-1)
print(ans)

                             


Measured memory_bytes: 68184
import sys
input = lambda:sys.stdin.readline().strip()
n = int(input())
a = [0]
b = [0]
for i in range(n):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
a.sort()
b.sort()
if n&1:
    print(b[(n+1)//2]-a[(n+1)//2]+1)
else:
    print((b[n//2]+b[(n//2)+1])-(a[n//2]+a[(n//2)+1])+1)

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
// cout << fixed << setprecision(10) << PI << endl;
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

ll sum(vll &v) {return accumulate(all(v), 0);}

int main(){
    string s;
    cin >> s;
    ll l = s.size();
    string a = s.substr(0,(l-1)/2);
    string b = s.substr((l+3)/2-1,(l-1)/2);
    l = a.size();
    REP(i,(l+1)/2){
        if(a[i]!=a[l-i-1]){
            cout << "No" << endl;
            return 0;
        }
        if(b[i]!=b[l-i-1]){
            cout << "No" << endl;
            return 0;
        }
        if(a[i]!=b[l-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
PS = []
for i in range(M):
  p,S = input().split()
  PS.append((int(p)-1,S))

SC = [[0 for _ in range(2)] for _ in range(N)]
for p,s in PS:
  if s == 'AC':
    SC[p][0] = 1
  else:
    if SC[p][0] == 0:
      SC[p][1] += 1

sc = 0
pe = 0
for s,p in SC:
  sc += s
  if s != 0:
    pe += p
print(sc,pe)


Measured memory_bytes: 73816
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  for(int i=0;i<5;i++) cout<<s[i];
  cout<<" ";
  for(int i=6;i<13;i++) cout<<s[i];
  cout<<" ";
  for(int i=14;i<19;i++) cout<<s[i];
  cout<<'\n';
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int w_acc[n+1];
  w_acc[0] = 0;
  for (int i=0; i<n; i++) {
    w_acc[i+1] = w_acc[i] + (s[i] == 'W');
  }
  int ans = n;
  for (int i=0; i<n; i++) {
    ans = min(w_acc[i] + n - i - 1 - w_acc[n] + w_acc[i+1], ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int cnt=0;
  while(n){
    cnt++;
    n/=k;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256