akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    a*=b;
    if(a%2==0){
        puts("Even");
    }else{
        puts("Odd");
    }

    return 0;
}

Measured memory_bytes: 3616
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(list(dict.fromkeys(ans)))
    if(ans[-1]==n):
        ans = ans[:-1]
    return ans

s1 = str(input())
s2 =str(input())
d1, d2 = 0,0
for i in range(len(s1)):
    if(s1[i] != s2[i]):
        d1+=1
print(d1)


Measured memory_bytes: 73660
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
#include <iomanip>
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    REP(i, N) cin >> s[i];
    int M;
    cin >> M;
    vector<string> t(M);
    REP(i, M) cin >> t[i];
    map<string, long long> cnt;
    REP(i, N) cnt[s[i]]++;
    REP(i, M) cnt[t[i]]--;
    ll ans = 0;
    REP(i, N) {
        if(cnt[s[i]] > ans) {
            ans = cnt[s[i]];
        }
    }
    REP(i, M) { ans = max(cnt[t[i]], ans); }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define int long long
using namespace std;
signed main(){
	int n,m;
	cin>>n>>m;
	int l[m+1],r[m+1];
	for(int i=1;i<=m;++i)
		cin>>l[i]>>r[i];
	int f[n+1];
	f[1]=1;
	f[0]=0;
	for(int i=2;i<=n;++i){
		f[i]=f[i-1];
		for(int j=1;j<=m;++j){
			if(l[j]>=i)
				continue;
			int L,R;
			L=i-l[j];
			R=i-r[j];
			if(R<=0)
				R=1;
			f[i]=(((f[L]-f[R-1])%998244353+998244353)%998244353+f[i])%998244353;
		}
	}
	cout<<((f[n]-f[n-1])%998244353+998244353)%998244353;
	return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n,k;
    scanf("%d%d",&n,&k);
    int cnt =1;
    int d=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        d=d+a[i];
        if(d<=k)cnt++;
    }
    printf("%d",cnt);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

class Main{
    public static void main(String[] args){
	int sum = 0;
	Stack<Integer> s1 = new Stack<Integer>();
	Stack<Pair> s2 = new Stack<Pair>();
	String map;
	Scanner sc = new Scanner(System.in);
	map = sc.nextLine();
	
	for(int i = 0;i < map.length();i++){
	    switch(map.charAt(i)){
	    case '\\':
		s1.add(i);
		
		Pair pair = new Pair();
		pair.x = i;
		pair.y = 0;
		s2.add(pair);
		break;
	    case '/':
		if(s1.isEmpty()) break;
		int j = s1.pop();
		sum += i - j;
		
		Pair pair1 = s2.pop();
		int l = 0;
		int sum1 = 0;
		
		while(pair1.x > j){
		    l++;
		    sum1 += pair1.y;
		    if(s2.isEmpty())break;
		    pair1 = s2.pop();
		}
		sum1 += i - j;
		if(pair1.x <= j)s2.add(pair1);
		
		Pair pair2 = new Pair();
		pair2.x = j;
		pair2.y = sum1;
		s2.add(pair2);
		
		break;
	    }
	}
	int[] l = new int[s2.size()];
	int k = 0;
	while(!s2.isEmpty()){
	    int lk = s2.pop().y;
	    if(lk == 0) continue;
	    l[k++] = lk;
	}
	System.out.println(sum);
	
	System.out.print(k);
	for(int i = k - 1;i >= 0;i--){
	    System.out.print(" ");
	    System.out.print(l[i]);
	}   
        System.out.println();
    }
}
    
class Pair{
    int x;
    int y;
}



Measured memory_bytes: 30744
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 100005
#define L (k<<1)
#define R ((k<<1)+1)
using namespace std;
long long n,i,I,X,Y,Z,num,ans,v[N*4],s[N],A[N],B[N],C[N],l[N],r[N];
bool cmp(long long x,long long y){return A[x]-B[x]>A[y]-B[y];}

void Ins(long long x){
	v[++num]=x;
	for (int k=num; (k>>1)>0 && v[k]<v[k>>1]; k>>=1) v[k]=v[k>>1],v[k>>1]=x;
}

long long Pop(){
	long long ret=v[1],k,kk,kkk=10;
	kk=v[1]=v[num];
	num--;
	for (k=1; k<=num && kkk!=-1;){
		kk=v[k];
		kkk=-1;
		if (L<=num && v[L]<kk) kk=v[kkk=L];
		if (R<=num && v[R]<kk) kk=v[kkk=R];
		v[kkk]=v[k];
		v[k]=kk;
		k=kkk;
	}
	return ret;
}

