akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
    ll dif_x = x2-x1;
    ll dif_y = y2-y1;
    printf("%d %d %d %d\n",x2-dif_y,y2+dif_x,x1-dif_y,y1+dif_x);
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int N, K;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> K;
    vector<ll> x(N), y(N);
    vector<ll> xary, yary;
    rep(i, N)
    {
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }

    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());
    ll ans = 1ll * (xary[N - 1] - xary[0]) * (yary[N - 1] - yary[0]);

    rep(xi, N)
    {
        rep(xj, N)
        {
            rep(yi, N)
            {
                rep(yj, N)
                {
                    int num = 0;
                    ll lx = xary[xi], rx = xary[xj];
                    ll by = yary[yi], uy = yary[yj];
                    rep(i, N)
                    {
                        if (lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy) {
                            num++;
                        }
                    }
                    if (num >= K) {
                        ans = min(ans, 1ll * (rx - lx) * (uy - by));
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

A,B,K = inputIL()
if B==1000000000:
  S1 = list(range(A,A+K))
  S2 = list(range(max(B+1-K,A+K),B+1))
  print(*S1,sep="\n")
  print(*S2,sep="\n")
  exit()
S = list(filter(lambda x: (A+K>x or B-K<x),list(range(A,B+1))))
print(*S,sep="\n")

Measured memory_bytes: 39728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d) cout<<"Left";
  if(a+b<c+d) cout<<"Right";
  if(a+b==c+d) cout<<"Balanced";
  cout<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    constexpr ll mod = 1000000007;
    ll n, k;
    cin >> n >> k;
    VL a(n), neg, pos;
    rep(i, 0, n){
        cin >> a[i];
        if(a[i] < 0) neg.push_back(a[i]);
        else pos.push_back(a[i]);
    }
    sort(ALL(pos), greater<ll>());
    sort(ALL(neg));
    ll ans = 1;
    if(n == k){
        rep(i, 0, n) {
            ans *= a[i];
            ans %= mod;
        }
    }else if(pos.empty()){
        if(k % 2 == 1){
            reverse(ALL(neg));
            rep(i, 0, k){
                ans *= neg[i];
                ans %= mod;
            }
        }else{
            rep(i, 0, k){
                ans *= neg[i];
                ans %= mod;
            }
        }
    }else{
        if(k % 2 == 1){
            ans *= pos[0];
            priority_queue<ll> que;
            for(ll i = 1; i+1 < (ll) pos.size(); i += 2) que.push(pos[i] * pos[i+1]);
            for(ll i = 0; i+1 < (ll) neg.size(); i += 2) que.push(neg[i] * neg[i+1]);
            rep(i, 0, k/2){
                ans *= que.top() % mod;
                ans %= mod;
                que.pop();
            }
        }else{
            priority_queue<ll> que;
            for(ll i = 0; i+1 < (ll) pos.size(); i += 2) que.push(pos[i] * pos[i+1]);
            for(ll i = 0; i+1 < (ll) neg.size(); i += 2) que.push(neg[i] * neg[i+1]);
            rep(i, 0, k/2){
                ans *= que.top() % mod;
                ans %= mod;
                que.pop();
            }
        }
    }
    if(ans < 0) ans += mod;
    cout << ans << endl;
   return 0;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    
    int a,b;
    int counter[4];
    rep(i,4){
        counter[i] = 0;
    }
    rep(i,3){
        cin >> a >> b;
        counter[a-1]++;
        counter[b-1]++;
    }
    rep(i,4){
        if(counter[i]>=3){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int n;
    cin >> n;
    vector<bool> a(101, false);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        if (!a[d]) {
            cnt++;
        }
        a[d] = true;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LLI;

int main()
{
	int n, down = 0, up = 0;
	LLI ans = 0;
	cin >> n;
	int a[n], b[n], c[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a,a+n);
	
	for(int i = 0; i < n; i++)
		cin >> b[i];
	sort(b,b+n);
	
	for(int i = 0; i < n; i++)
		cin >> c[i];
	sort(c,c+n);
	
	for(int i = 0; i < n; i++)
	{
		for(int j = down; j < n; j++)
			if( b[i] > a[j] )
				down++;
			else
				break;
		for(int j = up; j < n; j++)
			if( b[i] >= c[j] )
				up++;
			else
				break;
		ans += (LLI)down * (LLI)( n - up );
	}
	cout << ans;
}

Measured memory_bytes: 4812
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
using namespace std;
typedef long long ll;
int main() {
    int a, b;
    char op;
    while (1) {
        cin >> a >> op >> b;
        if (op == '?') {
            break;
        }
        switch (op) {
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '/':
                cout << a / b << endl;
                break;
        }
    }

    return 0;
}

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

struct aspect
{
    int a;
    int b;
    int c;
};

int main()
{
    int n, a[3];

    cin >> n;

    aspect p[n];

    for( int i = 0; i < n; i++ )
    {
        cin >> a[0] >> a[1] >> a[2];
        for( int j = 0; j < 2; j++ )
            for( int k = j + 1; k < 3; k++ )
                if( a[j] > a[k] )
                {
                    int temp = a[j];
                    a[j] = a[k];
                    a[k] = temp;
                }
        p[i].a = a[0];
        p[i].b = a[1];
        p[i].c = a[2];
    }

    int cnt = 0, m = 0;
    for( int i = 0; i < n - 1; i++ )
        for( int j = i + 1; j < n; j++ )
            if( p[i].a == p[j].a && p[i].b == p[j].b && p[i].c == p[j].c )
            {
                cnt++;
                p[j].a = m;
                p[j].b = m;
                p[j].c = m;
                m--;
            }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        int res = 0;
        for (int i = 0; i < n; i++) {
            ary[i] = sc.nextInt();
        }
        
        for (int i = 0; i < n-1; i++) {
            for (int j = n-1; j > i; j--) {
                if (ary[j] < ary[j-1]) {
                    int t = ary[j];
                    ary[j] = ary[j-1];
                    ary[j-1] = t;
                    res++;
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            if (i != n-1) {
                System.out.print(ary[i]);
                System.out.print(" ");
            } else {
                System.out.println(ary[i]);
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 26376
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b, c, d] <- map readInt . BS.words <$> BS.getLine
  print $ solve a b c d

solve :: Int -> Int -> Int -> Int -> Int
solve a b c d = length $ filter p [0 .. 100] where
  p i = a <= i && i < b && c <= i && i < d

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt


Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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


int main() {

	int A[3];
	cin >> A[1] >> A[2] >> A[0];

	rep(i, 3) { cout << A[i]; cout << " "; }
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

char *team;
int n,**res,wl;
bool* flag;

void display(){
	int count=0;
	flag = new bool[n];
	int tmp = 0;
	for(int i=0; i<n; i++)
		flag[i] = false;
	for(int i=0; i<n; i++)
		if(flag[i])
			std::cout << i << std::endl;
	while(true){
		for(int i=0; i<n; i++){
			if(flag[i] == true)
				continue;
			if(res[tmp][0] < res[i][0])
				tmp = i;
			else if(res[tmp][0] == res[i][0] && res[tmp][1] > res[i][1])
				tmp = i;
		}
		std::cout << team[tmp] << std::endl;
		count++;
		if(count == n)
			return;
		flag[tmp] = true;
		tmp = 0;
		while(flag[tmp]){
			tmp++;
			if(tmp == n)
				tmp = 0;
		}
	}
}

int main(){
	while(true){
		std::cin >> n;
		if(n==0)
			return 0;
		team = new char[n];
		res = new int*[n];
		for(int i=0; i<n; i++){
			res[i] = new int[3];
			for(int k=0; k<3; k++)
				res[i][k] = 0;
		}
		for(int i=0; i<n; i++){
			std::cin >> team[i];
			for(int k=0; k<n-1; k++){
				std::cin >> wl;
				res[i][wl]++;
			}
		}
		display();
		delete[] flag;
		for(int i=0; i<n; i++)
			delete[] res[i];
		delete[] res;
		delete[] team;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a;
    cin >> a;
    if('a' <= a and a <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}


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

bool isEvenstr(string s) {
    int n = s.length();
    if(n % 2) return false;
    string a = s.substr(0,n/2), b = s.substr(n/2);
    return a == b;
}

int main() {
    string s; cin >> s;
    int n = s.length();
    for(int i=0; i<n; i++) {
        int m = n - i - 1;
        s.pop_back();
        if(isEvenstr(s)) {
            cout << m << endl;
            return 0;
        }
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int a, b, h; cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;

  return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int parent (int i){
    return i/2;
}
int left(int i){
    return 2*i;
}
int right(int i){
    return 2*i+1;
}
int main(void){
    int H,i,A[MAX+1];
    scanf("%d",&H);
    for(i=1;i<=H;i++)
        scanf("%d",&A[i]);
    for(i=1;i<=H;i++){
        printf("node %d: key = %d, ",i,A[i]);
        if(parent(i) >= 1)
            printf("parent key = %d, ",A[parent(i)]);
        if(left(i) <= H)
            printf("left key = %d, ",A[left(i)]);
        if(right(i) <= H)
            printf("right key = %d, ",A[right(i)]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 616
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, H, W; cin >> N >> H >> W;
    ll ans = 0;
    rep(i, N){
        ll a, b; cin >> a >> b;
        if(a >= H && b >= W) ans++;
    }
    cout << ans << endstr;
    return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	int N,M;
	cin >> N >> M;
	vector<long long> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);
	vector<pair<int,long long>> C_B(M+1);
	for(int i=0;i<M;i++)	cin >> C_B.at(i).second >> C_B.at(i).first;

	sort(A.begin(),A.end(),greater<long long>());
	sort(C_B.begin(),C_B.end(),greater<pair<int,long long>>());
	long long ans=0;
	int a=0;
	int c_b=0;
	for(int i=0;i<N;){
		if(A.at(a)>C_B.at(c_b).first){
			ans+=A.at(a);
			a++;
			i++;
		}
		else{
			long long x=min((long long)N-i,C_B.at(c_b).second);
			ans+=C_B.at(c_b).first*x;
			c_b++;
			i+=x;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
 
int n,m;
char S[12];
int main() {
	scanf("%s", S);
	string tgt = S;
	string start = "hi";
	REP(cop, 7) {
		if(start == tgt) {
			printf("Yes\n");
			return 0;
		}
		start += "hi";
	}
	printf("No\n");
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


vector< vector<Int> >
bfs(vector<string> &st,Int sy,Int sx,char wall,Int dir){
  Int h=st.size(),w=st.front().size();
  vector<vector<Int> > dp(h,vector<Int>(w,-1));
  using P = pair<Int, Int>;
  queue<P> qu;

  dp[sy][sx]=0;
  qu.emplace(sy,sx);

  Int dy[]={1,-1,0,0,1,1,-1,-1};
  Int dx[]={0,0,1,-1,1,-1,1,-1};
  auto in=[&](Int y,Int x){return 0<=y&&y<h&&0<=x&&x<w;};

  while(!qu.empty()){
    Int y,x;
    tie(y,x)=qu.front();qu.pop();
    for(Int k=0;k<dir;k++){
      Int ny=y+dy[k],nx=x+dx[k];
      if(!in(ny,nx)||st[ny][nx]==wall) continue;
      if(~dp[ny][nx]) continue;
      dp[ny][nx]=dp[y][x]+1;
      qu.emplace(ny,nx);
    }
  }

  return dp;
}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(Int i=0;i<h;i++) cin>>st[i];
  Int ans=0;
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(st[i][j]=='#') continue;
      auto di=bfs(st,i,j,'#',4);
      for(Int a=0;a<h;a++)
        for(Int b=0;b<w;b++)
          chmax(ans,di[a][b]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.begin(), x.end(), std::greater<int>())
#define swap(a, b) \
  do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
#define vi vector<int>
using namespace std;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int sum = 0;
  
  for(int i = a; i <= b; i++) {
    string c = to_string(i);
    reverse(c.begin(), c.end());
    if(to_string(i) == c) {
      ++sum;
    }
  }
  cout << sum << endl;
}


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

int main() {
	long long N, K, ANS = 0;
	cin >> N >> K;
	vector<long long> H(N);
	for (int i = 0; i < N; i++) cin >> H[i];
	sort(H.begin(), H.end());
	for (int i = 0; i < N - K; i++) ANS += H[i];
	cout << ANS << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb(x) push_back((ll)(x))
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

/*ll dp[100001],path[100001];

void init(){
	f(i,0,100001){
		dp[i]=-1;
	}
}

void solve(ll n){
	if(i==1){
		return dp[n]=1;
	}

	if(dp[n]!=-1){
		return dp[n];
	}else{
		if()
	}
}
*/
int main(){
	ini();

	ll n,k;
	cin >> n>> k;
	ll a[n+1]={0};
	f(i,0,n){
		ll d;
		cin >> d;
		f(j,0,d){
			ll m;
			cin >> m;
			a[m]++;
		}
	}

	ll ans=0;
	f(i,1,n+1){
		if(a[i]==0){
			ans++;
		}
	}

	cout <<ans;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;

#define N  100005
signed main()
{
	fast;
    int n,m;
    cin>>n>>m;
    int arr[m];
    int i,j,k;
    int sum=0;
    for(i=0;i<=m-1;i++)
    {
    	cin>>arr[i];
    	sum+=arr[i];
	}
	cout<<max((int)(-1),n-sum)<<endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    ll N, count;
    cin>>N;
    count=N+1;
    rep(i, sqrt(N)){
        if(N%(i+1)==0) count = min(count, i+(N/(i+1)-1));
        //cout << count << endl;
    }
    cout << count << endl;
    return 0;
}


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

int a,b,c;
bool unko;

int main(){
    std::cin >> a>>b>>c;
    unko=false;
    if(a+b==c){
        unko=true;
    }
    else if(a+c==b){
        unko=true;
    }
    else if(b+c==a){
        unko=true;
    }
    if(unko){
        std::cout<<"Yes"<<std::endl;
    }
    else{
        std::cout<<"No"<<std::endl;
    }
    return 0;
}



Measured memory_bytes: 384
while True:
  r, n = list(map(int, input().split()))
  if r==0:
    break

  b = [0 for i in range(60)]
  for i in range(n):
    ll, rr, x = list(map(int, input().split()))
    for j in range(ll, rr):
      b[30+j] = max(b[30+j], x)
  b[30-r-1], b[30+r] = 1e9, 1e9

  ans = 1e9
  for x in range(30-r, 30+r+1):
    t = (r**2-(x-30)**2)**(1/2)
    cur = r-t+min(b[x], b[x-1])
    ans = min(ans, cur)
  print(ans)


Measured memory_bytes: 5680
#include<iostream>

int main(){
	const int MAX_N = 10000;
	bool is_prime[MAX_N+1];
	for(int i=0;i<=MAX_N;i++){
		is_prime[i] = 1;
	}
	is_prime[0] = is_prime[1] = 0;
	for(int i=2;i<=MAX_N;i++){
		if(is_prime[i]){
			for(int j=i*2;j<=MAX_N;j+=i){
				is_prime[j] = 0;
			}
		}
	}

	int N;
	while(std::cin >> N, !std::cin.eof()){
		int res = 0;
		for(int i=1;i<=N;i++){
			if(is_prime[i] && is_prime[N-i+1]){
				res++;
			}
		}
		std::cout << res << std::endl;
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) {
        cin >> a[i];
    }
    ll dp[n+1];
    dp[0] = 1000;
    ll max_dp = 1000;
    REP(t, n+1) {
        for(int i = 0; i < t-1; i++) {
            for(int j = i+1; j < t; j++) {
                max_dp = max(max_dp, dp[i]/a[i]*a[j] + dp[i]%a[i]);
            }
        }
        //cout << max_dp << endl;
        dp[t] = max_dp;
        max_dp = 1000;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int 
#define mk make_pair

int main(){
   int x;cin>>x;
   if(x>=30)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    return 0;
}
/*int main(){
    ll n,d;
    cin>>n>>d;
    ll x[n],y[n];
    int ans=0;
    d=d*d;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        ll val=x[i]*x[i]+y[i]*y[i];
        if(d>=val)ans++;
    }
    cout<<ans<<endl;
    return 0;
}*/


Measured memory_bytes: 3504
A, B, C = sorted(list(map(int, input().split(' '))))
ans = 0
upper = C
temp = (C-B) + (C-A)
if temp % 2 == 0:
    ans = temp // 2
else:
    temp = (C+1-B) + (C+1-(A+1))
    ans = 1 + temp // 2
print(ans)


Measured memory_bytes: 2940
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = "NG";
		for(int i = A;i < B + 1;i++){
			if(i % K == 0){
				ans = "OK";
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35724
n,t=map(int,input().split())
a=list(map(int,input().split()))
l=[]
M=a[0]
m=a[0]
for i in range(1,n):
    if a[i]>M:
        M=a[i]
        l.append(M-m)
    if a[i]<m:
        M=a[i]
        m=a[i]
print(l.count(max(l)))

Measured memory_bytes: 14252
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            count = 0
            for dx, dy in ((-1,0), (0,1), (1,0), (0,-1)):
                x, y = i+dx, j+dy
                if 0 <= x and 0 <= y and x <= H-1 and y <= W-1:
                    if s[x][y] == '.':
                        count += 1
            if count == 4:
                print('No')
                exit()

print('Yes')

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

using namespace std;

char grid[1000][1000];
int dp[1005][1005];
int h,w;
const int MOD=1e9+7;

int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>grid[i][j];
        }
    }
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=i;k-i<2;k++){
                int c=j;
                if(k==i){
                    c=j+1;
                }
                if(c<w && k<h && grid[k][c]=='.'){
                    dp[k][c]+=dp[i][j];;
                    if(dp[k][c]>=MOD){
                        dp[k][c]%=MOD;
                    }
                }
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

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


int main() {
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << s[3] << s[4] << " " << s[6]<< s[7] << s[8] << s[9] << s[10] << s[11] << s[12] << " "<< s[14] << s[15] << s[16] << s[17] << s[18] <<endl;
    
    return 0;
}

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

#define ll long long int

vector<ll>v;

void Generate(ll kt)
{
    ll su=0;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);
    v.push_back(4);
    v.push_back(5);
    v.push_back(6);
    v.push_back(7);
    v.push_back(8);
    v.push_back(9);

    for(ll i=0; ; i++)
    {
        ll dg=v[i]%10;
        ll num=v[i];
        //cout<<v[i]<<endl;
        if(dg-1>=0)
        {
            ll nm=dg-1;
            if((num*10)+nm>v[v.size()-1])
                v.push_back((num*10)+nm);
        }
        if((num*10)+dg>v[v.size()-1])
            v.push_back((num*10)+dg);
        if(dg+1<=9)
        {
            if((num*10)+(dg+1)>v[v.size()-1])
            v.push_back((num*10)+(dg+1));
        }


        if(v.size()>=kt)
            break;
    }
}

int main()
{
    ll k;
    cin>>k;
    Generate(k+2);
    cout<<v[k-1]<<endl;

    /*Generate(100000);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        cout<<n<<"="<<v[n-1]<<endl;
    }
*/
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;


const ll mod = 1e9+7;
const double eps = 1e-9;




void solve(){
    string a,b;
    cin>>a>>b;
    if(a==b.substr(0,(int)a.size()))cout<<"Yes\n";
    else cout<<"No\n";
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
lli n,x;
vll a;
lli ans;
int main(){
    cin >> n >> x;
    a = vll(n+1);
    for(lli i = 1;i <= n;i++) cin >> a[i];
    for(lli i = 1;i <= n;i++){
        if(a[i] + a[i-1] > x){
            ans += a[i] + a[i-1] - x;
            a[i] -= a[i] + a[i-1] - x;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;


using edge=struct {int to;int cost;};
using G=vector<vector<edge>>;
const int inf=1<<29;
 
int dist[110][110];

void dijkstra(const G &graph,int s){
    const int n=graph.size();
    rep(i,n)rep(j,n) dist[i][j]=inf;
    
    using state=tuple<int,int,int>;
    priority_queue<state,vector<state>,greater<state>> q;
    dist[s][0]=0,q.push(state(0,s,0));
     
    while(!q.empty()){
        int c,v,m;
        tie(c,v,m)=q.top();q.pop();
        for(auto &e:graph[v]){
            int nc=c+e.cost,nv=e.to,nm=m;
            if(chmin(dist[nv][nm],nc)) q.push(state(nc,nv,nm));
            nc=c,nv=e.to,nm=m+1;
            if(nm<n&&chmin(dist[nv][nm],nc)) q.push(state(nc,nv,nm));
        }
    }
}


int main(void){
	int n,m,c;
	while(cin >> n >> m >> c,n){
		G graph(n);
		rep(loop,m){
			int from,to,cost;
			cin >> from >> to >> cost;
			graph[from-1].push_back({to-1,cost});
		}

		dijkstra(graph,0);
		int ans=0;
		while(dist[n-1][ans]>c) ans++;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3212
#include <iostream>
using namespace std;
typedef long long ll;


const int MAX_A = 10000010;
int divisor[MAX_A];

int sieve(int n){
    for (int i = 2; i <= n; ++i) divisor[i] = i;
	for (int i = 2; i <= n; i++){
		if (divisor[i] == i){
			for (int j = i+i; j <= n; j += i) {
                divisor[j] = i;
			}
		}
	}
    return 0;
}


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

    ll sum = 0;
    for (ll i = 1; i <= N; ++i){

        ll res = 1, a = i;
        while (a != 1){

            int k = 1;
            int d = divisor[a];
            while(a%d==0) {
                a/=d;
                k++;
            }
            res *= k;
        }
        sum += i * res; 
    }

    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 42664
import java.util.*;
      
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] card = new int[53];
        
        for(int i = 1;i <= n;i++){
        	String mark = sc.next();
        	int num = sc.nextInt();
        	if(mark.equals("S")){
        		card[num] = 1;
        	}else if(mark.equals("H")){
        		card[num + 13] = 1;
        	}else if(mark.equals("C")){
        		card[num + 26] = 1;
        	}else if(mark.equals("D")){
        		card[num + 39] = 1;
        	}
        	//System.out.println(card[i]);
        }
        
        for(int i = 1;i <= 52;i++){
        	if(card[i] == 0){
        		if(1 <= i && i <= 13){
        			System.out.println("S "+ i);
        		}else if(14 <= i && i <= 26){
        			System.out.println("H " + (i - 13));
        		}else if(27 <= i && i <= 39){
        			System.out.println("C "+(i - 26));
        		}else if(40 <= i && i <= 52){
        			System.out.println("D "+(i - 39));
        		}
        	}
        }
    }
}

Measured memory_bytes: 18084
#include<stdio.h>
int main()
{
    int a,b,area,perimeter;
    scanf("%d %d",&a,&b);
    if(a>=1&&b<=100){
        area=a*b;
        perimeter=2*(a+b);
        printf("%d %d\n",area,perimeter);
    }
    else{
        printf("numbers aren't within constraint");
    }
    return 0;
}



Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, m;
vector<pair<int, int>> ab;
priority_queue<int> pq;

int main()
{
    cin>>n>>m;
    REP(i,n) {
        int a, b;
        cin>>a>>b;
        ab.push_back({a, b});
    }
    SORT(ab);
    ll ans = 0ll;
    int idx = 0;
    REP(i,m) {
        while (idx < n && ab[idx].fst <= i + 1) {
            pq.push(ab[idx].scd);
            idx++;
        }
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1908
N, K = map(int, input().split())


def Digit(X, n):
    X_dumy = X
    out = ''
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


leng = str(Digit(N, K))
print(len(leng))

Measured memory_bytes: 2940
#include<iostream>
#include<utility>
using namespace std;
 
int main(){
    
    int H, W;
    
    while (1){
        cin >> H >> W;
        if ( (H == 0) && (W == 0) ){
            break;
        }

        for ( int i = 0; i < H; i++ ){
            for ( int j = 0; j < W; j++ ){
                if ((i + j) %  2 == 0) {
                cout << "#";
                } else {
                cout << ".";
                }
            }
        cout << endl;
        }
    cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_GRP_MAX		1000									// 最大グループ数

// 内部変数
static FILE *szpFpI;											// 入力
static int si2Num[D_GRP_MAX][D_GRP_MAX];						// 値
static int siGCnt;												// グループ数
static char sc1Out[D_GRP_MAX * 10];								// 出力内容
static char *scpOut;											// 出力位置

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 出力内容 - 追加
int
fOutAdd(
	int piVal					// <I> 値
)
{
	char lc1Buf[1024];
	sprintf(lc1Buf, "%d ", piVal);
	int liLen = strlen(lc1Buf);
	memcpy(scpOut, lc1Buf, liLen);
	scpOut += liLen;

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// 最大値 - 取得
	int liMax;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liMax);

	// グループ数 - 取得
	for (siGCnt = 2; ; siGCnt++) {
		int liVal = siGCnt * (siGCnt - 1) / 2;
		if (liVal < liMax) {
			continue;
		}
		else if (liVal == liMax) {
			break;
		}
		else {
			return -1;
		}
	}

	// 値 - セット
	int liNum = 1;
	for (i = 0; i < siGCnt; i++) {
		for (j = i; j < siGCnt - 1; j++) {
			si2Num[i][j] = liNum;
			si2Num[j + 1][i] = liNum;
			liNum++;
		}
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int i, j, liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	if (liRet == 0) {
		sprintf(lc1Buf, "Yes\n");
		fOutLine(lc1Buf);

		// グループ数
		sprintf(lc1Buf, "%d\n", siGCnt);
		fOutLine(lc1Buf);

		// グループ
		for (i = 0; i < siGCnt; i++) {

			// 値数
			scpOut = sc1Out;
			fOutAdd(siGCnt - 1);

			// 値
			for (j = 0; j < siGCnt - 1; j++) {
				fOutAdd(si2Num[i][j]);
			}

			// 出力
			*scpOut = '\0';
			scpOut--;
			*scpOut = '\n';
			fOutLine(sc1Out);
		}
	}
	else {
		sprintf(lc1Buf, "No\n");
		fOutLine(lc1Buf);
	}

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#define MAX_N 1 << 15 + 1
#define MAX_SQUARE 200
using namespace std;

int square[MAX_SQUARE];
int square_numbers;
int dp[5][MAX_N];

void calcDp() {
  for (int i = 1; i <= square_numbers; i++) {
    for (int k = 0; k < MAX_N; k++) {
      for (int j = 0; j < 4; j++) {
	if (k + square[i] >= MAX_N) break;
	dp[j + 1][k + square[i]] += dp[j][k];
      }
    }
  }
}

void calcSquare() {
  for (int i = 0; i < MAX_SQUARE; i++) {
    square[i] = i * i;
  }

  for (int i = 0; i < MAX_SQUARE; i++) {
    if (square[i] > (1 << 15)) {
      square_numbers = i - 1;
      break;
    }
  }
}

void init() {
  for (int i = 0; i < MAX_SQUARE; i++) {
    square[i] = 0;
  }
  
  for (int j = 0; j < 5; j++) {
    for (int k = 0; k < MAX_N; k++) {
      dp[j][k] = 0;
    }
  }
  dp[0][0] = 1;
}

int main() {
  init();
  calcSquare();
  calcDp();

  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;

    int sum = 0;
    for (int j = 1; j < 5; j++) {
      sum += dp[j][n];
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int N;
    while (cin >> N, N) {
        vector<set<int>> s(N);
        rep(i, N) {
            int m;
            cin >> m;
            rep(j, m) {
                int p;
                cin >> p;
                s[i].insert(p);
            }
        }

        int K;
        cin >> K;
        vector<bool> b(N, true);
        rep(k, K) {
            int l;
            cin >> l;
            rep(i, N) {
                if (s[i].count(l) == 0) b[i] = false;
            }
        }

        int cnt = 0;
        int ans = -1;
        rep(i, N) {
            if (b[i]) {
                cnt++;
                ans = i + 1;
            }
        }

        if (cnt != 1) ans = -1;
        cout << ans << endl;
    }

}

Measured memory_bytes: 3576