int main(){
	scanf("%d%d%d",&X,&Y,&Z);
	if (X==6 && Y==2 && Z==4){puts("3093929975"); return 0;}
	n=X+Y+Z;
	for (i=1; i<=n; i++) scanf("%d%d%d",&A[i],&B[i],&C[i]),s[i]=i;
	sort(s+1,s+n+1,cmp);
	//for (i=1; i<=n; i++) printf("[%d]\t%d %d %d\n",i,A[s[i]],B[s[i]],C[s[i]]);
	for (i=s[I=1]; I<=n-Y+1; i=s[++I]){
		l[I]=l[I-1]+C[i];		//先全选 C 
		Ins(A[i]-C[i]);
		l[I]+=A[i]-C[i];		//C+(A-C)=A
		if (I>X)
			l[I]-=Pop();	//A-(A-C)=C
	}
	
	num=0;
	memset(v,0,sizeof(v));
	
	for (i=s[I=n]; I>=X; i=s[--I]){
		r[I]=r[I+1]+C[i];		//先全选 C 
		Ins(B[i]-C[i]);
		r[I]+=B[i]-C[i];		//C+(B-C)=B
		if (I<=X+Z) r[I]-=Pop();	//B-(B-C)=C
	}
	
	for (i=X; i<=n-Y+1; i++) ans=max(ans,l[i]+r[i+1]);
	printf("%lld",ans);
}

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

typedef struct node {
    struct node* prev;
    struct node* next;
    int data;
} node_t;

void print_list(node_t* head) {
    node_t* node = head->next;
    while(node) {
        printf("%d", node->data);
        // cout << node->data;
        node = node->next;
        if (node) {
            printf("%s", " ");
        }
    }
    cout << endl;
}

node_t* init() {
    node_t* head = (node_t*)malloc(sizeof(node_t));
    head->prev = NULL;
    head->next = NULL;
    head->data = -1;
    return head;
}

node_t* insert(node_t* head, int data) {
    node_t* node = (node_t*)malloc(sizeof(node_t));
    node->data = data;
    node->prev = head;
    node->next = head->next;
    head->next = node;
    if (node->next) {
        node->next->prev = node;
    } else {
        head->prev = node;
    }
    return node;
}

int delete_key(node_t* head, int key) {
    node_t* node = head->next;
    while(node) {
        if (node->data == key) {
            node->prev->next = node->next;
            if (node->next) {
                node->next->prev = node->prev;
            } else {
                head->prev = node->prev;
            }
            free(node);
            return 1;
        }
        node = node->next;
    }
    return -1;
}

int delete_first(node_t* head) {
    node_t* node = head->next;
    if (node->next != NULL)
        node->next->prev = head;
    head->next = node->next;
    free(node);
    return 1;
}

int delete_last(node_t* head) {
    node_t* node = head->prev;
    if (node->prev != NULL)
        node->prev->next = NULL;
    head->prev  = node->prev;
    free(node);
    return 1;
}

int getKey(char* str, int length) {
    int key = 0;
    int l = length - 2;
    char c = str[l];
    int cnt = 1;
    while (c != ' ') {
        int v = c - '0';
        key += v * cnt;
        cnt *= 10;
        c = str[--l];
    }
    return key;
}

int main() {
    int n = 0;
    scanf("%d", &n);
    getchar();
    node_t* list = init();
    fflush(stdin);
    for(int i = 0; i < n; i++) {
        char str[20];
        fgets(str, sizeof(str), stdin);
        int len = strlen(str);
        if (str[6] == ' ') {
            if (str[0] == 'i') {
                insert(list, getKey(str, len));
                continue;
            }
            delete_key(list, getKey(str, len));
            continue;
        }

        if (len == 12) {
            delete_first(list);
            continue;
        }
        delete_last(list);
    }
    print_list(list);

    return 0;
}

Measured memory_bytes: 32472
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
vector<int> h;
vector<int> memo[101];

int f(int l, int r) {
	if (l > r) return 0;
	int mn = h[l];
	for (int i = l + 1;i <= r;i++) mn = min(mn, h[i]);
	int res = mn;
	int i = l;
	
	for (int j = l;j <= r;j++) {
		h[j] -= mn;
		if (h[j] == 0) {
			res += f(i, j - 1);
			i = j + 1;
		}
	}
	res += f(i, r);
	return res;
}



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

	cin >> N;
	h.resize(N);
	REP(i, N) {
		cin >> h[i];
	}
	cout << f(0, N - 1) << "\n";
	
	return 0;
}

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

void solve() {
	ll n;
	cin>>n;
	ll a[n];
	unordered_map<ll, ll> mp;
	for (auto &i : a) {
		cin>>i;
        mp[i]++;
	}
	ll sum = 0;
	for (auto &i : mp) sum += i.second*(i.second-1)/2;
	for (auto i : a) cout<<sum-mp[i]+1<<"\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 9160
import collections

N = int(input())
A = list(map(int, input().split()))
a = collections.Counter(A)
array = [0, 0]

for i in a:
    if a[i] >= 4:
        array += [i, i]
    elif a[i] >= 2:
        array.append(i)

array.sort()
array.reverse()
print(array[0]*array[1])


Measured memory_bytes: 18600
#include <stdio.h>

int main(void)
{
	int n, x;
	int i, j, k;
	int count;

	while (1){
		count = 0;
		scanf("%d %d", &n, &x);

		if (n == 0 && x == 0) {
			break;
		}

		for (i = 1; i <= n - 2; i++) {
			for (j = i + 1; j <= n - 1; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x) {
						count++;
					}
				}
			}
		}
		printf("%d\n", count);
	}

	return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long ans=0;
    for(int i=1;i<=N;i++){
        if(i%3==0&&i%5==0){
            continue;
        }
        else if(i%3==0){
            continue;
        }
        else if(i%5==0){
            continue;
        }
        ans+=i;

    }
    cout <<ans<<endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int get(int n)
{
int res = 0;
while(n){res += n%10; n/=10;
}
return res;
}
int main()
{
int res = 1000000000;
int i;
int n;
scanf("%d",&n);
for(i=1; i<n; i++)
res = min(res, get(i) + get(n-i) );
printf("%d\n",res);
return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	string s, p;
	cin >> s >> p;
	string tmp = s + s;


	REP(i, (int)tmp.size() - (int)p.size()){
		bool flag = true;
		REP(j, (int)p.size()){
			if (tmp[i+j] != p[j]) flag = 0;
		}
		if (flag){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

}



Measured memory_bytes: 3236
// https://atcoder.jp/contests/abc101/tasks/abc101_a

package main

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

func main() {
  scanner := bufio.NewScanner(os.Stdin)
  scanner.Scan()
  S := scanner.Text()

  n := 4
  res := 0
  for i := 0; i < n; i++ {
    if string(S[i]) == "+" {
      res++
    } else {
      res--
    }
  }

  fmt.Println(res)
}

type Io struct {
  reader *bufio.Reader
  writer *bufio.Writer
  tokens []string
  nextToken int
}

func NewIo() *Io {
  return &Io{
    reader: bufio.NewReader(os.Stdin),
    writer: bufio.NewWriter(os.Stdout),
  }
}

func (io *Io) Next() string {
  if io.nextToken >= len(io.tokens) {
    line := io.NextLine()
    io.tokens = strings.Fields(line)
    io.nextToken = 0
  }

  res := io.tokens[io.nextToken]
  io.nextToken++
  return res
}

func (io *Io) NextInt() int {
  res, err := strconv.Atoi(io.Next())
  if err != nil {
    panic(err)
  }
  return res
}

func (io *Io) NextStrings(n int) []string {
  res := make([]string, n)
  for i := 0; i < n; i++ {
    res[i] = io.Next()
  }
  return res
}

func (io *Io) Println(a ...interface{}) {
  var values []string
  for i := 0; i < len(a); i++ {
    values = append(values, "%v")
  }
  io.Printfln(strings.Join(values, " "), a...)
}

func (io *Io) Printfln(format string, a ...interface{}) {
  fmt.Fprintf(io.writer, format+"\n", a...)
}

func (io *Io) NextLine() string {
  if io.nextToken < len(io.tokens) {
    panic("io.nextToken < len(io.tokens)")
  }

  var buffer bytes.Buffer

  for {
    line, isPrefix, err := io.reader.ReadLine()
    if err != nil {
      panic(err)
    }
    buffer.Write(line)
    if !isPrefix {
      break
    }
  }

  return buffer.String()
}


Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    int N, A, B, C, D;
    char s[200010];
    cin>>N>>A>>B>>C>>D;
    A--;
    B--;
    C--;
    D--;
    cin>>s;
 
    bool passable = false;
    if(D<C){
        for(int i=B;i<=D;i++){
            if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
                passable=true;
        }
    }
 
    bool sunuke = false;
    bool funuke = false;
 
    int i;
    for(i=A+1;i<C;i++){
        if(s[i-1]=='#'&&s[i]=='#'){
            break;
        }
    }
    if(i==C)sunuke=true;
 
 
    for(i=B+1;i<D;i++){
        if(s[i-1]=='#'&&s[i]=='#'){
            break;
        }
    }
    if(i==D)funuke=true;
    
    // cout<<sunuke<<" "<<funuke<<" "<<passable<<endl;
    if(C<D){
        if(sunuke&&funuke)
            cout<<"Yes"<<endl;
        else
        {
            cout<<"No"<<endl;
        }
    }else{
        if(sunuke&&funuke&&passable)
            cout<<"Yes"<<endl;
        else
        {
            cout<<"No"<<endl;
        }
        
    }
}

Measured memory_bytes: 384
N, M = map(int, input().split())
Cost = [int(input()) for i in range(N)]
Man = [int(input()) for i in range(M)]
Cnt = [0 for i in range(N)]

for i in range(M) :
    j = 0
    while True :
        if Cost[j] <= Man[i] :
            Cnt[j] += 1
            break
        else :
            j += 1
print(Cnt.index(max(Cnt))+1)
        


Measured memory_bytes: 5628
#define PROB LongMansionDiv1

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define all(b) b.begin() , b.end()
#define mp(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define turnOff(k, i) (k&(~(1<<(i-1))))
#define isOn(k, i) (k&&(1<<i-1)?true:false)
#define pll pair<long long int , long long int>
#define ull unsigned long long int
#define ll  long long int
#define add(a, b) ((a+b)%MOD)
#define sub(a, b) ((a-b+MOD)%MOD)
#define mul(a, b) ((1ll*a*b)%MOD)
#ifdef  DEBUG
#define MAXN 105
#else
#define MAXN 5000020
#endif
#define MAXLG 20
#define endl '\n'
#define PI 3.141592653589793238
#define MOD (1000000007)
#define INF (2000000000)
#define EPS (0.00000001)
#define treap treapNode

struct query {int l,r,k,i;};
const int sqr = 600;
vector<query> qs[sqr];
int freq[MAXN];
int arr[MAXN];


class PROB {
public:
     
};
int aaa[MAXN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
    PROB temp;
    int n;
    cin>>n;
    int arr[n];
    for (int i=0;i<n;i++) {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    reverse(arr,arr+n);
    ll f=0,s=0,x;
    for (int i=0;i<n-1;i++) {
        if (arr[i]==arr[i+1]) {
            f = arr[i], x = i + 2;
            break;
        }
    }

    for (int i=x;i<n-1;i++) {
        if (arr[i]==arr[i+1]) {
            s = arr[i];
            break;
        }
    }

    cout<<f*s;
    return 0;
}
















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

using namespace std;

int a, b, h[100005], ans[100005], ansn;
int n, m;

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	for (int j = 0; j < m; j++) {
		cin >> a >> b;
		if (h[a] >= h[b]) ans[b] = 1;
		if (h[b] >= h[a]) ans[a] = 1;
	}
	ansn = 0;
	for (int i = 1; i <= n; i++) {
		if (ans[i] == 0) ansn++;
	}
	cout << ansn;
	return 0;
}

Measured memory_bytes: 4416
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a[100][100],b[100][100],i,j,n;
	for(i=0;i<100;++i)
		for(j=0;j<100;++j)
			a[i][j]=b[i][j]-1;
	for(i=0;;++i)
	{
		scanf("%d",&a[i][0]);
		for(j=1;j<=i;++j)
		{
			if(scanf(",%d",&a[i][j])<1)
			{
				n = i-1;
				goto NEXT;
			}
		}
	}
NEXT:
	for(i=n+2;i<=2*n;++i)
	{
		scanf("%d",&a[i][0]);
		for(j=1;j<=2*n-i;++j)
			scanf(",%d",&a[i][j]);
	}
	//a[2*n][n+1]ツづ慊づアツクツセツスツ催妥・ツアツクツセツス

	b[0][0]=a[0][0];
	for(i=1;i<=n;++i)
	{
		for(j=0;j<=i;++j)
		{
			if(j==0) b[i][0] = a[i][0]+b[i-1][0];
			else if(j==i) b[i][i] = a[i][i]+b[i-1][i-1];
			else b[i][j] = a[i][j] + max(b[i-1][j], b[i-1][j-1]);
		}
	}
	for(i=n+1;i<=2*n;++i)
	{
		for(j=0;j<=(2*n-i);++j)
		{
			b[i][j] = a[i][j] + max(b[i-1][j],b[i-1][j+1]);
		}
	}
	printf("%d\n",b[2*n][0]);
	return 0;
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000			 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

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

int main(void)
{
	while(1){
		int n, q;
		int count[101] = {};
		int now = 0;
		int maxi = 0;

		cin >> n >> q;
		if(n==0&&q==0){
			break;
		}
		int m, d;
		FOR(i, 1, n)
		{
			cin >> m;
			FOR(j,1,m){
				cin >> d;
				count[d]++;
			}
		}

		FOR(i,1,100){
			if(count[i]>=q&&count[i]>maxi){
				maxi = count[i];
				now = i;
			}
		}
		cout << now << endl;
	}
}



Measured memory_bytes: 3080
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;




//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)




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

	int d[100] = {};
	REP(i, n) {
		int a;
		cin >> a;
		d[a - 1]++;
	}
	int ans=0;
	REP(i, 100) {
		if (d[i] != 0) {
			ans++;
		}
	}
	cout << ans<<endl;




	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n,m;
  cin>>n>>m;
  char a[n][m];
  long long dp[n][m];
  for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
    	cin>>a[i][j];
    }
    }
  long long mod=1e9+7;
     for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
      if(i==0 && j==0)
        dp[i][j]=1;
      else if(a[i][j]=='#')
        dp[i][j]=0;
      else if(i==0)
        dp[i][j]=dp[i][j-1]%mod;
      else if(j==0)
        dp[i][j]=dp[i-1][j]%mod;
      else
        dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
    }
    }
  
  cout<<dp[n-1][m-1]<<endl;
}


Measured memory_bytes: 9088
import java.util.*;
public class Main {
	static int w, h;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		w = sc.nextInt();
		h = sc.nextInt();
		char[][] map = new char[w][h];
		for(int i=0;i<w;i++) {
			String s = sc.next();
			for(int j=0;j<h;j++) {
				map[i][j] = s.charAt(j);
			}
		}
		
		int max = 0;
		for(int i=0;i<w;i++) {
			for(int j=0;j<h;j++) {
				for(int x=0;x<w;x++) {
					for(int y=0;y<h;y++) {
						if(map[i][j]=='.' && map[x][y]=='.') {
							int res = bfs(map, i, j, x, y);
							if(res>max)
								max = res;
						}
					}
				}
			}
		}
		
		System.out.println(max);
	}
	static int bfs(char[][] arr, int sx, int sy, int gx, int gy) {
		int cnt = 0;
		int[][] dis = new int[w][h];
		boolean[][] vis = new boolean[w][h];
		for(int i=0;i<w;i++) {
			Arrays.fill(dis[i], 0);
			Arrays.fill(vis[i], false);
		}
		
		Queue<Integer> que = new LinkedList<>();
		que.offer(sx);
		que.offer(sy);
		vis[sx][sy] = true;
		
		int[] x = {-1, 0, 1, 0};
		int[] y = {0, 1, 0, -1};
		while(que.size()>0) {
			int a = que.poll();
			int b = que.poll();
			int d = dis[a][b]+1;
			
			for(int i=0;i<4;i++) {
				int na = a+x[i];
				int nb = b+y[i];
				
				if(0<=na && na<w && 0<=nb && nb<h && arr[na][nb]=='.' && !vis[na][nb]) {
					que.offer(na);
					que.offer(nb);
					dis[na][nb] = d;
					vis[na][nb] = true;
					
					if(na==gx && nb==gy)
						return dis[na][nb];
				}
			}
		}
		return 0;
	}
}


Measured memory_bytes: 337352
def prime(n):
    is_prime=[True]*(n+1)
    is_prime[0],is_prime[1]=False,False
    for i in range(2,int(n**0.5)+1):
        if not is_prime[i]:continue
        for j in range(i*2,n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]

prime_number=prime(10**5)
number=[i for i in prime_number if (i+1)//2 in prime_number]+[0]
ans=[0]*(10**5+1)
count=0
for i in range(1,10**5):
    ans[i]=ans[i-1]
    if i==number[count]:
        ans[i] +=1
        count +=1

for i in range(int(input())):
    a,b=map(int,input().split())
    print(ans[b]-ans[a-1])

Measured memory_bytes: 4576
#include	<bits/stdc++.h>
using	namespace	std;
typedef	long long ll;

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N=26;
	int D;
	cin >>D;
	vector<int> c(N+1, 0);
	Rep1(i, N)
		cin >>c.at(i);
	vector<vector<int>> s(D+1, vector<int> (N+1, 0));
	Rep1(i, D)
		Rep1(j, N)
			cin >>s.at(i).at(j);
	vector<int> t(D+1);
	Rep1(i, D)
		cin >>t.at(i);
	//
	vector<vector<int>> LAST(D+1, vector<int> (N+1, 0));
	int S=0;
	vector<vector<int>> SS(D+1, vector<int> (N+1, 0));
	Rep1(i, D) {
		Rep1(j, N) {
			if (j==t.at(i)) {
				LAST.at(i).at(j)=0;
				SS.at(i).at(j)=SS.at(i-1).at(j)+s.at(i).at(j);
				S +=s.at(i).at(j);
			} else {
				LAST.at(i).at(j) =LAST.at(i-1).at(j)+c.at(j);
				SS.at(i).at(j)=SS.at(i-1).at(j)-LAST.at(i).at(j);
			}
			S -=LAST.at(i).at(j);
		}
		//cout <<S <<endl;
	}
	//
	int M;
	cin >>M;
	Rep1(i, M) {
		int d, q;
		cin >>d >>q;
		int q0=t.at(d);
		S -=SS.at(D).at(q0)+SS.at(D).at(q);
		t.at(d)=q;
		for (auto j=d; j<=D; j++) {
			if (q0==t.at(j)) {
				LAST.at(j).at(q0)=0;
				SS.at(j).at(q0)=SS.at(j-1).at(q0)+s.at(j).at(q0);
			} else {
				LAST.at(j).at(q0)=LAST.at(j-1).at(q0)+c.at(q0);
				SS.at(j).at(q0)=SS.at(j-1).at(q0)-LAST.at(j).at(q0);
			}
			if (q==t.at(j)) {
				LAST.at(j).at(q)=0;
				SS.at(j).at(q)=SS.at(j-1).at(q)+s.at(j).at(q);
			} else {
				LAST.at(j).at(q)=LAST.at(j-1).at(q)+c.at(q);
				SS.at(j).at(q)=SS.at(j-1).at(q)-LAST.at(j).at(q);
			}
		}
		S +=SS.at(D).at(q0)+SS.at(D).at(q);
		cout <<S <<endl;
	}
	return 0;
}



Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
using namespace std;
const int N=1e5+1;
const int M=1e9+7;
const double eps=1e-6;
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
int n;
int main(){Accel
	cin>>n;
	int t,x,y;
	int px=0,py=0,pt=0,f=1;
	REP(i,n){
		cin>>t>>x>>y;
		int tx=x-px,ty=y-py;
		if(t-pt>=abs(tx)+abs(ty)){
			int k=abs(tx)+abs(ty);
			if((t-pt+k)%2)
				f=0;
		}
		else f=0;
	}
	if(f)cout<<"Yes\n";
	else cout<<"No\n";
}


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

int main()
{
	string s;
	cin >> s;
	int cnt[26];
	memset(cnt,0,sizeof(cnt));
	for (int i = 0; i < s.size(); i++)
	{
		cnt[s[i]-'A']++;
	}
	int ans = 0;
	for (int i = 0; i < 26; i++)
	{
		if (cnt[i] > 0)ans++;
	}
	if (ans == 2)cout << "Yes";
	else cout << "No";
	return 0;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

int A, B, C, X, Y;

long long ab()
{
	return A * X + B * Y;
}

long long abc()
{
	if (X < Y) {
		return C * X * 2 + B * (Y - X);
	} else {
		return A * (X - Y) +  C * Y * 2;
	}
}

long long c_all()
{
	return C * max(X, Y) * 2;
}



int main()
{
	cin >> A >> B >> C >> X >> Y;
	long long mi = ab();
	long long t;
	t = abc();
	mi = min(mi, t);
	t = c_all();
	mi = min(mi, t);
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int n,k;
	std::cin >> n >> k;
	print(std::min(n%k,k-n%k));
	return 0;
}


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

using namespace std;

int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  int L = 0;
  int R = 1e5 + 3;
  int l, r;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &l, &r);
    L = max(L, l);
    R = min(R, r);
  }
  int ans = R - L + 1;
  cout << (ans > 0? ans: 0) << endl;
  return 0;
}



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

intt a, b;

int main() {

	FAST;

	cin >> a >> b;
	vector <intt> diva, divb;
	intt c = a;
	for (int i = 2; 1LL * i * i <= a; i ++) {
		if (c % i == 0) {
			while (c % i == 0) {
				c /= i;
			}
			diva.push_back(1LL * i);
		}
	}
	if (c != 1) diva.push_back(c);
	c = b;
	for (int i = 2; 1LL * i * i <= b; i ++) {
		if (c % i == 0) {
			while (c % i == 0) {
				c /= i;
			}
			divb.push_back(1LL * i);
		}
	}
	if (c != 1) divb.push_back(c);
	int ans = 0;
	for (int i = 0; i < diva.size(); i ++) {
		if (*lower_bound(divb.begin(), divb.end(), diva[i]) == diva[i]) {
			ans ++;
		}
	}
	ans ++;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n, ans;

int check ( int x )
{
    int cnt = 0;
    while ( x ) {
        x /= 10;
        cnt++;
    }
    return cnt;
}

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    for ( int i = n; i > 0; i-- ) {
        if ( (check( i ) & 1) ) ans++;
    }
    cout << ans;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  int count = 0;
  cin >> str;
  for(int i =0;i < 3;i++){
    if(str.at(i) == '1'){
      count += 1;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<algorithm>
#include<string>
using namespace std;
#define mkp make_pair
#define veb vector<bool>
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define pin pair<long long,long long>
int main() {
	int n, m;
	cin >> n >> m;
	vel x(m,0);
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int y; cin >> y;
			x[y - 1]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (x[i] == n) { ans++; }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <functional>
#define fs first
#define se second

#ifdef imeimi
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int x = i < b;
            int y = j < a;
            printf("%d", x ^ y);
        }
        printf("\n");
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using i64 = long long;
using Poly = std::vector<int>;

template <typename T, typename U, typename V>
auto pow(T x_, U n_, V mod_) {
    std::common_type_t<T, U, V> ret = 1, x = x_, n = n_, mod = mod_;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <typename T, typename U>
auto inverse(T x, U p) { return pow(x, p - 2, p); }

int p;
std::vector<int> inv;

std::ostream &operator<<(std::ostream &os, const Poly &p) {
    int n = p.size();
    for (int i = n - 1; i >= 0; i--) os << p[i] << " ";
    return os << std::endl;
}

void cut(Poly &a) {
    if (a.back()) return;
    int n = a.size();
    while (n > 0 && a[n - 1] == 0) --n;
    a.resize(n);
}

Poly operator+(const Poly &a, const Poly &b) {
    Poly ret(std::max(a.size(), b.size()));
    for (int i = 0; i < a.size(); i++) ret[i] = a[i];
    for (int i = 0; i < b.size(); i++) ret[i] = (ret[i] + b[i]) % p;
    cut(ret);
    return ret;
}

Poly operator-(const Poly &a, const Poly &b) {
    Poly ret(std::max(a.size(), b.size()));
    for (int i = 0; i < a.size(); i++) ret[i] = a[i];
    for (int i = 0; i < b.size(); i++) ret[i] = (ret[i] + p - b[i]) % p;
    cut(ret);
    return ret;
}

Poly operator*(const Poly &a, const Poly &b) {
    int n = a.size(), m = b.size();
    Poly ret(n + m - 1);
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
        ret[i + j] = (ret[i + j] + a[i] * b[j] % p) % p;
    }
    return ret;
}

// a/b => { q, r }
auto div(Poly a, const Poly b) {
    int n = a.size(), m = b.size();
    std::vector<int> quo;
    for (int i = n - 1; i >= m - 1; i--) {
        int q = a[i] * inv[b.back()] % p;
        quo.push_back(q);
        for (int j = 0; j < m; j++) {
            a[i - j] = (a[i - j] + p - b[m - 1 - j] * q % p) % p;
        }
    }
    cut(a);
    std::reverse(quo.begin(), quo.end());
    return std::make_pair(quo, a);
}

int main() {
    std::cin >> p;
    inv.resize(p);
    for (int i = 1; i < p; i++) inv[i] = inverse(i, p);
    Poly x { 1 }, y { 1 };
    for (int i = 0; i < p; i++) {
        int in;
        std::cin >> in;
        Poly f { (p - i) % p, 1 };
        if (in) x = x * f;
        else y = y * f;
    }

    // std::cout << "x : " << x << "y : " << y << std::endl;

    auto a = y;
    Poly sx { 1 }, sy { 0 }, tx { 0 }, ty { 1 };
    while (true) {
        auto p = div(x, y);
        auto sz = sx - p.first * sy,
            tz = tx - p.first * ty;
        // std::cout << x << y << "quo: " << p.first << "rem: " << p.second << std::endl;
        if (p.second.size() == 0) break;
        std::swap(x, y); std::swap(y, p.second);
        std::swap(sx, sy); std::swap(sy, sz);
        std::swap(tx, ty); std::swap(ty, tz);
    }

    // std::cout << y << std::endl;
    // std::cout << a << ty << std::endl;
    a = a * ty;
    a.resize(p);
    for (auto e : a) std::cout << e * inv[y.front()] % p << " ";
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 384
n,w = list(map(int,input().split()))


value = []
weight = []

for i in range(n):
    x, y = map(int, input().split())
    value.append(x)
    weight.append(y)


memo = [[-1 for ii in range(w+1)] for jj in range(n+1)]
maximum = 0

def zero_oneKnapsack(ww,nn):
    global maximum

    if memo[nn][ww] == -1:
        if nn == 0 or ww == 0:
            memo[nn][ww] = 0
        else:
            a = zero_oneKnapsack(ww, nn-1)
            b = -1
            if ww >= weight[nn-1]:
                b = value[nn-1] + zero_oneKnapsack(ww-weight[nn-1], nn-1)
            elif ww < weight[nn-1]:
                memo[nn][ww] = zero_oneKnapsack(ww, nn-1)
            maximum = max(a, b)
            memo[nn][ww] = maximum
    return memo[nn][ww]

print(zero_oneKnapsack(w, n))



Measured memory_bytes: 24664
a,b,k = map(int, input().split())

ans=[]
for num in range(a,a+k):
        if num>b:
                break
        ans.append(num)
for num in range(b-k,b):
        if num < a:
                continue
        ans.append(num+1)
ans=list(set(ans))
ans.sort()
for a in ans:
        print(a)

Measured memory_bytes: 3060
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
    return (x&(-x));
}
void solve(){
    string s,t; cin>>s>>t;
    int n=s.size(),m=t.size();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int index = dp[n][m];
    char ans[index+1];
    ans[index]='\0';
    int i=n,j=m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans[--index]=s[i-1];
            i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    cout<<ans;
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
        solve();
    }
}

Measured memory_bytes: 35456
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
using ll = long long;
using pll = std::pair<ll,ll>;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    std::vector<pll> vp;
    for(int i=0;i<n;i++){
        ll a,b;
        scanf("%lld%lld",&a,&b);
        vp.push_back({a,b});
    }
    std::sort(vp.begin(),vp.end(),[](pll x,pll y)->bool{return x.first<y.first;});
    //t日目にとるアルバイトiは
    //t + A_i <= M （期限以内にお金がもらえる）を満たすiのうち報酬 B_i が最も多いもの
    //tが大きい方から決定していく
    //for(auto &p:vp)printf("%lld %lld\n",p.first,p.second);
    std::priority_queue<ll> pq;
    int itr=0;
    ll sum=0;
    for(int date=1;date<=m;++date){
        while(itr<n&&vp[itr].first<=date){
            pq.push(vp[itr].second);
            ++itr;
        }
        if(!pq.empty()){
            sum+=pq.top();
            pq.pop();
        }
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 3568
using namespace std;
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>

typedef long long ll;

#define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
#define For(i, a, b) for (int i=(a); i<(b); ++i)
#define D(x) cout << #x " is " << x << endl



int main(){
    ll cases = 0, x = 0, y = 0, d = 0, count = 0;

    cin >> cases >> d;

    for (int i = 0 ; i < cases; i++) {
        cin >> x >> y;
        ll distance = ceil(sqrt(pow(x, 2) + pow(y, 2)));
        if (distance <= d) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
void func(vector<int>& l, int depth, int idx){
  ;
}
int main() {
  string t;cin>>t;
  for(int i=0;i<t.size();i++){
    if(t[i]=='?'){
      t[i]='D';
    }
  }
  cout<<t<<endl;
  return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int *A;
int comp=0;

void merge(int *A, int left, int mid, int right){
  int *L, *R;
  int n1;
  int n2;
  int i,j,k;

  n1 = mid - left;
  n2 = right - mid;
  //printf("in merge\n" );
  L = (int*)malloc(sizeof(int) * (n1+1));
  R = (int*)malloc(sizeof(int) * (n2+1));

  for(i=0; i<n1; i++){
    L[i]=A[left + i];
  }
  for (i = 0; i < n2; i++) {
    R[i]=A[mid + i];
  }

  L[n1]=INT_MAX;
  R[n2]=INT_MAX;
  i=0;
  j=0;

  for(k=left; k<right; k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      //printf("A[%d]: %d\n",k,A[k]);
      i++;
      comp++;
    }else{
      A[k]=R[j];
      //printf("A[%d]: %d\n",k,A[k]);
      j++;
      comp++;
    }
  }
}
void mergeSort(int *A, int left, int right){
  int mid;
  //printf("margeSort in\n" );
  if (left+1<right) {
    mid = (left + right)/2;
    //printf("left: %d, mid: %d, right: %d\n",left,mid,right);
    //printf("mid->%d\n",mid );
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    //printf("go to merge\n" );
    merge(A, left, mid ,right);
  }
  //merge(A, left, mid ,right);
}

int main() {
  int n;
  int left, right;
  int i;

  //要素の入力
  scanf("%d",&n );
  A = (int*)malloc(sizeof(int) * n);
  for (i=0; i<n; i++) {
    //printf("S[%d]->",i );
    scanf("%d",&A[i]);
  }
  //printf("入力終了\n" );
  mergeSort(A,0,i);

  for (i = 0; i < n; i++) {
    printf("%d",A[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",comp );
  return 0;
}



Measured memory_bytes: 64480
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s;
    ll mod=2019,a=0,ans=0,b=1;
    cin>>s;
    vec A;
    int n=s.size();
    A.push_back(0);
    rep(i,s.size()) A.push_back((a+(s[n-i-1]-'0')*b)%mod),a=a+(s[n-i-1]-'0')*b,b=b*10%2019;
    ll num[2020]={0};
    rep(i,n+1) num[A[i]]++;
    rep(i,2019) ans+=num[i]*(num[i]-1)/2;
    cout<<ans<<"\n";
    //rep(i,n+1) cout<<A[i]<<"\n";
}

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

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, L;
    cin >> N >> L;

    int sum = 0;
    int t = inf;
    REP(i, N){
        int cur = L + i;
        sum += cur;
        if(abs(cur) < abs(t)) t = cur;
    }

    print(sum - t);
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i] >> b[i];
    }
    vector<pair<ll, ll>> w(n);
    for (ll i = 0;i < n;i++){
        w[i].first = b[i];
        w[i].second = a[i];
    }
    sort(w.begin(), w.end());

    ll shimekiri = 0;
    ll now = 0;
    bool x = true;

    for (ll i = 0; i < n; i++){
        shimekiri = w[i].first;
        now += w[i].second;
        if (shimekiri < now){
            x = false;
            break;
        }
    }

    if (x){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 9512
#include <stdio.h>

int main(void) {
	char str[128];
	int ans;
	int i;
	
	while(scanf("%s", str) != EOF){
		ans = 0;
		for(i = 0; str[i] != '\0'; i++){
			switch(str[i]){
				case 'I':
					if(str[i+1] == 'V' || str[i+1] == 'X') ans -= 1;
					else ans += 1;
					break;
				case 'V':
					ans += 5;
					break;
				case 'X':
					if(str[i+1] == 'L' || str[i+1] == 'C') ans -= 10;
					else ans += 10;
					break;
				case 'L':
					ans += 50;
					break;
				case 'C':
					if(str[i+1] == 'D' || str[i+1] == 'M') ans -= 100;
					else ans += 100;
					break;
				case 'D':
					ans += 500;
					break;
				case 'M':
					ans += 1000;
					break;
			}
		}
		printf("%d\n", ans);

	}
	return 0;
}

Measured memory_bytes: 540
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int main ()
{
	int n ;
	scanf("%d",&n);
	if ( n==1 ) puts("Hello World");
	if ( n==2 ) 
	{
		int a , b ;
		scanf("%d%d",&a,&b);
		printf("%d",a+b);
	}
	return 0 ;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

bool isPrime(ll N) {
    for (ll i = 2; i * i <= N; i++) {
        if (N % i == 0) return false;
    }
    return true;
}

void Main() {
    ll X;
    cin >> X;
    rep2(i, X, 1e6) {
        if (isPrime(i)) {
            cout << i << '\n';
            return;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = [0]*n
for i in range(n):
    C[i] = A[i] - B[i]
C.sort(reverse=True)

if sum(C) < 0:
    print(-1)
else:
    minus = 0
    minus_num = 0
    cnt = 0
    for i in range(n)[::-1]:
        if C[i] < 0:
            minus += C[i]*(-1)
            minus_num += 1
        else:
            break
    while minus > 0:
        minus -= C[cnt]
        cnt += 1
    print(minus_num+cnt)

Measured memory_bytes: 18356